:root {
  --bg: #0c0c0e;
  --panel: #17171a;
  --panel-2: #202024;
  --border: #2c2c31;
  --text: #f4f4f6;
  --text-dim: #a2a2ab;
  --text-faint: #6e6e77;
  --accent: #d09e52;
  --on-accent: #2f2410;
  --danger: #c06a3e;
  --radius: 14px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
#app { min-height: 100vh; max-width: 640px; margin: 0 auto; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px; padding-top: calc(10px + env(safe-area-inset-top));
  padding-left: calc(12px + env(safe-area-inset-left)); padding-right: calc(12px + env(safe-area-inset-right));
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.brand { font-family: Georgia, "Times New Roman", serif; font-size: 19px; letter-spacing: 0.01em; }
.search { flex: 1; min-width: 0; }
.search input, .field input {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  font: inherit; font-size: 16px; outline: none; -webkit-appearance: none; appearance: none;
  transition: border-color 200ms var(--ease);
}
.search input:focus, .field input:focus { border-color: var(--accent); }
input::placeholder { color: var(--text-faint); }
.icon-btn {
  flex: none; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel-2); font-size: 18px; line-height: 1; padding: 0;
}
#view { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }

.pressable { transition: transform 160ms ease-out, background-color 200ms var(--ease), border-color 200ms var(--ease); }
.pressable:active { transform: scale(0.97); }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.state { padding: 28px 16px; color: var(--text-dim); text-align: center; }
.btn {
  display: inline-block; padding: 7px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text);
}
.link-btn { background: none; border: 0; padding: 8px 0 0; color: var(--accent); font-size: 14px; }

.home { padding: 9vh 16px 24px; }
.wordmark { font-family: Georgia, "Times New Roman", serif; font-size: 44px; text-align: center; margin: 0 0 8px; font-weight: 400; }
.hint { text-align: center; color: var(--text-dim); margin: 0 0 32px; }
.section-title { font-size: 13px; color: var(--text-dim); margin: 0 0 12px; font-weight: 500; }

.list { display: flex; flex-direction: column; gap: 16px; padding: 16px 12px 0; }
.card { display: block; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.thumb { position: relative; aspect-ratio: 16 / 9; background: var(--panel-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge {
  position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: 6px; font-size: 12px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
}
.card-body { padding: 10px 12px 12px; }
.card-title {
  font-size: 15px; font-weight: 500; margin: 0 0 4px; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.card-meta { font-size: 13px; color: var(--text-dim); }

.player { width: 100%; aspect-ratio: 16 / 9; background: #000; }
.player iframe { width: 100%; height: 100%; border: 0; display: block; }
.watch-body { padding: 12px 16px 0; padding-left: calc(16px + env(safe-area-inset-left)); padding-right: calc(16px + env(safe-area-inset-right)); }
.vtitle { font-size: 18px; line-height: 1.3; margin: 0 0 6px; font-weight: 600; overflow-wrap: anywhere; }
.vmeta { color: var(--text-dim); margin-bottom: 14px; font-size: 13.5px; }
.dl { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.dl-btn {
  display: flex; align-items: center; justify-content: center; height: 48px; border-radius: 12px;
  font-weight: 600; border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
}
.dl-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.desc {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-dim); font-size: 14px;
}
.desc.clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.setup-link { display: block; margin: 18px 0 0; text-align: center; color: var(--text-faint); background: none; border: 0; width: 100%; padding: 8px; font-size: 13.5px; }

.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0); transition: background-color 200ms var(--ease); }
.scrim.on { background: rgba(0, 0, 0, 0.6); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 85vh; display: flex; flex-direction: column;
  max-width: 640px; margin: 0 auto;
  background: var(--panel); border: 1px solid var(--border); border-bottom: 0; border-radius: 18px 18px 0 0;
  transform: translateY(100%); visibility: hidden;
  transition: transform 200ms var(--ease), opacity 200ms var(--ease), visibility 0s linear 200ms;
}
.sheet.open { transform: translateY(0); visibility: visible; transition-delay: 0s; }
.sheet-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.sheet-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.sheet-head .link-btn { padding: 4px 0; }
.sheet-body { overflow-y: auto; padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 14px; color: var(--text-dim); }
.steps li { padding-left: 4px; }
.cmd { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0; }
.cmd code {
  flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; user-select: all;
}

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 30; transform: translateX(-50%);
  padding: 8px 16px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border);
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 250ms ease;
}
.toast.on { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
