:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #263244;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #10b981;
  --accent-dim: rgba(16,185,129,0.09);
  --violet: #8b5cf6;
  --violet-dim: rgba(139,92,246,0.09);
  --amber: #f59e0b;
  --red: #ef4444;
  --r-card: 12px;
  --r-btn: 8px;
  --r-input: 6px;
}
* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html { height:100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height:100%;
  max-width:480px;
  margin:0 auto;
}

/* ─── LOGIN ─── */
#screen-login {
  display:flex; flex-direction:column; align-items:center;
  justify-content:center; min-height:100vh; padding:32px 24px; gap:20px;
}
.select-logo { font-size:56px; line-height:1; }
.select-title { font-size:28px; font-weight:800; letter-spacing:-0.02em; text-align:center; }
.select-sub { font-size:15px; color:var(--muted); text-align:center; }
.login-form { display:flex; flex-direction:column; gap:12px; width:100%; }
.login-input {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--r-input);
  padding:14px 16px; font-size:16px; color:var(--text); width:100%;
}
.login-input:focus { outline:none; border-color:var(--accent); }
.login-error { font-size:13px; color:var(--red); min-height:18px; }
.login-btn {
  background:var(--accent); color:white; border:none; border-radius:var(--r-btn);
  padding:14px; font-size:16px; font-weight:700; cursor:pointer; transition:background 0.15s;
}
.login-btn:hover { background:#059669; }

/* ─── APP SHELL ─── */
#screen-app { display:none; min-height:100vh; }
.header {
  position:sticky; top:0; z-index:20;
  background:var(--bg); border-bottom:1px solid var(--border);
  padding:12px 16px; display:flex; align-items:center; justify-content:space-between;
}
.header-logo { font-size:18px; font-weight:800; letter-spacing:-0.02em; }
.header-user {
  display:flex; align-items:center; gap:7px;
  background:var(--surface); border:1px solid var(--border);
  border-radius:24px; padding:6px 12px 6px 6px;
  cursor:pointer; transition:background 0.15s;
}
.header-user:hover { background:var(--surface2); }
.hdr-avatar {
  width:26px; height:26px; border-radius:50%;
  display:flex; align-items:center; justify-content:center; font-size:15px;
}
.hdr-name { font-size:13px; font-weight:600; }
.hdr-switch { color:var(--muted); font-size:12px; }

/* ─── NAV ─── */
.nav {
  position:fixed; bottom:0; left:50%; transform:translateX(-50%);
  width:100%; max-width:480px;
  background:var(--bg); border-top:1px solid var(--border);
  display:flex; z-index:20;
}
.nav-btn {
  flex:1; display:flex; flex-direction:column; align-items:center; gap:3px;
  padding:10px 8px 14px; border:none; background:none;
  color:var(--muted); font-size:11px; font-weight:500;
  cursor:pointer; transition:color 0.15s;
}
.nav-btn.active { color:var(--accent); }
.nav-icon { font-size:22px; }

/* ─── PAGES ─── */
.page { display:none; padding:16px; padding-bottom:80px; }
.page.active { display:block; }

/* ─── WINNER BANNER ─── */
.winner-banner {
  background:rgba(245,158,11,0.09); border:1px solid rgba(245,158,11,0.28);
  border-radius:var(--r-card); padding:12px 14px;
  display:flex; align-items:center; gap:10px;
  margin-bottom:16px; cursor:pointer;
}
.wb-text { flex:1; font-size:14px; font-weight:500; line-height:1.4; }
.wb-close { color:var(--muted); font-size:18px; }

/* ─── SCORES ─── */
.scores { display:flex; gap:12px; margin-bottom:20px; }
.score-card {
  flex:1; background:var(--surface); border:1px solid var(--border);
  border-radius:var(--r-card); padding:14px; transition:border-color 0.15s;
}
.score-card.is-current-u1 { border-color:var(--accent); background:var(--accent-dim); }
.score-card.is-current-u2 { border-color:var(--violet); background:var(--violet-dim); }
.score-hdr { display:flex; align-items:center; gap:8px; margin-bottom:10px; }
.score-avatar {
  width:28px; height:28px; border-radius:50%;
  display:flex; align-items:center; justify-content:center; font-size:16px;
}
.score-uname { font-size:13px; font-weight:700; }
.score-pts { font-size:36px; font-weight:900; letter-spacing:-0.03em; line-height:1; margin-bottom:4px; }
.score-streak { font-size:12px; color:var(--muted); }
.score-total { font-size:11px; color:var(--muted); margin-top:2px; }

/* ─── SECTION TITLE ─── */
.section-title {
  font-size:11px; font-weight:700; color:var(--muted);
  text-transform:uppercase; letter-spacing:0.08em; margin-bottom:12px;
}

/* ─── PHOTOS FEED ─── */
.photos-scroll {
  display:flex; gap:10px; overflow-x:auto;
  margin-bottom:24px; padding-bottom:4px;
  scrollbar-width:none; -webkit-overflow-scrolling:touch;
}
.photos-scroll::-webkit-scrollbar { display:none; }
.photo-item { flex-shrink:0; width:76px; position:relative; }
.photo-thumb {
  width:76px; height:76px; border-radius:10px; overflow:hidden;
  background:var(--surface); border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center; font-size:28px;
}
.photo-thumb img { width:100%; height:100%; object-fit:cover; }
.photo-thumb.is-ko { border-color:#ef444460; }
.photo-ko-dot {
  position:absolute; top:3px; right:3px;
  background:#ef4444; border-radius:50%;
  width:10px; height:10px;
}
.photo-task { font-size:11px; color:var(--muted); text-align:center; margin-top:4px; }
.photo-by { font-size:11px; font-weight:700; text-align:center; }
.no-actions {
  font-size:13px; color:var(--muted); font-style:italic;
  margin-bottom:24px; padding:16px;
  background:var(--surface); border-radius:var(--r-card); text-align:center; line-height:1.5;
}

/* ─── TASK GRID ─── */
.task-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
.task-cell {
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--r-card); padding:14px 8px 12px;
  display:flex; flex-direction:column; align-items:center; gap:5px;
  cursor:pointer; position:relative; aspect-ratio:1; justify-content:center;
  transition:border-color 0.12s, background 0.12s, transform 0.1s; user-select:none;
}
.task-cell:active { transform:scale(0.94); }
.task-cell:hover { border-color:var(--accent); background:var(--accent-dim); }
.tc-emoji { font-size:34px; line-height:1; }
.tc-label { font-size:12px; font-weight:600; text-align:center; }
.tc-last { font-size:10px; font-weight:600; text-align:center; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; }
.tc-badge {
  position:absolute; top:6px; right:6px;
  background:var(--accent); color:white; border-radius:10px;
  font-size:10px; font-weight:800; min-width:18px; height:18px;
  display:flex; align-items:center; justify-content:center; padding:0 4px;
}
.task-add { border-style:dashed; }
.task-add:hover { border-color:var(--muted); background:none; }

/* ─── MODALS ─── */
.overlay {
  position:fixed; inset:0; background:rgba(0,0,0,0.6);
  backdrop-filter:blur(3px); z-index:50; display:none; align-items:flex-end;
}
.overlay.open { display:flex; }
.sheet {
  background:var(--surface); border-radius:20px 20px 0 0;
  width:100%; max-width:480px; margin:0 auto; padding:0 24px 32px;
  animation:slide-up 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes slide-up {
  from { transform:translateY(100%); opacity:0; }
  to { transform:translateY(0); opacity:1; }
}
.sheet-handle {
  width:36px; height:4px; background:var(--border);
  border-radius:2px; margin:12px auto 20px;
}
.modal-header { text-align:center; margin-bottom:24px; }
.m-emoji { font-size:56px; line-height:1; display:block; margin-bottom:10px; }
.m-name { font-size:22px; font-weight:800; margin-bottom:4px; }
.m-hint { font-size:13px; color:var(--muted); }
.photo-zone {
  height:180px; background:var(--bg); border:2px dashed var(--border);
  border-radius:var(--r-card);
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px;
  cursor:pointer; margin-bottom:16px; overflow:hidden; transition:border-color 0.15s;
}
.photo-zone:hover { border-color:var(--muted); }
.photo-zone.has-photo { border-style:solid; border-color:var(--accent); }
.photo-zone img { width:100%; height:100%; object-fit:cover; }
.pz-icon { font-size:32px; }
.pz-text { font-size:13px; color:var(--muted); }
.modal-btns { display:flex; gap:10px; }
.btn {
  flex:1; padding:14px; border-radius:var(--r-btn); border:none;
  font-size:15px; font-weight:700; cursor:pointer; transition:all 0.12s;
}
.btn-cancel { background:var(--bg); color:var(--text); border:1px solid var(--border); }
.btn-cancel:hover { border-color:var(--muted); }
.btn-primary { background:var(--accent); color:white; }
.btn-primary:hover { background:#059669; }
.btn-primary:disabled { opacity:0.3; cursor:not-allowed; }
.add-title { font-size:18px; font-weight:800; margin-bottom:20px; }
.add-fields { display:flex; gap:10px; margin-bottom:6px; }
.inp-emoji {
  width:56px; height:56px; background:var(--bg); border:1px solid var(--border);
  border-radius:var(--r-input); font-size:26px; text-align:center; color:var(--text);
}
.inp-label {
  flex:1; background:var(--bg); border:1px solid var(--border);
  border-radius:var(--r-input); padding:0 14px; font-size:16px; color:var(--text); height:56px;
}
.inp-emoji:focus, .inp-label:focus { outline:none; border-color:var(--accent); }
.field-err { font-size:12px; color:var(--red); margin-bottom:12px; display:none; }
.field-err.show { display:block; }
#file-input { display:none; }

/* ─── TOAST ─── */
.toast {
  position:fixed; top:16px; left:16px; right:16px; max-width:448px; margin:0 auto;
  background:var(--accent); color:white; padding:14px 18px;
  border-radius:10px; font-size:14px; font-weight:600;
  box-shadow:0 4px 24px rgba(16,185,129,0.35); z-index:100;
  display:none; align-items:center; gap:8px;
}
.toast.show { display:flex; animation:toast-in 0.18s ease; }
@keyframes toast-in {
  from { transform:translateY(-10px); opacity:0; }
  to { transform:translateY(0); opacity:1; }
}

/* ─── ANALYTICS ─── */
.export-btn {
  background:var(--surface); border:1px solid var(--border);
  color:var(--muted); border-radius:var(--r-btn);
  padding:8px 14px; font-size:13px; font-weight:600;
  cursor:pointer; transition:all 0.15s; white-space:nowrap;
}
.export-btn:hover { border-color:var(--accent); color:var(--accent); }
.an-title { font-size:22px; font-weight:800; margin-bottom:4px; }
.an-sub { font-size:13px; color:var(--muted); margin-bottom:20px; }
.an-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--r-card); padding:16px; margin-bottom:14px; }
.an-card-title { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:0.08em; color:var(--muted); margin-bottom:16px; }
.bar-row { display:flex; align-items:center; gap:10px; margin-bottom:12px; }
.bar-row:last-child { margin-bottom:0; }
.bar-av { width:28px; height:28px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:16px; flex-shrink:0; }
.bar-nm { font-size:13px; font-weight:600; width:40px; flex-shrink:0; }
.bar-track { flex:1; height:10px; background:var(--bg); border-radius:5px; overflow:hidden; }
.bar-fill { height:100%; border-radius:5px; transition:width 0.4s cubic-bezier(0.4,0,0.2,1); min-width:4px; }
.bar-cnt { font-size:14px; font-weight:800; width:28px; text-align:right; flex-shrink:0; }
.task-row { padding:10px 0; border-bottom:1px solid var(--border); }
.task-row:last-child { border-bottom:none; }
.tr-header { display:flex; align-items:center; gap:10px; margin-bottom:5px; }
.tr-emoji { font-size:20px; width:28px; text-align:center; }
.tr-label { font-size:14px; font-weight:600; flex:1; }
.tr-total { font-size:14px; font-weight:800; }
.tr-split { display:flex; gap:12px; padding-left:38px; }
.tr-split span { font-size:12px; font-weight:600; }
.hist-item { display:flex; align-items:center; gap:12px; padding:10px 0; border-bottom:1px solid var(--border); }
.hist-item:last-child { border-bottom:none; }
.hist-emoji { font-size:24px; width:32px; text-align:center; }
.hist-info { flex:1; }
.hist-task { font-size:14px; font-weight:600; }
.hist-date { font-size:12px; color:var(--muted); margin-top:1px; }
.hist-photo { width:44px; height:44px; border-radius:8px; object-fit:cover; background:var(--bg); border:1px solid var(--border); }
.hist-user { font-size:13px; font-weight:700; }
.empty-state { text-align:center; padding:48px 24px; color:var(--muted); }
.empty-icon { font-size:48px; display:block; margin-bottom:12px; }
.empty-text { font-size:14px; line-height:1.6; }

/* ─── REVIEW PAGE ─── */
.review-week-toggle {
  display:flex; gap:8px; margin-bottom:20px;
}
.rwt-btn {
  flex:1; padding:10px; border-radius:var(--r-btn); border:1px solid var(--border);
  background:var(--surface); color:var(--muted); font-size:13px; font-weight:600;
  cursor:pointer; transition:all 0.15s;
}
.rwt-btn.active { background:var(--accent); border-color:var(--accent); color:white; }

.review-item {
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--r-card); margin-bottom:14px; overflow:hidden;
  transition:border-color 0.15s;
}
.review-item.is-ko {
  border-color:#ef444460;
  background:rgba(239,68,68,0.05);
}
.review-photo-wrap { position:relative; width:100%; aspect-ratio:4/3; background:var(--bg); }
.review-photo-wrap img { width:100%; height:100%; object-fit:cover; display:block; }
.review-no-photo {
  width:100%; height:140px; background:var(--bg);
  display:flex; align-items:center; justify-content:center; font-size:48px;
}
.review-ko-badge {
  position:absolute; top:10px; right:10px;
  background:#ef4444; color:white; border-radius:6px;
  padding:4px 10px; font-size:12px; font-weight:700;
}
.review-body { padding:14px; }
.review-task-row { display:flex; align-items:center; gap:8px; margin-bottom:6px; }
.review-task-emoji { font-size:22px; }
.review-task-name { font-size:16px; font-weight:700; flex:1; }
.review-meta { font-size:12px; color:var(--muted); margin-bottom:14px; }
.review-btns { display:flex; gap:8px; }
.rv-btn {
  flex:1; padding:10px; border-radius:var(--r-btn); border:1px solid var(--border);
  background:var(--surface2); color:var(--muted); font-size:14px; font-weight:600;
  cursor:pointer; transition:all 0.12s;
}
.rv-btn-ok {
  flex:1; padding:10px; border-radius:var(--r-btn); border:1px solid var(--accent);
  background:var(--accent-dim); color:var(--accent); font-size:14px; font-weight:700;
  cursor:pointer; transition:all 0.12s;
}
.rv-btn-ko {
  flex:1; padding:10px; border-radius:var(--r-btn); border:1px solid #ef444460;
  background:rgba(239,68,68,0.08); color:#f87171; font-size:14px; font-weight:700;
  cursor:pointer; transition:all 0.12s;
}

/* ─── USER MENU ─── */
.user-menu {
  position:absolute; top:52px; right:16px;
  background:var(--surface2); border:1px solid var(--border);
  border-radius:var(--r-card); padding:6px; min-width:210px;
  z-index:30; display:none;
  box-shadow:0 8px 24px rgba(0,0,0,0.4);
  animation:menu-in 0.12s ease;
}
.user-menu.open { display:block; }
@keyframes menu-in {
  from { opacity:0; transform:translateY(-6px); }
  to { opacity:1; transform:translateY(0); }
}
.user-menu-item {
  display:block; width:100%; text-align:left;
  background:none; border:none; color:var(--text);
  padding:10px 14px; border-radius:8px;
  font-size:14px; font-weight:500; cursor:pointer;
  transition:background 0.12s;
}
.user-menu-item:hover { background:var(--border); }
.user-menu-danger { color:#f87171; }
.user-menu-sep { height:1px; background:var(--border); margin:4px 0; }

/* ─── SKELETON ─── */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--r-card);
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
