:root {
  --forest: #174f48;
  --forest-strong: #103e39;
  --ink: #17201f;
  --muted: #63716f;
  --line: #d7dfdd;
  --soft: #f3f6f5;
  --paper: #ffffff;
  --amber: #b76b10;
  --danger: #a63e39;
  --shadow: 0 18px 50px rgba(24, 45, 42, 0.14);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #edf2f0;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #edf2f0; }
body { min-height: 100vh; margin: 0; letter-spacing: 0; }
button, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: default; }
.hidden { display: none !important; }

.shell { width: min(920px, 100%); min-height: 100vh; margin: 0 auto; background: var(--paper); }
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(390px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); box-shadow: var(--shadow); }
.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-row > div { display: grid; gap: 2px; }
.brand-row strong { font-size: 15px; }
.brand-row span:not(.brand-mark) { color: var(--muted); font-size: 12px; }
.brand-mark { display: grid; flex: 0 0 38px; width: 38px; height: 38px; place-items: center; border-radius: 6px; background: var(--forest); color: white; font-size: 12px; font-weight: 800; }
.login-panel .brand-row { margin-bottom: 30px; }
.login-panel label { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 700; }
.login-panel input { width: 100%; height: 46px; border: 1px solid #b9c5c2; border-radius: 6px; padding: 0 12px; color: var(--ink); }
.login-panel input:focus { border-color: var(--forest); outline: 3px solid rgba(23, 79, 72, 0.12); }
.primary-button { width: 100%; min-height: 44px; margin-top: 14px; border: 0; border-radius: 6px; background: var(--forest); color: white; font-weight: 750; }
.primary-button:hover { background: var(--forest-strong); }
.error { margin: 10px 0 0; color: var(--danger); font-size: 12px; }

.topbar { position: sticky; z-index: 5; top: 0; min-height: 66px; display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.96); }
.topbar-actions { display: flex; gap: 6px; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--ink); }
.icon-button:hover { border-color: #aebbb8; background: var(--soft); }
.icon-button svg, .dropzone svg, .action-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button.is-spinning svg { animation: spin 700ms cubic-bezier(.45, .08, .3, 1) both; }
@keyframes spin { to { transform: rotate(360deg); } }

.workspace-section { padding: 28px 24px 32px; }
.workspace-section + .workspace-section { border-top: 8px solid #edf2f0; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
.section-heading h1, .section-heading h2 { margin: 0; font-size: 23px; line-height: 1.2; }
.eyebrow { margin: 0 0 3px; color: var(--muted); font-size: 10px; font-weight: 800; }
.counter { min-width: 28px; height: 24px; display: grid; place-items: center; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 12px; font-weight: 750; }

.upload-mode { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-bottom: 14px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); }
.mode-button { min-height: 36px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 750; }
.mode-button.is-active { background: var(--paper); color: var(--ink); box-shadow: 0 1px 4px rgba(23, 32, 31, 0.1); }

.dropzone { min-height: 144px; display: grid; place-items: center; align-content: center; gap: 6px; border: 1.5px dashed #9fb1ad; border-radius: 8px; background: var(--soft); color: var(--forest); text-align: center; transition: border-color 150ms ease, background 150ms ease; }
.dropzone input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.dropzone svg { width: 26px; height: 26px; margin-bottom: 3px; }
.dropzone strong { font-size: 14px; }
.dropzone span { color: var(--muted); font-size: 12px; }
.dropzone:hover, .dropzone.is-dragging { border-color: var(--forest); background: #edf5f2; }

.text-upload-panel { display: grid; gap: 8px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); }
.field-label { color: var(--ink); font-size: 11px; font-weight: 750; }
.field-label:not(:first-child) { margin-top: 4px; }
.field-label span { margin-left: 4px; color: var(--muted); font-weight: 500; }
.filename-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; overflow: hidden; border: 1px solid #b9c5c2; border-radius: 6px; background: white; }
.filename-field:focus-within { border-color: var(--forest); outline: 3px solid rgba(23, 79, 72, 0.12); }
.filename-field input { min-width: 0; height: 40px; border: 0; outline: 0; padding: 0 10px; color: var(--ink); }
.filename-field > span { padding: 0 10px; color: var(--muted); font-size: 12px; }
.text-upload-panel textarea { width: 100%; min-height: 210px; resize: vertical; border: 1px solid #b9c5c2; border-radius: 6px; outline: 0; padding: 11px 12px; color: var(--ink); background: white; font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 12px; line-height: 1.55; }
.text-upload-panel textarea:focus { border-color: var(--forest); outline: 3px solid rgba(23, 79, 72, 0.12); }
.text-upload-footer { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.text-upload-footer > span { color: var(--muted); font-size: 11px; }
.text-upload-footer > span.limit-exceeded { color: var(--danger); font-weight: 700; }
.save-text-button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 6px; padding: 0 14px; background: var(--forest); color: white; font-size: 12px; font-weight: 750; }
.save-text-button:hover:not(:disabled) { background: var(--forest-strong); }
.save-text-button:disabled { background: #b9c5c2; }
.save-text-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.upload-queue { display: grid; gap: 8px; margin-top: 12px; }
.upload-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; }
.upload-item strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.upload-item span { color: var(--muted); font-size: 11px; }
.progress { grid-column: 1 / -1; height: 4px; overflow: hidden; border-radius: 2px; background: #dce4e2; }
.progress i { display: block; width: 0; height: 100%; background: var(--forest); transition: width 120ms linear; }

.file-list { display: grid; gap: 1px; border-top: 1px solid var(--line); }
.file-list.compact { margin-top: 18px; }
.file-row { min-height: 72px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.file-main { min-width: 0; display: grid; gap: 4px; }
.file-name { overflow: hidden; font-size: 13px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { color: var(--muted); font-size: 11px; }
.file-actions { display: flex; align-items: center; gap: 6px; }
.action-button { min-height: 34px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 6px; padding: 0 10px; background: white; color: var(--ink); font-size: 11px; font-weight: 700; text-decoration: none; }
.action-button:hover { border-color: #aebbb8; background: var(--soft); }
.action-button.primary { border-color: var(--forest); background: var(--forest); color: white; }
.action-button.danger { width: 34px; padding: 0; justify-content: center; color: var(--danger); }
.action-button svg { width: 15px; height: 15px; }
.empty-state { padding: 24px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.toast { position: fixed; z-index: 10; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); max-width: min(360px, calc(100vw - 32px)); padding: 12px 14px; border-radius: 6px; background: #17201f; color: white; box-shadow: var(--shadow); font-size: 12px; }
.toast.error-toast { background: var(--danger); }

@media (max-width: 640px) {
  .shell { width: 100%; }
  .topbar { padding: 10px 16px; }
  .workspace-section { padding: 24px 16px 28px; }
  .file-row { grid-template-columns: 1fr; align-items: start; }
  .file-actions { width: 100%; }
  .action-button:not(.danger) { flex: 1; justify-content: center; }
  .text-upload-panel { padding: 14px; }
  .text-upload-panel textarea { min-height: 250px; }
  .text-upload-footer { align-items: stretch; flex-direction: column; }
  .save-text-button { width: 100%; }
  .login-view { padding: 18px; }
  .login-panel { padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
