/* ------------------------------------------------------------- tokens */

:root {
  color-scheme: light dark;

  --bg: #f6f8fc;
  --bg-accent-a: rgba(37, 99, 235, 0.10);
  --bg-accent-b: rgba(14, 165, 233, 0.08);
  --surface: #ffffff;
  --surface-sunken: #f8fafc;
  --surface-hover: #f1f5f9;

  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --on-primary: #ffffff;

  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-line: #fecaca;

  --success: #047857;
  --success-soft: #ecfdf5;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.07);

  --step: 4px;
  --focus: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

/* theme.js resolves "system" and always writes data-theme before first paint,
   so one explicit dark block covers both the toggle and the OS preference. */
:root[data-theme="dark"] {
  --bg: #0b1120;
  --bg-accent-a: rgba(37, 99, 235, 0.16);
  --bg-accent-b: rgba(14, 165, 233, 0.10);
  --surface: #131c2e;
  --surface-sunken: #0f172a;
  --surface-hover: #1c2740;

  --text: #e8eefc;
  --text-muted: #9aa8c2;
  --text-faint: #6b7a96;

  --line: #24314c;
  --line-strong: #33425f;

  --primary: #4f8bf7;
  --primary-hover: #6b9ff9;
  --primary-soft: #17233c;
  --on-primary: #08122a;

  --danger: #f87171;
  --danger-soft: #2a1618;
  --danger-line: #4c2326;

  --success: #34d399;
  --success-soft: #10231d;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.45);
  --focus: 0 0 0 3px rgba(79, 139, 247, 0.45);
}

* { box-sizing: border-box; }

/* Author display rules below would otherwise beat the UA's [hidden] rule. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1200px 520px at 12% -8%, var(--bg-accent-a), transparent 70%),
    radial-gradient(900px 460px at 105% 108%, var(--bg-accent-b), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

h1, h2, h3, p { margin: 0; }

a { color: var(--primary); }

/* Visible focus for keyboard users only. */
:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--radius-sm);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 20;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-md) 0;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus { left: 0; }

/* ------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  display: flex;
  gap: calc(var(--step) * 4);
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: calc(var(--step) * 3) 0;
}

.brand {
  display: flex;
  gap: calc(var(--step) * 3);
  align-items: center;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--on-primary);
  background: linear-gradient(140deg, var(--primary), #0ea5e9);
  box-shadow: var(--shadow-sm);
}

.brand-mark svg { width: 20px; height: 20px; }

.brand-text { display: grid; min-width: 0; }

.brand-text strong {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-sub {
  color: var(--text-muted);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  gap: calc(var(--step) * 2);
  align-items: center;
  min-width: 0;
}

.link-chip {
  display: inline-flex;
  gap: calc(var(--step) * 2);
  align-items: center;
  max-width: 340px;
  padding: calc(var(--step) * 2) calc(var(--step) * 2) calc(var(--step) * 2) calc(var(--step) * 3);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.link-chip:hover { background: var(--surface-hover); }

.link-chip-url {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-muted);
}

.theme-toggle:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
  color: var(--text);
}

.theme-toggle svg {
  grid-area: 1 / 1;
  width: 17px;
  height: 17px;
}

/* Show only the icon matching the active preference. */
.theme-toggle .icon-system,
.theme-toggle .icon-light,
.theme-toggle .icon-dark { display: none; }

:root[data-theme-pref="system"] .theme-toggle .icon-system,
:root[data-theme-pref="light"] .theme-toggle .icon-light,
:root[data-theme-pref="dark"] .theme-toggle .icon-dark { display: block; }

/* Before theme.js runs there is no preference attribute; show something. */
:root:not([data-theme-pref]) .theme-toggle .icon-system { display: block; }

.link-chip-copy {
  flex: none;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

/* ------------------------------------------------------------ buttons */

button {
  font: inherit;
  cursor: pointer;
}

button, .download-link, .ghost-button {
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

#sendTextBtn, .download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 calc(var(--step) * 5);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: var(--on-primary);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

#sendTextBtn:hover:not(:disabled), .download-link:hover { background: var(--primary-hover); }

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 calc(var(--step) * 4);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

.ghost-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.ghost-button.danger { color: var(--danger); }

.ghost-button.danger:hover:not(:disabled) {
  border-color: var(--danger-line);
  background: var(--danger-soft);
}

.text-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.text-button:hover { text-decoration: underline; }

button:disabled, .ghost-button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.delete-button {
  min-height: 36px;
  padding: 0 calc(var(--step) * 4);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 650;
}

.delete-button:hover {
  border-color: var(--danger-line);
}

/* -------------------------------------------------------------- layout */

.status-wrap {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: calc(var(--step) * 6) 0 calc(var(--step) * 12);
}

.columns {
  display: grid;
  gap: calc(var(--step) * 5);
  align-items: start;
}

.column {
  display: grid;
  gap: calc(var(--step) * 5);
  min-width: 0;
}

@media (min-width: 940px) {
  .columns { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .column:last-child { position: sticky; top: 88px; }
}

.card {
  padding: calc(var(--step) * 6);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  gap: calc(var(--step) * 3);
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: calc(var(--step) * 4);
}

.card-title {
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.card > .card-title { margin-bottom: calc(var(--step) * 4); }

.card-sub {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 13px;
}

.hint {
  color: var(--text-muted);
  font-size: 12.5px;
}

.meta-line {
  margin-top: calc(var(--step) * 4);
  padding-top: calc(var(--step) * 3);
  border-top: 1px dashed var(--line);
}

/* -------------------------------------------------------------- status */

.status {
  margin-top: calc(var(--step) * 4);
  padding: calc(var(--step) * 3) calc(var(--step) * 4);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13.5px;
  font-weight: 650;
}

.status.error {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger);
}

/* ------------------------------------------------------------ dropzone */

.dropzone {
  display: grid;
  justify-items: center;
  gap: calc(var(--step) * 1);
  padding: calc(var(--step) * 8) calc(var(--step) * 4);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover { border-color: var(--primary); background: var(--primary-soft); }

.dropzone.dragover {
  border-color: var(--primary);
  border-style: solid;
  background: var(--primary-soft);
}

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: calc(var(--step) * 2);
  border-radius: 14px;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--line);
}

.dropzone-icon svg { width: 22px; height: 22px; }

.dropzone-title { font-size: 15px; font-weight: 700; }

.dropzone-sub { color: var(--text-muted); font-size: 13px; }

.dropzone-link { color: var(--primary); font-weight: 650; text-decoration: underline; }

/* ------------------------------------------------------------ progress */

.progress {
  margin-top: calc(var(--step) * 4);
  padding: calc(var(--step) * 4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}

.progress-head {
  display: flex;
  gap: calc(var(--step) * 3);
  align-items: center;
  justify-content: space-between;
  margin-bottom: calc(var(--step) * 3);
  font-size: 13.5px;
  font-weight: 650;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--line);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #0ea5e9);
  transition: width 0.2s ease;
}

.progress-meta {
  margin-top: calc(var(--step) * 2);
  color: var(--text-muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------- password opt-in */

.protect-row {
  margin-top: calc(var(--step) * 4);
  padding: calc(var(--step) * 4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}

.protect-toggle {
  display: flex;
  gap: calc(var(--step) * 3);
  align-items: flex-start;
  cursor: pointer;
}

.protect-toggle input {
  flex: none;
  width: 17px;
  height: 17px;
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
}

.protect-toggle-text { display: grid; gap: 1px; }

.protect-toggle-title { font-size: 14px; font-weight: 650; }

.protect-toggle-sub { color: var(--text-muted); font-size: 12.5px; }

.protect-field { display: grid; gap: calc(var(--step) * 2); margin-top: calc(var(--step) * 3); }

input[type="password"], textarea {
  width: 100%;
  padding: calc(var(--step) * 3) calc(var(--step) * 4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
}

input[type="password"]::placeholder, textarea::placeholder { color: var(--text-faint); }

input[type="password"]:focus-visible, textarea:focus-visible {
  border-color: var(--primary);
  box-shadow: var(--focus);
}

/* ----------------------------------------------------------- text form */

.text-form { display: grid; gap: calc(var(--step) * 3); }

.text-form textarea {
  min-height: 92px;
  line-height: 1.5;
  resize: vertical;
}

.text-form-footer {
  display: flex;
  gap: calc(var(--step) * 3);
  align-items: center;
  justify-content: space-between;
}

/* --------------------------------------------------------------- lists */

.note-list, .file-list {
  display: grid;
  gap: calc(var(--step) * 2);
}

.note-list:not(:empty), .file-list:not(:empty) { margin-top: calc(var(--step) * 4); }

.note-row, .file-row {
  padding: calc(var(--step) * 4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color 0.15s ease;
}

.note-row:hover, .file-row:hover { border-color: var(--line-strong); }

.note-text {
  max-height: 220px;
  margin: 0;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.note-footer, .file-actions {
  display: flex;
  gap: calc(var(--step) * 2);
  align-items: center;
}

.note-footer {
  justify-content: space-between;
  margin-top: calc(var(--step) * 3);
  padding-top: calc(var(--step) * 3);
  border-top: 1px solid var(--line);
}

.note-meta, .file-meta {
  color: var(--text-muted);
  font-size: 12.5px;
}

.note-actions { display: flex; gap: calc(var(--step) * 2); }

.file-row {
  display: flex;
  gap: calc(var(--step) * 4);
  align-items: center;
  justify-content: space-between;
}

.file-main { min-width: 0; }

.file-name {
  display: flex;
  gap: calc(var(--step) * 2);
  align-items: center;
  font-size: 14px;
  font-weight: 650;
}

.file-name-text { overflow-wrap: anywhere; }

.lock-badge {
  display: inline-flex;
  flex: none;
  gap: 4px;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.file-meta { margin-top: 2px; }

.file-actions { flex: none; }

.section-actions {
  display: flex;
  gap: calc(var(--step) * 2);
  flex-wrap: wrap;
}

/* --------------------------------------------------------- empty state */

.empty-state {
  margin-top: calc(var(--step) * 4);
  padding: calc(var(--step) * 8) calc(var(--step) * 4);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  text-align: center;
  background: var(--surface-sunken);
}

.empty-title { font-size: 14px; font-weight: 650; }

.empty-sub { margin-top: 2px; color: var(--text-muted); font-size: 13px; }

/* ------------------------------------------------------- login/unlock */

.login-card {
  width: min(440px, calc(100% - 32px));
  margin: 12vh auto 0;
  padding: calc(var(--step) * 8);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.login-card .eyebrow {
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-card h1 {
  margin: calc(var(--step) * 2) 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.login-card .subtitle { color: var(--text-muted); font-size: 14px; }

.login-form { display: grid; gap: calc(var(--step) * 3); margin-top: calc(var(--step) * 5); }

.login-form button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: var(--on-primary);
  font-size: 15px;
  font-weight: 700;
}

.login-form button:hover { background: var(--primary-hover); }

.login-card .hint { margin-top: calc(var(--step) * 4); text-align: center; }

/* --------------------------------------------------------- small screens */

@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; gap: calc(var(--step) * 2); }
  .brand-sub { display: none; }
  .link-chip { max-width: 100%; flex: 1; }
  .app-shell { padding-top: calc(var(--step) * 4); }
  .card { padding: calc(var(--step) * 4); }

  .file-row { flex-direction: column; align-items: stretch; }
  .file-actions > * { flex: 1; }
  .note-footer { flex-direction: column; align-items: stretch; gap: calc(var(--step) * 3); }
  .note-actions > * { flex: 1; }
  .section-actions > * { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
