:root {
  --bg0: #F6F5F0; --bg1: #FFFFFF; --bg2: #F3F1EA; --bg3: #EAE6DB;
  --border: #E6E1D6; --border-hi: #D6CFC0;
  --text: #23302B; --text-3: #3C4A44; --muted: #6F7B76; --dim: #8E9894;
  --red: #B11C21; --red-text: #B11C21; --red-18: rgba(177,28,33,.10); --red-40: rgba(177,28,33,.40);
  --amber: #F0860C; --amber-text: #9A5200; --amber-18: rgba(240,134,12,.16); --amber-40: rgba(240,134,12,.55);
  --blue: #4A90B8; --blue-text: #2F6F93; --blue-soft: #8FC1E3; --blue-18: #E4F0F8; --blue-40: rgba(74,144,184,.45);
  --green: #7FA97A; --green-text: #4E7A4A; --green-pale: #DCEBD9;
  --primary-bg: #7FA97A; --primary-fg: #FFFFFF; --primary-hover: #6F9A6A;
  --on-bg: #23302B; --on-fg: #FFFFFF; --scrim: rgba(35,48,43,.38);
  --shadow: 0 10px 28px rgba(35,48,43,.14), 0 1px 2px rgba(35,48,43,.08); --shadow-lg: 0 16px 44px rgba(35,48,43,.2);
  --radius: 12px;
  --font-body: 'Alegreya Sans', 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Oldenburg', Georgia, serif;
  --mono: Consolas, 'Cascadia Mono', 'Courier New', monospace;
  --tap: 48px;
}

html[data-theme]:not([data-theme="amhub"]) {
  --bg0: #000000; --bg1: #111111; --bg2: #1a1a1a; --bg3: #232323;
  --border: #2a2a2a; --border-hi: #444444;
  --text: #ffffff; --text-3: #cccccc; --muted: #8a8a8a; --dim: #666666;
  --red: #C02026; --red-text: #E8666B; --red-18: rgba(192,32,38,.18); --red-40: rgba(192,32,38,.4);
  --amber: #F0860C; --amber-text: #F0860C; --amber-18: rgba(240,134,12,.18); --amber-40: rgba(240,134,12,.4);
  --blue: #70BDE2; --blue-text: #70BDE2; --blue-soft: #70BDE2; --blue-18: rgba(112,189,226,.18); --blue-40: rgba(112,189,226,.4);
  --green: #70BDE2; --green-text: #70BDE2; --green-pale: rgba(112,189,226,.18);
  --primary-bg: #C02026; --primary-fg: #ffffff; --primary-hover: #d3262c;
  --on-bg: #eeeeee; --on-fg: #000000; --scrim: rgba(0,0,0,.62);
  --shadow: 0 6px 24px rgba(0,0,0,.6); --shadow-lg: 0 12px 40px rgba(0,0,0,.7);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
::selection { background: var(--blue-40); color: var(--text); }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg0); color: var(--text); font-family: var(--font-body); font-size: 16px; line-height: 1.4; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
html[dir="rtl"] body { font-size: 17px; }
body.c-docked { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
body.c-sheet-open { overflow: hidden; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
button, input, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; }

#c-top { position: relative; display: flex; align-items: center; gap: 8px; padding: calc(9px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left)); background: var(--bg1); border-bottom: 1px solid var(--border); }
#c-top::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, #8FC1E3, #7FA97A); }
.c-mark { flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: linear-gradient(135deg, #4A90B8, #8FC1E3); color: #fff; font-family: var(--font-display); font-size: 10px; letter-spacing: .3px; }
.c-app { flex: none; font-family: var(--font-display); font-size: 17px; }
.c-film { flex: 1; min-width: 0; color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.c-seg { display: inline-flex; flex: none; border: 1px solid var(--border-hi); border-radius: 24px; overflow: hidden; background: var(--bg1); }
.c-seg button { min-height: var(--tap); min-width: var(--tap); padding: 0 14px; border: 0; background: transparent; color: var(--text-3); font-weight: 700; font-size: 15px; cursor: pointer; }
.c-seg button.on { background: var(--on-bg); color: var(--on-fg); }
.c-seg button:disabled { opacity: .5; cursor: default; }
.c-seg button:focus-visible { outline-offset: -4px; }
.c-seg.wide { display: flex; }
.c-seg.wide button { flex: 1; min-width: 0; padding: 0 6px; }

#c-main { max-width: 960px; margin: 0 auto; padding: 12px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left)); }
.c-card { background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.c-h { font-weight: 700; font-size: 16px; }
.c-lbl { font-size: 14px; font-weight: 700; color: var(--muted); }
.c-hint { margin: 0; color: var(--muted); font-size: 15px; }
.c-hint.small { font-size: 14px; }

.c-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); min-width: var(--tap); padding: 0 14px; border: 1px solid var(--border-hi); border-radius: 10px; background: var(--bg1); color: var(--text); font-weight: 700; font-size: 16px; line-height: 1.15; cursor: pointer; user-select: none; -webkit-user-select: none; }
.c-btn:active { background: var(--bg3); }
.c-btn:disabled { opacity: .45; cursor: default; }
.c-btn svg { display: block; width: 22px; height: 22px; flex: none; }
.c-btn.primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-fg); }
.c-btn.primary:active { background: var(--primary-hover); }
.c-btn.big { width: 100%; min-height: 56px; font-size: 18px; }
.c-btn.small { padding: 0 12px; font-size: 15px; }
.c-btn.ghost { border-color: transparent; background: transparent; }
.c-btn.round { border-radius: 50%; padding: 0; font-size: 26px; font-weight: 400; }
.c-btn.danger { border-color: var(--red-40); color: var(--red-text); }
.c-btn.accent { background: var(--blue-18); border-color: var(--blue-40); color: var(--blue-text); }
.c-btn.ok { background: var(--green-pale); border-color: var(--green); color: var(--green-text); }
.c-btn.bad { background: var(--red-18); border-color: var(--red-40); color: var(--red-text); }

input[type="text"], textarea { display: block; width: 100%; min-width: 0; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--border-hi); border-radius: 10px; background: var(--bg1); color: var(--text); font-size: 17px; }
input[type="text"]:disabled { opacity: .5; }
input::placeholder, textarea::placeholder { color: var(--dim); opacity: 1; }
textarea { min-height: 68px; line-height: 1.35; resize: none; }

.c-screen { display: flex; flex-direction: column; gap: 12px; max-width: 440px; margin: 12px auto 0; padding: 22px 18px 16px; box-shadow: var(--shadow); }
.c-h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 23px; line-height: 1.25; }
html[dir="rtl"] .c-h1 { font-family: var(--font-body); font-weight: 700; font-size: 26px; }
.c-lead { margin: 0; color: var(--text-3); font-size: 17px; }
.c-form { display: flex; flex-direction: column; gap: 10px; margin: 0; }
input.c-code { min-height: 66px; padding: 6px 4px; font-family: var(--mono); font-size: 34px; letter-spacing: .28em; text-indent: .28em; text-align: center; direction: ltr; font-variant-numeric: tabular-nums; }
.c-msg { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--red-18); color: var(--red-text); font-weight: 700; }
.c-msg.info { background: var(--blue-18); color: var(--blue-text); }
.c-foot { margin: 0; text-align: center; }
.c-foot a { display: inline-block; min-width: 96px; min-height: var(--tap); line-height: var(--tap); padding: 0 16px; border-radius: 10px; color: var(--blue-text); font-weight: 700; }

.c-remote, .c-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
@media (min-width: 700px) {
  .c-remote { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}
.c-time { display: flex; flex-direction: column; gap: 10px; }
.c-time-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.c-src { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; font-weight: 700; }
.c-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); }
.c-src.play .c-dot { background: var(--green); animation: c-pulse 1.6s ease-in-out infinite; }
@keyframes c-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .c-src.play .c-dot { animation: none; } }

.c-nowrow { display: flex; gap: 8px; }
.c-now { display: block; flex: 1; width: 100%; min-width: 0; min-height: 62px; padding: 2px 8px; border: 1px solid transparent; border-radius: 10px; background: var(--bg2); color: var(--text); font-family: var(--mono); font-size: 44px; line-height: 1.2; letter-spacing: 1px; font-variant-numeric: tabular-nums; text-align: center; direction: ltr; unicode-bidi: isolate; cursor: pointer; }
.c-now:disabled { opacity: .45; cursor: default; }
input.c-nowedit { min-height: 62px; padding: 2px 8px; border: 2px solid var(--blue); background: var(--bg1); font-size: 44px; cursor: text; }
.c-nowgo { min-height: 62px; }
.c-away { margin: 0; padding: 10px 12px; border: 1px dashed var(--border-hi); border-radius: 10px; background: var(--bg2); color: var(--text-3); font-weight: 700; }

.c-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.c-two .c-btn { padding: 0 8px; }
.c-ltr { direction: ltr; }
.c-gl { display: inline-flex; flex: none; }
.c-vol { display: grid; grid-template-columns: 48px 48px minmax(0, 1fr) 48px 46px; gap: 6px; align-items: center; }
.c-vol .c-btn { padding: 0; font-size: 22px; }
.c-vol input[type="range"] { width: 100%; min-width: 0; height: var(--tap); margin: 0; accent-color: var(--primary-bg); }
.c-vol input[type="range"]:disabled { opacity: .45; }
.c-vol-pct { font-family: var(--mono); font-size: 14px; color: var(--muted); text-align: right; }
.c-prof { display: flex; flex-direction: column; gap: 6px; }

.c-caption { display: flex; align-items: center; min-height: 3.5em; max-height: 3.5em; padding: 6px 10px; border: 1px dashed var(--border-hi); border-radius: 10px; color: var(--text-3); font-style: italic; overflow: hidden; }
.c-caption-txt { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.3; overflow: hidden; width: 100%; }
.c-caption.idle { color: var(--dim); font-style: normal; font-size: 14px; }

.c-nowact { display: flex; flex-direction: column; gap: 10px; border-color: var(--blue-40); }
.c-nowact.idle { border-color: var(--border); }
.c-kicker { color: var(--blue-text); font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.c-nowact.idle .c-kicker { color: var(--muted); }
html[dir="rtl"] .c-kicker { font-size: 15px; letter-spacing: 0; }
.c-nowact-body { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.c-ico { display: inline-flex; flex: none; }
.c-ico svg { display: block; width: 30px; height: 30px; }
.c-na-main { flex: 1; min-width: 0; }
.c-na-label { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-na-sub { color: var(--muted); font-size: 14px; }
.c-na-none { color: var(--muted); }
.c-time-txt { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; }
.c-pill { display: inline-flex; align-items: center; flex: none; min-height: 26px; padding: 0 10px; border-radius: 13px; background: var(--bg3); color: var(--text-3); font-size: 13px; font-weight: 700; white-space: nowrap; }
html[dir="rtl"] .c-pill { font-size: 14px; }
.c-pill.skip, .c-pill.k-false { background: var(--red-18); color: var(--red-text); }
.c-pill.mute, .c-pill.k-note { background: var(--amber-18); color: var(--amber-text); }
.c-pill.cover { background: var(--blue-18); color: var(--blue-text); }
.c-pill.k-ok { background: var(--green-pale); color: var(--green-text); }
.c-note { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }

.c-tiles-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.c-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.c-tile { position: relative; display: flex; min-height: 96px; border: 1px solid var(--border-hi); border-radius: 12px; background: var(--bg2); }
.c-tile-go { display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 6px; flex: 1; min-width: 0; padding: 9px 10px 10px; border: 0; border-radius: 11px; background: transparent; color: var(--text); text-align: start; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.c-tile-go .c-ico { min-height: 30px; }
.c-tile-lbl { font-weight: 700; font-size: 15px; line-height: 1.2; overflow-wrap: anywhere; }
.c-tile-more { position: absolute; top: 0; inset-inline-end: 0; width: var(--tap); height: var(--tap); padding: 0; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; }
.c-tile.pressing { background: var(--bg3); }
.c-tile.flashed { background: var(--green-pale); border-color: var(--green); }
.c-tile-go:disabled, .c-tile-more:disabled { opacity: .45; cursor: default; }

.c-list-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.c-list-head .c-h { flex: 1; min-width: 0; }
.c-count { flex: none; min-width: 28px; padding: 2px 8px; border-radius: 12px; background: var(--bg3); color: var(--text-3); font-size: 14px; font-weight: 700; text-align: center; }
.c-count:empty { display: none; }
.c-list { display: flex; flex-direction: column; gap: 8px; }
.c-flag { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 6px 8px 6px 10px; padding-inline: 10px 8px; min-height: 60px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg2); }
.c-flag-t { color: var(--text-3); font-family: var(--mono); font-size: 14px; direction: ltr; unicode-bidi: isolate; }
.c-flag-body { min-width: 0; }

.c-flag-cat { font-weight: 700; line-height: 1.6; }
.c-flag-cat > * { vertical-align: middle; }
.c-flag-cat .c-ico { display: inline-block; margin-inline-end: 6px; }
.c-flag-cat .c-pill { display: inline-flex; margin-inline-start: 6px; }
.c-flag-cat .c-ico svg { width: 20px; height: 20px; }
.c-flag-meta { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.c-flag-note { color: var(--text-3); font-size: 15px; overflow-wrap: anywhere; }
.c-empty { margin: 0; padding: 14px 4px; color: var(--muted); text-align: center; }
.c-honest { margin-top: 12px; text-align: center; }
.c-me { display: flex; flex-direction: column; gap: 10px; }
.c-me-row { display: flex; align-items: center; gap: 8px; }
.c-me-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.c-sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; background: var(--scrim); }
.c-sheet-box { display: flex; flex-direction: column; width: 100%; max-width: 560px; max-height: 88vh; max-height: 88dvh; padding-bottom: env(safe-area-inset-bottom); border-radius: 16px 16px 0 0; background: var(--bg1); box-shadow: var(--shadow-lg); }
.c-sheet-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 4px 14px; padding-inline: 14px 8px; }
.c-sheet-title { flex: 1; min-width: 0; font-family: var(--font-display); font-size: 20px; }
html[dir="rtl"] .c-sheet-title { font-family: var(--font-body); font-weight: 700; font-size: 22px; }
.c-sheet-body { display: flex; flex-direction: column; gap: 12px; padding: 4px 14px 12px; overflow-y: auto; overscroll-behavior: contain; }
.c-sheet-foot { display: flex; align-items: center; gap: 12px; padding: 10px 14px 12px; border-top: 1px solid var(--border); }
.c-sheet-foot .c-btn.big { flex: 1; width: auto; }
.c-sheet-t { flex: none; color: var(--text-3); font-family: var(--mono); font-size: 17px; direction: ltr; unicode-bidi: isolate; }
.c-field { display: flex; flex-direction: column; gap: 6px; }
.c-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.c-chip { min-height: var(--tap); min-width: var(--tap); padding: 0 14px; border: 1px solid var(--border-hi); border-radius: 24px; background: var(--bg1); color: var(--text); font-weight: 700; font-size: 15px; cursor: pointer; }
html[dir="rtl"] .c-chip { font-size: 16px; }
.c-chip.on { background: var(--on-bg); border-color: var(--on-bg); color: var(--on-fg); }
.c-sev { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.c-sev .c-chip { padding: 0 2px; }

.c-dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: grid; direction: ltr; grid-template-columns: 1fr 1fr 1.5fr 1fr 1fr; gap: 8px; padding: 10px max(12px, env(safe-area-inset-right), calc(50vw - 380px)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left), calc(50vw - 380px)); background: var(--bg1); border-top: 1px solid var(--border-hi); box-shadow: 0 -6px 18px rgba(35,48,43,.10); direction: ltr; }
.c-dock .c-btn { min-height: 56px; padding: 0; font-size: 18px; font-variant-numeric: tabular-nums; }
.c-dock .c-btn svg { width: 28px; height: 28px; }

.c-toast { position: fixed; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 50; display: flex; align-items: center; gap: 10px; max-width: 520px; min-height: 56px; margin: 0 auto; padding: 4px 6px 4px 14px; padding-inline: 14px 6px; border-radius: 12px; background: var(--on-bg); color: var(--on-fg); box-shadow: var(--shadow); font-weight: 700; }
body.c-docked .c-toast { bottom: calc(88px + env(safe-area-inset-bottom)); }
body.c-sheet-open .c-toast { top: calc(12px + env(safe-area-inset-top)); bottom: auto; }
.c-toast.err { background: var(--red); color: #fff; }
.c-toast.off { opacity: 0; pointer-events: none; }
.c-toast > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.c-toast .c-btn { flex: none; border-color: currentColor; background: transparent; color: inherit; }

@media (max-height: 480px) {
  .c-dock { padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .c-dock .c-btn { min-height: var(--tap); }
  body.c-docked { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  body.c-docked .c-toast { bottom: calc(68px + env(safe-area-inset-bottom)); }
  .c-screen { margin-top: 0; padding-top: 14px; gap: 8px; }
  .c-sheet-box { max-height: 96vh; max-height: 96dvh; }
  .c-sheet-foot { padding-top: 6px; padding-bottom: 8px; }
}
