:root {
  --bg: #e9ecf1;
  --card: #ffffff;
  --surface-sub: #f2f4f8;
  --text: #0a0c10;
  --muted: #626b7a;
  --line: #d4dae3;
  --border: rgba(10, 12, 16, 0.11);
  --accent: #102a54;
  --accent-strong: #0a1c3a;
  --accent-soft: rgba(16, 42, 84, 0.09);
  --accent-ink: #ffffff;
  --silver: #c8d0dc;
  --dark: #0a0c10;
  --green: #15803d;
  --green-bg: #e3f6ec;
  --red: #dc2626;
  --red-bg: #feeaea;
  --amber: #b45309;
  --amber-bg: #fef3dc;
  --blue: #1d4ed8;
  --blue-bg: #e4ecff;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(10, 12, 16, 0.05), 0 6px 18px rgba(10, 12, 16, 0.06);
  --shadow-hover: 0 4px 12px rgba(10, 12, 16, 0.09), 0 10px 24px rgba(16, 42, 84, 0.14);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #08090c; --card: #16181f; --surface-sub: #0f1117;
    --text: #ffffff; --muted: #9da6b5; --line: #282c38;
    --border: rgba(215, 222, 235, 0.16);
    --accent: #1c4485; --accent-strong: #e2e8f0; --accent-soft: rgba(203, 213, 225, 0.12);
    --silver: #aeb8c7; --dark: #ffffff;
    --green: #34d399; --green-bg: #0f2e22; --red: #f87171; --red-bg: #361519;
    --amber: #fbbf24; --amber-bg: #33250e; --blue: #60a5fa; --blue-bg: #132544;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.65);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
#app { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); animation: viewIn .18s ease-out; }
@keyframes viewIn { from { opacity: 0.7; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.splash { min-height: 80vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }
.logo { width: 64px; height: 64px; border-radius: 18px; background: linear-gradient(145deg, #17345e, #091426); color: #e2e8f0;
  border: 1.5px solid rgba(203, 213, 225, .35);
  display: grid; place-items: center; font: 700 32px/1 Georgia, serif; box-shadow: 0 8px 24px rgba(9, 19, 38, .25); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

h1 { font-size: 24px; margin: 4px 0 2px; letter-spacing: -.3px; }
h2 { font-size: 18px; margin: 22px 4px 10px; }
h3 { font-size: 16px; margin: 0; }

.header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(145deg, #17345e, #0a1629); color: #e2e8f0;
  display: grid; place-items: center; font-weight: 700; flex: none; overflow: hidden; border: 2px solid var(--silver); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.sm { width: 38px; height: 38px; font-size: 14px; }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; border-width: 1px; }
.avatar.lg { width: 80px; height: 80px; font-size: 26px; }

.avatar-editor { display: flex; align-items: center; gap: 14px; padding: 12px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; }
.avatar-editor .btns { flex: 1; flex-wrap: wrap; }

.participants-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px;
  background: rgba(255, 255, 255, .12); font-size: 13px; font-weight: 600; }
.chip.light { background: var(--bg); color: var(--text); border: 1px solid var(--border); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 10px; }
.card.tap { cursor: pointer; transition: transform .16s cubic-bezier(.22, 1, .36, 1), box-shadow .16s ease, border-color .16s ease, background-color .16s ease; }
@media (hover: hover) {
  .card.tap:hover { transform: translateY(-1px); box-shadow: var(--shadow-hover); border-color: var(--accent-soft); }
}
.card.tap:active, .card.tap.is-pressed { transform: scale(.975); box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }

.list { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list .item { padding: 14px 16px; display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--line); }
.list .item:first-child { border-top: 0; }
.list .item.tap { cursor: pointer; transition: background-color .14s ease, transform .14s cubic-bezier(.22, 1, .36, 1); }
@media (hover: hover) {
  .list .item.tap:hover { background: var(--accent-soft); }
}
.list .item.tap:active, .list .item.tap.is-pressed { background: var(--accent-soft); transform: scale(.985); }
.chev::after { content: "›"; color: var(--muted); font-size: 22px; line-height: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px;
  padding: 13px 18px; font-weight: 600; cursor: pointer; background: var(--line); width: 100%;
  transition: transform .14s cubic-bezier(.22, 1, .36, 1), filter .14s ease, opacity .14s ease, box-shadow .14s ease; }
.btn:disabled { opacity: .45; cursor: default; transform: none !important; }
.btn:not(:disabled):active, .btn:not(:disabled).is-pressed { transform: scale(.965); filter: brightness(.95); }
.btn.primary { background: linear-gradient(135deg, #183a70 0%, #0e2449 100%); color: var(--accent-ink);
  border: 1px solid rgba(226, 232, 240, .28); box-shadow: 0 4px 14px rgba(10, 28, 58, .28); }
@media (hover: hover) {
  .btn.primary:not(:disabled):hover { filter: brightness(1.04); }
}
.btn.dark { background: var(--dark); color: var(--bg); }
.btn.danger { background: var(--red-bg); color: var(--red); }
.btn.ghost { background: transparent; color: var(--accent); padding: 8px 10px; width: auto; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; width: auto; }
.btn.huge { padding: 20px; font-size: 18px; border-radius: 20px; }
.btns { display: flex; gap: 10px; }
.btns > * { flex: 1; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.p1 { background: var(--red-bg); color: var(--red); }
.badge.p2 { background: var(--amber-bg); color: var(--amber); }
.badge.p3 { background: var(--blue-bg); color: var(--blue); }
.badge.ok { background: var(--green-bg); color: var(--green); }
.badge.live { background: var(--blue-bg); color: var(--blue); }
.badge.gray { background: var(--line); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.live .dot { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.shift { background: linear-gradient(145deg, #132d58 0%, #0a1934 100%); color: #f8fafc; border-radius: 22px; padding: 20px;
  border: 1px solid rgba(226, 232, 240, .32); box-shadow: 0 12px 30px rgba(8, 9, 12, .28); }
.shift .label { color: #cbd5e1; opacity: .88; font-size: 14px; }
.timer { font: 600 44px/1.1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: -1px; margin: 6px 0 14px; font-variant-numeric: tabular-nums; }
.timer.sm { font-size: 30px; margin: 2px 0 8px; }
.shift .btn { background: rgba(203, 213, 225, .14); color: #f8fafc; border: 1px solid rgba(203, 213, 225, .24); }
.shift .btn.primary { background: linear-gradient(135deg, #ffffff 0%, #dbe4f0 100%); color: #0a1a33; border: 0; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.shift .badge.live { background: rgba(203, 213, 225, .18); color: #e2e8f0; }

.room { display: flex; gap: 14px; align-items: flex-start; }
.room-num { width: 48px; height: 48px; flex: none; border-radius: 14px; background: var(--surface-sub); display: grid; place-items: center;
  font-weight: 700; font-size: 20px; border: 1px solid var(--border); }
.room.done .room-num { background: var(--green-bg); color: var(--green); border-color: transparent; }
.room.busy .room-num { background: var(--blue-bg); color: var(--blue); border-color: transparent; }
.room.p1 .room-num { background: var(--red-bg); color: var(--red); border-color: transparent; }
.room .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.note { margin-top: 6px; font-size: 14px; color: var(--text); background: var(--surface-sub); padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); }

.grid-rooms { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.grid-rooms .cell { aspect-ratio: 1; border-radius: 14px; background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; position: relative;
  cursor: pointer; user-select: none;
  transition: transform .16s cubic-bezier(.22, 1, .36, 1), box-shadow .16s ease, border-color .16s ease, background-color .16s ease; }
@media (hover: hover) {
  .grid-rooms .cell:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--accent); }
}
.grid-rooms .cell:active, .grid-rooms .cell.is-pressed { transform: scale(.87); box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
.grid-rooms .cell small { font-size: 10px; font-weight: 600; opacity: .82; }
.grid-rooms .cell.done { background: var(--green-bg); color: var(--green); border-color: rgba(31, 157, 87, .25); }
.grid-rooms .cell.busy { background: var(--blue-bg); color: var(--blue); border-color: rgba(45, 108, 224, .25); }
.grid-rooms .cell .flag { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 2px var(--card); }
.flag.p1 { background: var(--red); } .flag.p2 { background: var(--amber); } .flag.p3 { background: var(--blue); }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 84px)); gap: 8px; margin-top: 10px; }
.media-grid .m { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--bg); border: 1px solid var(--border);
  cursor: pointer; transition: transform .14s cubic-bezier(.22, 1, .36, 1); }
.media-grid .m:active, .media-grid .m.is-pressed { transform: scale(.93); }
.media-grid img, .media-grid video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-grid .m .del { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .65); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.media-grid .m .tag { position: absolute; left: 4px; bottom: 4px; background: rgba(0, 0, 0, .65); color: #fff; font-size: 10px; padding: 2px 5px; border-radius: 5px; }
.media-grid .m.up { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.progress { width: 72%; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.add-tile { aspect-ratio: 1; border-radius: 12px; border: 1.5px dashed var(--accent); display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 2px; color: var(--accent-strong); font-weight: 600; font-size: 11px; cursor: pointer; background: var(--accent-soft);
  transition: transform .14s cubic-bezier(.22, 1, .36, 1), background-color .14s ease; }
.add-tile:active, .add-tile.is-pressed { transform: scale(.92); }
.add-tile b { font-size: 22px; line-height: 1; }
@media (prefers-color-scheme: dark) {
  .add-tile { color: #e2e8f0; border-color: rgba(203, 213, 225, .45); }
}
.req { display: flex; align-items: center; gap: 8px; }
.req .ok { color: var(--green); font-weight: 700; }

.full-media { width: 100%; border-radius: 14px; display: block; background: #000; max-height: 70vh; object-fit: contain; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabs .inner { display: flex; max-width: 640px; width: 100%; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px 2px 10px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; color: var(--muted); cursor: pointer; transition: transform .14s cubic-bezier(.22, 1, .36, 1), color .14s ease; }
.tabs button:active, .tabs button.is-pressed { transform: scale(.92); }
.tabs button .ic { font-size: 20px; line-height: 1.1; filter: grayscale(1); opacity: .7; }
.tabs button.on { color: var(--accent-strong); font-weight: 600; }
@media (prefers-color-scheme: dark) { .tabs button.on { color: #ffffff; } }
.tabs button.on .ic { filter: none; opacity: 1; }

.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 4px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
  transition: transform .12s ease, background-color .14s ease, color .14s ease; }
.seg button:active, .seg button.is-pressed { transform: scale(.95); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.seg button.on.p1 { color: var(--red); } .seg button.on.p2 { color: var(--amber); } .seg button.on.p3 { color: var(--blue); }

.datebar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.datebar .btn { width: 44px; padding: 10px 0; }
.datebar input { flex: 1; text-align: center; font-weight: 600; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin: 0 4px 6px; }
input[type=text], input[type=tel], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 12px; outline: none; transition: border-color .14s ease; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 22px; margin-top: 2px; }
.kv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; text-align: center; }
.kv div { background: var(--surface-sub); border-radius: 10px; padding: 8px 4px; border: 1px solid var(--border); }
.kv b { display: block; font-size: 16px; }
.kv span { font-size: 11px; color: var(--muted); }

.timeline .ev { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.timeline .ev:first-child { border-top: 0; }
.timeline .t { width: 92px; flex: none; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .44); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; backdrop-filter: blur(2px); }
.sheet { background: var(--bg); width: 100%; max-width: 640px; border-radius: 22px 22px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow: auto; animation: up .2s ease-out; }
.sheet .grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { font-size: 19px; margin-bottom: 14px; }
.sheet.viewer { background: #000; color: #fff; max-height: 100vh; height: 100vh; border-radius: 0; display: flex; flex-direction: column; justify-content: center; padding: 16px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--dark); color: var(--bg);
  padding: 12px 18px; border-radius: 14px; z-index: 100; max-width: 90vw; font-size: 15px; box-shadow: 0 6px 24px rgba(0, 0, 0, .2); }
.toast.err { background: var(--red); color: #fff; }

.dev-bar { font-size: 12px; text-align: center; color: var(--muted); margin-top: 24px; }
