/* Chicchai-Kitsu: dark, review-friendly, thumb-sized. */

:root {
  --bg: #16171b;
  --surface: #1f2026;
  --surface-2: #2a2b33;
  --border: #34353e;
  --text: #ececf1;
  --muted: #9a9cab;
  --accent: #00b242;
  --accent-text: #fff;
  --danger: #ff5c6c;
  --warn: #f5a623;
  --radius: 12px;
  --tap: 44px;
  --topbar: 52px;
  --tabbar: 58px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); }
svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; }

/* Inputs: 16px stops iOS from zooming on focus. */
input, select, textarea {
  font-size: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  min-height: var(--tap);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: var(--tap); }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); margin: 0; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 18px;
  background: var(--accent); color: var(--accent-text);
  border: 0; border-radius: 10px; font-weight: 600; text-decoration: none;
  cursor: pointer;
}
.button.small { min-height: 38px; padding: 0 14px; font-size: 14px; }
.button.small svg { width: 18px; height: 18px; }
.button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.button.block { width: 100%; }
.button:disabled { opacity: .5; }

.icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); flex: none;
  background: none; border: 0; border-radius: 50%; color: var(--text); cursor: pointer;
  text-decoration: none; font-size: 22px;
}
.icon-button:active { background: var(--surface-2); }
.icon-button:disabled { opacity: .35; }
.icon-button.small { width: 34px; height: 34px; font-size: 18px; }

.chip-button {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 34px; padding: 0 12px; flex: none;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 17px;
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip-button.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip-button small { opacity: .7; font-weight: 400; }

.link-button {
  background: none; border: 0; color: var(--muted); padding: 8px 4px; min-height: 36px;
  font-size: 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 4px;
}
.link-button.active { color: var(--accent); }

.spacer { flex: 1; }
.hint { color: var(--muted); font-size: 13px; }
.error-text { color: var(--danger); font-size: 14px; margin: 6px 0 0; }
.pre { white-space: pre-wrap; }

.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.boot, .empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 48px 24px; text-align: center; color: var(--muted);
}
.boot { min-height: 100vh; min-height: 100dvh; }
.empty.small { padding: 24px; }

/* Avatars and pills */

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 700;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.small { width: 26px; height: 26px; font-size: 11px; }
.avatar.large { width: 56px; height: 56px; font-size: 20px; }
img.avatar { object-fit: cover; }

.status-pill {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; flex: none;
  border-radius: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
}
.type-tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border: 1.5px solid; border-radius: 6px; font-size: 12px; font-weight: 600;
}
.due { font-size: 12px; color: var(--muted); }
.due.soon { color: var(--warn); }
.due.late { color: var(--danger); font-weight: 600; }

/* Login */

.login {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
}
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.login-card .link-button { align-self: center; }
.server-hint { text-align: center; margin: -6px 0 0; overflow-wrap: anywhere; }
.brand { text-align: center; margin-bottom: 8px; }
.brand img { margin: 0 auto 8px; border-radius: 12px; }
.brand h1 { margin: 0; font-size: 24px; }
.brand p { margin: 4px 0 0; color: var(--muted); }
.factor-switch { display: flex; flex-direction: column; align-items: center; }

/* Shell */

.shell { min-height: 100vh; min-height: 100dvh; }
.content { padding-bottom: calc(var(--tabbar) + var(--safe-bottom)); }
.shell.is-task .content { padding-bottom: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 4px;
  min-height: calc(var(--topbar) + var(--safe-top));
  padding: var(--safe-top) calc(8px + var(--safe-right)) 0 calc(8px + var(--safe-left));
  background: rgba(22, 23, 27, .94);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 20px; margin: 0 0 0 8px; }
.topbar .count { color: var(--muted); font-size: 14px; margin-left: 4px; }
.topbar-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.topbar-title strong, .topbar-title small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title small { color: var(--muted); font-size: 12px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; height: calc(var(--tabbar) + var(--safe-bottom));
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: rgba(22, 23, 27, .96);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600;
}
.tabbar a.active { color: var(--accent); }

/* Task list */

.filters {
  padding: 10px calc(16px + var(--safe-right)) 4px calc(16px + var(--safe-left));
  display: flex; flex-direction: column; gap: 8px;
}
.filter-row { display: flex; gap: 8px; }
.filter-row select { flex: 1; min-width: 0; }
.chip-row {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 2px 16px 6px;
}
.chip-row::-webkit-scrollbar { display: none; }
.status-chip { border-width: 1.5px; }

.task-list {
  list-style: none; margin: 0;
  padding: 4px calc(12px + var(--safe-right)) 16px calc(12px + var(--safe-left));
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.task-card {
  display: flex; gap: 12px; padding: 10px;
  background: var(--surface); border-radius: var(--radius);
  color: inherit; text-decoration: none; min-height: 88px;
}
.task-card:active { background: var(--surface-2); }
.thumb {
  width: 96px; height: 64px; flex: none; border-radius: 8px; overflow: hidden;
  background: var(--surface-2);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.task-card-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.task-card-title strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.task-card-project { color: var(--muted); font-size: 12px; }
.task-card-comment {
  margin: 0; color: var(--muted); font-size: 13px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.task-card-comment b { color: var(--text); font-weight: 600; }

@media (max-width: 380px) {
  .task-list { grid-template-columns: 1fr; }
  .thumb { width: 72px; height: 48px; }
}

/* Task view */

.task-layout { display: flex; flex-direction: column; }
.review-pane { background: #000; }
.thread-pane { padding: 0 calc(16px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(16px + var(--safe-left)); }

.no-preview {
  height: 120px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); background: var(--bg); border-bottom: 1px solid var(--border);
}

.task-summary { display: flex; align-items: center; gap: 8px; padding: 12px 0 8px; flex-wrap: wrap; }
.assignees { display: flex; gap: 2px; }
.details {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 12px;
  padding: 12px; background: var(--surface); border-radius: var(--radius); font-size: 14px;
}
.details dt { color: var(--muted); }
.details dd { margin: 0; }

.revision-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px calc(12px + var(--safe-right)) 8px calc(12px + var(--safe-left));
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.revision-scroll { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.revision-scroll::-webkit-scrollbar { display: none; }
.pages { display: flex; align-items: center; gap: 2px; font-size: 13px; color: var(--muted); }

/* Player */

.player { display: flex; flex-direction: column; background: #000; }
.stage {
  position: relative; width: 100%; overflow: hidden; background: #000;
  height: min(56.25vw, 52vh); min-height: 180px;
}
.media, .overlay { position: absolute; }
.media { object-fit: contain; background: #000; }
.overlay { touch-action: auto; }
.player.drawing .overlay { touch-action: none; cursor: crosshair; }
.player.drawing .stage { box-shadow: inset 0 0 0 2px var(--accent); }

.big-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 64px; height: 64px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .55); color: #fff; display: flex; align-items: center; justify-content: center;
  pointer-events: auto; cursor: pointer;
}
.big-play svg { width: 34px; height: 34px; }

.stage-message {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px;
  align-items: center; justify-content: center; text-align: center; padding: 16px; color: var(--muted);
  background: rgba(0, 0, 0, .7);
}

.toolbar {
  background: var(--surface);
  padding: 6px calc(8px + var(--safe-right)) 6px calc(8px + var(--safe-left));
  display: flex; flex-direction: column; gap: 4px;
}
.control-row { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.control-row .icon-button { width: 40px; height: 40px; }
.icon-button.on { color: var(--accent); }
.frame-readout { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 4px; display: flex; flex-direction: column; line-height: 1.15; }
.frame-readout strong { color: var(--text); font-size: 15px; }
.frame-readout small { font-size: 11px; }

.scrub { position: relative; padding: 0 6px; }
.scrub input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 32px; min-height: 0;
  background: transparent; border: 0; padding: 0; margin: 0;
}
.scrub input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: var(--border); border-radius: 2px; }
.scrub input[type="range"]::-moz-range-track { height: 4px; background: var(--border); border-radius: 2px; }
.scrub input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px;
  border-radius: 50%; background: var(--accent); border: 0;
}
.scrub input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); border: 0; }
.markers { position: absolute; left: 16px; right: 16px; top: 22px; height: 6px; pointer-events: none; }
.marker { position: absolute; width: 4px; height: 6px; margin-left: -2px; background: var(--warn); border-radius: 1px; }
.marker-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.marker-dot.on { background: var(--warn); }

.draw-tools { gap: 8px; padding-top: 10px; padding-bottom: 10px; }
.draw-tools > div { display: flex; align-items: center; gap: 8px; }
.swatches { gap: 10px !important; }
.swatch {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; padding: 0;
}
.swatch.active { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--text); }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.segmented button { min-width: 44px; min-height: 36px; border: 0; background: none; font-weight: 600; cursor: pointer; }
.segmented button.active { background: var(--text); color: var(--bg); }
.draw-actions { justify-content: flex-end; }
.tool-row { gap: 2px !important; }
.tool-row .icon-button { width: 42px; height: 42px; border-radius: 10px; }
.icon-button.tool.on { background: var(--text); color: var(--bg); }
.icon-button.tool.on svg { fill: var(--bg); }
.icon-button svg.outline { fill: none !important; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:disabled { opacity: 0.35; }
.style-row { justify-content: space-between; flex-wrap: wrap; }
.eraser-row { min-height: 36px; }
.button.danger { color: var(--danger); border-color: var(--danger); }
.stage-spinner { position: absolute; left: 50%; top: 50%; margin: -14px 0 0 -14px; pointer-events: none; }

/* Expanded player: the preview takes the whole screen. */
.task-view.expanded .topbar { display: none; }
.task-view.expanded .review-pane {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}
.task-view.expanded .player { flex: 1; min-height: 0; }
.task-view.expanded .stage { flex: 1; height: auto; min-height: 0; }

/* Composer */

.composer {
  background: var(--surface); border-radius: var(--radius); padding: 10px;
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px;
}
.composer-status { display: flex; align-items: center; gap: 8px; }
.status-select { position: relative; display: inline-flex; align-items: center; gap: 2px; min-height: 36px; }
.status-select select { position: absolute; inset: 0; opacity: 0; min-height: 0; cursor: pointer; }
.status-select .status-pill { height: 28px; font-size: 13px; }
.status-select svg { color: var(--muted); }
.composer-actions { display: flex; align-items: center; gap: 4px; }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.file-list li { display: flex; align-items: center; gap: 8px; font-size: 14px; background: var(--surface-2); border-radius: 8px; padding: 2px 4px 2px 10px; }
.file-list li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list small { color: var(--accent); }
.toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; min-height: 36px; }
.checklist.editing li { display: flex; gap: 4px; align-items: center; }
.checklist.editing input { min-height: 38px; padding: 6px 10px; }

/* Comments */

.comments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.comment { background: var(--surface); border-radius: var(--radius); padding: 12px; }
.comment.pinned { box-shadow: inset 3px 0 0 var(--warn); }
.comment-head { display: flex; align-items: center; gap: 8px; }
.comment-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.comment-meta strong { font-size: 14px; }
.comment-meta small { color: var(--muted); font-size: 12px; }
.comment-text { margin-top: 8px; overflow-wrap: anywhere; }
.comment-text .mention { color: var(--accent); font-weight: 600; }
.checklist { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.checklist label { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.checklist .done { text-decoration: line-through; color: var(--muted); }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.attachment { color: var(--text); font-size: 14px; text-decoration: none; }
.attachment img { max-width: 140px; max-height: 100px; border-radius: 8px; object-fit: cover; }
.comment-actions { display: flex; gap: 12px; margin-top: 4px; }
.replies { list-style: none; margin: 6px 0 0; padding: 0 0 0 12px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.replies strong { font-size: 13px; }
.replies small { color: var(--muted); font-size: 12px; margin-left: 6px; }
.replies .comment-text { margin-top: 2px; font-size: 14px; }
.reply-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }

/* Settings */

.settings { padding-bottom: 24px; }
.profile { display: flex; gap: 14px; align-items: center; padding: 20px 16px; }
.profile div { display: flex; flex-direction: column; }
.profile small { color: var(--muted); }
.settings-row {
  display: flex; align-items: center; justify-content: space-between; width: calc(100% - 32px);
  margin: 0 16px 8px; min-height: 52px; padding: 0 16px;
  background: var(--surface); border: 0; border-radius: var(--radius);
  color: var(--text); text-decoration: none; font-size: 16px; text-align: left; cursor: pointer;
}
.settings-row.danger { color: var(--danger); }
.settings-row.static { cursor: default; gap: 12px; }
.settings-row.static small { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; text-align: right; }
.about { padding: 8px 16px; }

/* Segmented switches used as page tabs */

.segmented.wide { display: flex; width: 100%; }
.segmented.wide > * { flex: 1; }
.segmented a {
  display: flex; align-items: center; justify-content: center; min-height: 36px;
  color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px;
}
.segmented a.active { background: var(--text); color: var(--bg); }

/* Projects and production lists */

.production-list { list-style: none; margin: 12px 16px; padding: 0; display: grid; gap: 10px; }
@media (min-width: 700px) { .production-list { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); } }
.production-card { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.production-main { display: flex; align-items: center; gap: 12px; padding: 12px 12px 8px; color: inherit; text-decoration: none; }
.production-main > svg { width: 22px; height: 22px; fill: var(--muted); flex: none; }
.production-avatar {
  width: 44px; height: 44px; border-radius: 10px; flex: none; overflow: hidden;
  display: grid; place-items: center; font-weight: 700; color: #fff;
}
.production-avatar img { width: 100%; height: 100%; object-fit: cover; }
.production-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.production-name strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.production-name small { color: var(--muted); }
.production-links { display: flex; border-top: 1px solid var(--border); }
.production-links a {
  flex: 1; min-height: 44px; display: grid; place-items: center;
  color: var(--text); text-decoration: none; font-size: 14px;
}
.production-links a + a { border-left: 1px solid var(--border); }
.project-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left: 0 !important; }

.entity-list {
  list-style: none; margin: 0;
  padding: 4px calc(12px + var(--safe-right)) 16px calc(12px + var(--safe-left));
  display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}
.entity-row { display: flex; gap: 12px; padding: 10px; background: var(--surface); border-radius: var(--radius); }
.entity-row .thumb { width: 80px; height: 54px; }
.entity-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.entity-name { display: flex; flex-direction: column; line-height: 1.2; }
.entity-name small { color: var(--muted); font-size: 12px; }
.entity-tasks { display: flex; flex-wrap: wrap; gap: 6px; }
.task-chip {
  display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 9px;
  border-radius: 7px; font-size: 12px; font-weight: 700; text-decoration: none; text-transform: uppercase;
}
.task-chip-type { font-weight: 500; opacity: .85; text-transform: none; }
.task-chip-people { font-weight: 500; text-transform: none; }
@media (max-width: 380px) { .entity-list { grid-template-columns: 1fr; } }

/* Playlist player */

.playlist-nav {
  display: flex; align-items: center; gap: 2px; background: var(--bg);
  padding: 6px calc(4px + var(--safe-right)) 6px calc(4px + var(--safe-left));
  border-bottom: 1px solid var(--border);
}
.playlist-strip {
  list-style: none; margin: 0; padding: 0; flex: 1; min-width: 0;
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
}
.playlist-strip::-webkit-scrollbar { display: none; }
.playlist-strip li { flex: none; scroll-snap-align: center; }
.playlist-strip button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; width: 76px;
  padding: 3px; background: none; border: 2px solid transparent; border-radius: 8px; cursor: pointer;
}
.playlist-strip li.active button { border-color: var(--accent); }
.playlist-strip img { width: 66px; height: 38px; object-fit: cover; border-radius: 4px; background: var(--surface-2); }
.playlist-strip span { font-size: 11px; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.playlist-strip li.active span { color: var(--text); }
.panel-title { display: flex; align-items: center; gap: 8px; padding-top: 12px; flex-wrap: wrap; }
.thread-pane > .link-button { margin: 8px 0; }
.load-more { grid-column: 1 / -1; list-style: none; }

/* Revision comparison */

.compare-select {
  position: relative; display: inline-flex; align-items: center; gap: 4px; flex: none;
  color: var(--muted); font-size: 13px; font-weight: 600;
}
.compare-select.active { color: var(--accent); }
.compare-select select { min-height: 34px; padding: 4px 8px; width: auto; font-size: 14px; }
.media.hidden { visibility: hidden; }
.ab-badge {
  position: absolute; top: 8px; right: 8px; z-index: 2; min-height: 30px; padding: 0 10px;
  border: 0; border-radius: 15px; background: rgba(0, 0, 0, .65); color: #fff; font-weight: 700; cursor: pointer;
}

/* Landscape phones and anything wide: preview left, thread right,
   each scrolling on its own. */
@media (orientation: landscape) and (max-height: 600px), (min-width: 900px) {
  .task-view { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
  .task-layout { flex: 1; min-height: 0; flex-direction: row; }
  .review-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .review-pane .player { flex: 1; min-height: 0; }
  .review-pane .stage { flex: 1; height: auto; min-height: 0; }
  .review-pane .no-preview { flex: 1; height: auto; }
  .entity-list { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .thread-pane {
    width: min(42%, 420px); flex: none; overflow-y: auto; overscroll-behavior: contain;
    border-left: 1px solid var(--border);
    padding-left: 12px;
  }
}

/* Landscape phones: every pixel of height counts. */
@media (orientation: landscape) and (max-height: 600px) {
  :root { --topbar: 44px; --tabbar: 50px; }
  .toolbar { padding-top: 2px; padding-bottom: 2px; }
  .scrub input[type="range"] { height: 26px; }
  .markers { top: 19px; }
  .revision-bar { padding-top: 4px; padding-bottom: 4px; }
  .draw-tools { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding-top: 4px; padding-bottom: 4px; }
  .draw-tools .tool-row .spacer, .draw-tools .eraser-row .hint { display: none; }
  .tool-row .icon-button { width: 36px; height: 36px; }
  .swatches { gap: 6px !important; }
  .swatch { width: 26px; height: 26px; }
  .draw-tools .segmented button { min-height: 30px; min-width: 34px; }
  .draw-actions { margin-left: auto; }
  /* Player controls fold into one row under the scrub bar. */
  .controls { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0 2px; }
  .controls .scrub { flex-basis: 100%; }
  .controls .control-row { flex-wrap: nowrap; gap: 2px; }
  .controls .control-row:last-child { flex: 1; }
  .controls .icon-button { width: 36px; height: 36px; }
  .controls .chip-button { min-height: 30px; padding: 0 9px; }
  .controls .frame-readout small { display: none; }
  .controls .draw-label, .controls .download { display: none; }
  .controls .button.small { min-height: 32px; padding: 0 10px; }
  /* Playlist strip: names only. */
  .playlist-nav { padding-top: 2px; padding-bottom: 2px; }
  .playlist-nav .icon-button { width: 36px; height: 36px; }
  .playlist-strip img { display: none; }
  .playlist-strip button { width: auto; padding: 4px 8px; }
  .playlist-strip span { max-width: 110px; font-size: 12px; }
  .tabbar a { flex-direction: row; gap: 6px; font-size: 12px; }
  .filters { flex-direction: row; flex-wrap: wrap; padding-top: 6px; }
  .filters .search { flex: 1 1 200px; width: auto; }
  .filter-row { flex: 1 1 280px; }
  .chip-row { flex-basis: 100%; }
}

/* Bottom sheets (new playlist, add shots, share) */

body.sheet-open { overflow: hidden; }
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 560px; max-height: calc(100dvh - var(--safe-top) - 24px);
  background: var(--bg); border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column;
  padding-left: var(--safe-left); padding-right: var(--safe-right);
}
@media (min-width: 700px) and (min-height: 500px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 16px; max-height: 85dvh; }
}
.sheet-header { display: flex; align-items: center; padding: 6px 6px 0 16px; }
.sheet-header h2 { flex: 1; margin: 0; font-size: 18px; }
.sheet-body { overflow-y: auto; padding: 8px 16px 16px; flex: 1; overscroll-behavior: contain; }
.sheet-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 10px 16px calc(10px + var(--safe-bottom)); border-top: 1px solid var(--border);
}
.sheet-footer .button { flex: 1; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label:not(.toggle) { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.form h3 { margin: 8px 0 0; font-size: 15px; }
.sheet-filters { display: flex; flex-direction: column; gap: 8px; position: sticky; top: -8px; background: var(--bg); padding: 8px 0; z-index: 1; }
.sheet-filters .filter-row .button { flex: none; }
.pick-list { list-style: none; margin: 0; padding: 0; }
.pick-list label { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 4px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.pick-list label.disabled { opacity: 0.55; cursor: default; }
.thumb.small { width: 64px; height: 40px; border-radius: 6px; }
.pick-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pick-name small { color: var(--muted); font-size: 12px; }
.share-links { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 10px; }
.share-link { background: var(--surface); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.share-link input { font-size: 14px; }
.share-tags { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); }
.share-tags span { border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }
.share-actions { display: flex; gap: 8px; align-items: center; }
.share-form { margin-top: 12px; }

.search-row { display: flex; gap: 8px; align-items: center; }
.search-row .search { flex: 1; min-width: 0; }
.search-row .button { flex: none; }
.entry-links { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px 16px 16px; }
.link-button.danger { color: var(--danger); }
.chip-button.play-all { flex: none; }

.episode-select { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.episode-select select { flex: 1; min-width: 0; color: var(--text); font-weight: 600; }
