/* ==========================================================================
   Buildlog: desktop-first, still usable on a phone.
   Fonts and colors follow the light theme of khudoyshukur.com.
   ========================================================================== */

/* Self-hosted variable fonts (Google Fonts builds, SIL Open Font License),
   so pages load nothing from third parties. */
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(/fonts/geist-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(/fonts/geist-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/fonts/newsreader-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/fonts/newsreader-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --text: #1a1a1a;
  --text-body: #3b3f45;
  --muted: #6b7078;
  --faint: #a3a7ad;
  --border: #e7e7e4;
  --border-strong: #d4d4d0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff4ff;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fdeeee;
  --danger-text: #ffffff;
  --warn-bg: #fff8e6;
  --warn-text: #8a4b08;
  --shadow-lg: 0 12px 40px rgb(0 0 0 / 0.12);
  --radius: 8px;
  --radius-lg: 10px;
  --tap: 38px;
  --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font-sans);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 450;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
}

[hidden] { display: none !important; }

.icon { width: 18px; height: 18px; flex: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Smooth cross-fade between pages (View Transitions API, ignored by older browsers). */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.16s; }

/* ---------- Layout ---------- */
.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 32px;
}
.narrow { max-width: 680px; }
body.watch .wrap { max-width: 1120px; }
main.wrap { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
}

/* ---------- Header ---------- */
.topbar { padding-top: env(safe-area-inset-top); }
.topbar .wrap {
  display: flex;
  align-items: center;
  gap: 22px;
  height: 76px;
}
.brand {
  margin-right: auto;
  color: var(--text);
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 21px;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
}
.nav-link .icon { width: 16px; height: 16px; }
.nav-link:hover { color: var(--text); }
.nav-link-accent { color: var(--accent); }
.nav-link-accent:hover { color: var(--accent-hover); }

@media (max-width: 600px) {
  .topbar .wrap { height: 64px; gap: 18px; }
  .nav-link .label-desktop { display: none; }
}

/* ---------- Page heading ---------- */
.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 24px 0 8px;
}
.page-head h1 { margin: 0; font-size: 38px; }
.page-head .summary { margin: 0; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}
.crumb .icon { width: 16px; height: 16px; }
.crumb:hover { color: var(--text); }

@media (max-width: 600px) {
  .page-head h1 { font-size: 30px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn .icon { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger-soft); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: var(--danger-text); }
.btn-danger-solid:hover { background: color-mix(in srgb, var(--danger) 88%, black); }
.btn-block { width: 100%; }
.btn-lg { min-height: 44px; font-size: 15px; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 500; font-size: 14px; margin: 20px 0 6px; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
::placeholder { color: var(--faint); }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.btn:focus-visible, a:focus-visible, .nav-link:focus-visible, .dropzone:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (max-width: 600px) {
  input[type="text"], input[type="password"], textarea { font-size: 16px; } /* no iOS zoom */
}

.actions { display: flex; gap: 8px; margin-top: 24px; flex-wrap: wrap; }
.actions-end { justify-content: flex-end; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.card-pad { padding: 24px; }
@media (max-width: 600px) { .card-pad { padding: 16px; } }

/* ---------- Notices ---------- */
.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 16px 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
}
.notice-warn { background: var(--warn-bg); color: var(--warn-text); }
.notice-error { background: var(--danger-soft); color: var(--danger); }

/* ---------- Session list ---------- */
.group { margin-top: 28px; }
.group-title {
  margin: 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
}
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { border-bottom: 1px solid var(--border); }
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px 72px;
  align-items: baseline;
  gap: 20px;
  padding: 13px 0;
  color: var(--text);
  text-decoration: none;
}
a.row:hover .row-title { color: var(--accent); }
a.row:focus-visible { outline-offset: 0; border-radius: 4px; }
.row-main { min-width: 0; }
.row-title {
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.12s;
}
.row-desc {
  margin-top: 1px;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-dur, .row-time {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.row-dur { font-family: var(--font-mono); color: var(--text-body); }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-body);
  font: 12px/1.6 var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .row { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
  .row-time { display: none; }
  .row-title { font-size: 17px; }
}

/* Skeleton placeholders while the list loads */
.skel {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
.skel-title { width: 45%; height: 15px; margin: 4px 0; }
.skel-sub { width: 25%; margin-top: 8px; }
.skel-short { width: 48px; justify-self: end; }
.skel-group { width: 72px; height: 10px; margin: 32px 0 12px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 72px 24px;
}
.empty-icon {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
}
.empty-icon .icon { width: 24px; height: 24px; }
.empty h2 { margin: 0 0 6px; font-size: 26px; }
.empty p { margin: 0 0 22px; }

/* ---------- Upload ---------- */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 220px;
  margin: 24px 0 0;
  padding: 24px;
  border: 2px dashed var(--faint);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  font-weight: 400;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; inset: 0; width: 1px; height: 1px; opacity: 0; }
.dropzone-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.dropzone.is-over .dropzone-icon { background: var(--accent); color: var(--accent-text); }
.dropzone-icon .icon { width: 22px; height: 22px; }
.dropzone strong { font-family: var(--font-serif); font-size: 21px; font-weight: 450; letter-spacing: -0.01em; }
.dropzone .hint { font-size: 14px; }

.file-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 24px;
  padding: 14px 16px;
}
.file-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}
.file-card .row-main { flex: 1; }
.file-card .row-title { font-size: 18px; }
.file-meta { color: var(--muted); font-size: 13px; }

#progress-view { margin-top: 24px; }
.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 20px 0 10px;
}
.progress > div {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.25s linear;
}
.progress-stats {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.progress-pct { font-weight: 600; color: var(--text); font-size: 15px; }
.progress-title { font-size: 24px; margin: 0; overflow-wrap: anywhere; }

/* ---------- Player ---------- */
.player {
  margin-top: 16px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
}
.player video {
  display: block;
  width: 100%;
  max-height: 76vh;
  aspect-ratio: 16 / 9;
  background: #000;
}
.player-skel { aspect-ratio: 16 / 9; max-height: 76vh; width: 100%; border-radius: var(--radius-lg); margin-top: 16px; }

.session-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 24px;
  margin-top: 24px;
}
.session-head h1 { font-size: 32px; margin: 0 0 8px; overflow-wrap: anywhere; }
.session-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--muted); font-size: 14px; }
.session-actions { display: flex; gap: 8px; flex: none; }
.description {
  max-width: 72ch;
  margin: 24px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-body);
  font-size: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.edit-card { margin-top: 24px; }
.edit-card label:first-child { margin-top: 0; }

@media (max-width: 600px) {
  .player { margin: 12px -16px 0; border-radius: 0; }
  .session-head { flex-direction: column; }
  .session-head h1 { font-size: 26px; }
}

/* Phone in landscape: let the video take the whole screen height. */
@media (orientation: landscape) and (max-height: 500px) {
  body.watch .player { margin: 0 -24px; border-radius: 0; }
  body.watch .player video { height: 100dvh; max-height: 100dvh; aspect-ratio: auto; }
}

/* ---------- Dialog ---------- */
dialog.modal {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgb(15 17 21 / 0.35); }
dialog.modal[open] { animation: pop 0.14s ease-out; }
.modal-body { padding: 22px 22px 0; }
.modal-body h2 { margin: 0 0 8px; font-size: 22px; }
.modal-body p { margin: 0; color: var(--text-body); overflow-wrap: anywhere; }
.modal .actions { padding: 0 22px 20px; margin-top: 22px; justify-content: flex-end; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 9px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.18s ease-out;
}
.toast.is-error { background: var(--danger); color: var(--danger-text); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Login ---------- */
.login {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand h1 { margin: 0 0 6px; font-size: 40px; }
.login-brand p { margin: 0; color: var(--muted); font-size: 15px; }
.login form { width: 100%; max-width: 360px; }
.login form label:first-child { margin-top: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

.skel-watch-title { width: 40%; height: 24px; margin-top: 26px; }
.skel-watch-meta { width: 24%; margin-top: 12px; }
.actions .hint { margin-right: auto; align-self: center; }
@media (max-width: 600px) { #edit-hint { display: none; } }
