/* ---------- foundation ---------- */
:root {
  --bg: #f1ede2;
  --bg-elev: #e9e3d3;
  --ink: #0c0c0c;
  --ink-2: #2a2722;
  --muted: #8b8579;
  --rule: #1a1a1a;
  --accent: #c1292e;
  --accent-ink: #fdf6e9;
  --shadow: 0 24px 48px -16px rgba(12, 12, 12, 0.18);
  --maxw: 1280px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  overflow-x: hidden;
}

/* warm grain overlay */
.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  mix-blend-mode: multiply;
  opacity: 0.55;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='7'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

::selection { background: var(--ink); color: var(--bg); }

a { color: inherit; text-decoration: none; }
button { background: none; border: 0; font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }

/* ---------- top + bottom bars ---------- */
.top-bar, .bottom-bar {
  position: fixed; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 28px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  z-index: 50;
}
.top-bar { top: 0; border-bottom: 1px solid var(--rule); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); }
.bottom-bar { bottom: 0; border-top: 1px solid var(--rule); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); }

.mark { font-weight: 700; }
.muted { color: var(--muted); }
.time { font-variant-numeric: tabular-nums; }

/* ---------- login page ---------- */
.login-body { min-height: 100vh; display: flex; flex-direction: column; }

.login-stage {
  flex: 1;
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 120px 48px 120px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  gap: 24px;
}

.login-stage.login-minimal {
  max-width: 720px;
  justify-items: stretch;
  align-content: center;
  min-height: calc(100vh - 60px);
  padding: 60px 48px;
}
.login-stage.login-minimal .pw-form { margin-top: 0; }

.login-eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.22em;
  color: var(--ink-2);
  border: 1px solid var(--rule);
  padding: 6px 12px 6px 10px;
  width: fit-content;
}
.login-eyebrow .dot {
  width: 8px; height: 8px; background: var(--accent);
  display: inline-block;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.display {
  font-family: "Fraunces", "Times New Roman", serif;
  font-weight: 300;
  font-size: clamp(96px, 18vw, 280px);
  line-height: 0.86;
  letter-spacing: -0.05em;
  font-variation-settings: "opsz" 144, "SOFT" 50;
  margin: 8px 0 4px;
  color: var(--ink);
}
.display .word { display: inline; }
.display .italic { font-style: italic; font-variation-settings: "opsz" 144, "SOFT" 100; font-weight: 400; }
.display .period { color: var(--accent); }

.lede {
  font-size: 18px;
  line-height: 1.55;
  max-width: 520px;
  color: var(--ink-2);
  margin-top: 24px;
}

.error-line {
  font-size: 13px;
  color: var(--accent);
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 4px;
  letter-spacing: 0.04em;
}
.err-mark { font-size: 18px; font-family: "Fraunces", serif; line-height: 1; }

.pw-form {
  margin-top: 36px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0;
  max-width: 720px;
  border: 1px solid var(--rule);
}

.pw-label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-right: 1px solid var(--rule);
  background: var(--bg);
}
.pw-prompt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--muted);
  border-right: 1px solid var(--rule);
  padding-right: 14px;
}
.pw-input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: "JetBrains Mono", monospace;
  font-size: 17px;
  letter-spacing: 0.12em;
  color: var(--ink);
  padding: 0;
}
.pw-input::placeholder { color: var(--muted); letter-spacing: 0.18em; }
.cursor {
  color: var(--accent);
  font-size: 17px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.pw-submit {
  background: var(--ink);
  color: var(--bg);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
  transition: background .18s ease;
}
.pw-submit:hover { background: var(--accent); color: var(--accent-ink); }
.pw-submit .key-hint {
  font-size: 10px;
  border: 1px solid color-mix(in srgb, var(--bg) 50%, transparent);
  padding: 4px 8px;
  letter-spacing: 0.14em;
  opacity: 0.85;
}

/* ---------- dashboard ---------- */
.app-body { padding: 0; min-height: 100vh; padding-bottom: 80px; }

.app-header {
  position: sticky; top: 0; z-index: 40;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 32px;
  padding: 22px 32px;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  font-size: 11px;
  letter-spacing: 0.18em;
  border: 1px solid var(--rule);
  padding: 5px 8px;
  font-weight: 700;
}
.brand-name {
  font-family: "Fraunces", serif;
  font-weight: 400;
  font-size: 28px;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 72, "SOFT" 30;
}
.brand-name em { color: var(--accent); font-style: normal; }

.header-stats { display: flex; gap: 28px; }
.stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.stat-num {
  font-family: "Fraunces", serif;
  font-size: 26px;
  font-weight: 400;
  font-variation-settings: "opsz" 72;
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 6px;
}

.logout-form { display: flex; }
.logout-btn {
  border: 1px solid var(--rule);
  padding: 9px 14px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: background .15s, color .15s;
}
.logout-btn:hover { background: var(--ink); color: var(--bg); }

/* ---- dropzone ---- */
.dropzone {
  margin: 32px 32px 0;
  border: 1.5px dashed var(--rule);
  background: var(--bg-elev);
  padding: 56px 32px;
  text-align: center;
  position: relative;
  transition: background .2s, border-color .2s;
}
.dropzone.is-drag {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  border-color: var(--accent);
  border-style: solid;
}
.drop-display {
  font-family: "Fraunces", serif;
  font-weight: 300;
  font-size: clamp(40px, 6vw, 78px);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variation-settings: "opsz" 144, "SOFT" 80;
  font-style: italic;
}
.drop-sub {
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-2);
  letter-spacing: 0.02em;
}
.link-btn {
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
  font-weight: 500;
}
.link-btn:hover { color: var(--accent); }

.upload-list {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}
.upload-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--rule);
  font-size: 12px;
}
.upload-row .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row .pct { font-variant-numeric: tabular-nums; color: var(--muted); }
.upload-row .bar {
  width: 240px; height: 4px; background: var(--bg-elev); position: relative; overflow: hidden;
}
.upload-row .bar::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--ink); width: var(--p, 0%);
  transition: width .12s linear;
}
.upload-row.is-done .bar::after { background: var(--accent); }
.upload-row.is-error .bar::after { background: var(--accent); width: 100%; }
.upload-row.is-error .pct { color: var(--accent); }

/* ---- files section ---- */
.files { margin: 64px 32px 0; }
.files-bar {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 16px;
  margin-bottom: 24px;
}
.section-title {
  font-family: "Fraunces", serif;
  font-weight: 400;
  font-size: 36px;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 144, "SOFT" 30;
}
.filter input {
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  padding: 6px 4px;
  width: 240px;
  font-size: 13px;
  outline: 0;
}
.filter input:focus { border-color: var(--accent); }

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
.file-card {
  background: var(--bg);
  display: flex; flex-direction: column;
  cursor: pointer;
  position: relative;
  transition: background .15s;
}
.file-card:hover { background: var(--bg-elev); }
.thumb {
  aspect-ratio: 4 / 3;
  background: var(--bg-elev);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--rule);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-ext {
  font-family: "Fraunces", serif;
  font-weight: 300;
  font-size: 64px;
  font-style: italic;
  letter-spacing: -0.04em;
  color: var(--ink);
  font-variation-settings: "opsz" 144, "SOFT" 100;
}
.thumb-badge {
  position: absolute;
  top: 10px; left: 10px;
  background: var(--ink); color: var(--bg);
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  padding: 4px 7px;
  font-weight: 500;
}
.file-meta {
  padding: 14px 16px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.file-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.file-sub {
  display: flex; justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.file-actions {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--rule);
}
.file-actions button {
  flex: 1;
  padding: 10px 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  border-right: 1px solid var(--rule);
  transition: background .12s;
  color: var(--ink-2);
}
.file-actions button:last-child { border-right: 0; }
.file-actions button:hover { background: var(--ink); color: var(--bg); }
.file-actions .danger:hover { background: var(--accent); color: var(--accent-ink); }
.file-actions .copied { background: var(--accent) !important; color: var(--accent-ink) !important; }

.empty {
  grid-column: 1 / -1;
  background: var(--bg);
  padding: 80px 24px;
  text-align: center;
  color: var(--muted);
  display: flex; flex-direction: column; gap: 18px; align-items: center;
}
.empty-mark {
  font-family: "Fraunces", serif;
  font-size: 96px;
  font-weight: 300;
  font-style: italic;
  line-height: 1;
  color: var(--ink);
  font-variation-settings: "opsz" 144;
}

/* ---- preview modal ---- */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: color-mix(in srgb, #0c0c0c 85%, transparent);
  cursor: pointer;
}
.modal-shell {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--rule);
  width: min(1100px, 100%);
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
}
.modal-title {
  font-weight: 500;
  font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-right: 16px;
}
.modal-close {
  font-family: "Fraunces", serif;
  font-size: 28px;
  line-height: 1;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.modal-close:hover { background: var(--ink); color: var(--bg); }
.modal-body {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  background: #0c0c0c;
  min-height: 320px;
  overflow: hidden;
}
.modal-body img, .modal-body video {
  max-width: 100%; max-height: 70vh;
  object-fit: contain;
  display: block;
}
.modal-body audio { width: 80%; }
.modal-body iframe { width: 100%; height: 70vh; border: 0; background: #fff; }
.modal-body .no-prev {
  color: var(--muted);
  text-align: center;
  padding: 40px;
}
.modal-body .no-prev .ext-bubble { margin: 0 auto 14px; }

.modal-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px;
  border-top: 1px solid var(--rule);
  gap: 16px;
  flex-wrap: wrap;
}
.modal-meta { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.modal-actions { display: flex; gap: 8px; }

.btn-ghost, .btn-solid {
  border: 1px solid var(--rule);
  padding: 9px 14px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-ghost:hover { background: var(--ink); color: var(--bg); }
.btn-solid { background: var(--ink); color: var(--bg); }
.btn-solid:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-solid.copied { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---- share page ---- */
.share-body { min-height: 100vh; display: flex; flex-direction: column; }
.share-stage {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 120px 48px;
  display: flex; flex-direction: column;
  gap: 36px;
}
.share-eyebrow {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}
.share-title {
  font-size: clamp(56px, 8vw, 130px);
  line-height: 0.94;
  word-break: break-word;
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 80;
  font-weight: 350;
}
.share-preview {
  border: 1px solid var(--rule);
  background: #0c0c0c;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  min-height: 280px;
  max-height: 70vh;
}
.share-preview img, .share-preview video { max-width: 100%; max-height: 70vh; }
.share-preview iframe { width: 100%; height: 70vh; border: 0; background: #fff; }
.share-noprev { color: var(--muted); text-align: center; padding: 60px 20px; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.ext-bubble {
  font-family: "Fraunces", serif;
  font-weight: 350;
  font-style: italic;
  font-size: 56px;
  letter-spacing: -0.02em;
  background: var(--bg);
  color: var(--ink);
  padding: 18px 28px;
  border: 1px solid var(--rule);
}
.share-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-solid.big { padding: 16px 22px; font-size: 13px; }
.btn-solid.big .muted { color: color-mix(in srgb, var(--bg) 70%, transparent); margin-left: 6px; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .login-stage, .share-stage { padding: 100px 24px 100px; }
  .pw-form { grid-template-columns: 1fr; }
  .pw-label { border-right: 0; border-bottom: 1px solid var(--rule); }
  .app-header { grid-template-columns: 1fr; gap: 14px; padding: 18px 20px; }
  .header-stats { justify-content: flex-start; }
  .stat { align-items: flex-start; }
  .dropzone, .files { margin-left: 16px; margin-right: 16px; }
  .dropzone { padding: 36px 18px; }
  .files-bar { flex-direction: column; align-items: flex-start; gap: 12px; }
  .filter input { width: 100%; }
  .modal { padding: 16px; }
}
