
:root {
  --bg: #0d1117;
  --bg-soft: #11161f;
  --card: #161c26;
  --card-2: #1c2430;
  --border: #232d3d;
  --text: #eef2f8;
  --text-dim: #9aa7b8;
  --accent: #4ade80;
  --accent-2: #22d3ee;
  --danger: #f87171;
  --warn: #fbbf24;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  min-height: 100vh;
  padding-bottom: 140px;
}

.hidden { display: none !important; }

.screen { animation: fadeUp .35s ease both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

#screen-profile {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.profile-box {
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 28px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: pop .45s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes pop {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: 1; transform: none; }
}
.profile-logo { font-size: 52px; animation: floaty 3s ease-in-out infinite; display: inline-block; }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.profile-box h1 { font-size: 22px; margin: 12px 0 6px; }
.sub { color: var(--text-dim); font-size: 14px; margin-bottom: 22px; }
.profile-list { display: flex; flex-direction: column; gap: 12px; }
.profile-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 15px 18px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s ease, border-color .2s ease, box-shadow .2s ease;
}
.profile-btn span.arrow { transition: transform .2s ease; }
.profile-btn:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(74,222,128,.12); }
.profile-btn:hover span.arrow { transform: translateX(4px); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 800; margin-right: 12px;
  flex: none;
}
.av-tim   { background: linear-gradient(135deg, #4ade80, #0ea5e9); }
.av-simon { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.av-other { background: linear-gradient(135deg, #a78bfa, #ec4899); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px calc(10px);
  background: rgba(13, 17, 23, .82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-emoji {
  font-size: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(74,222,128,.18), rgba(34,211,238,.14));
  border: 1px solid rgba(74,222,128,.3);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 17px; letter-spacing: .2px; }
.top-date { font-size: 12px; color: var(--text-dim); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--border);
  font-size: 18px; cursor: pointer;
  transition: all .18s ease;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.icon-btn.active {
  background: linear-gradient(135deg, rgba(74,222,128,.22), rgba(34,211,238,.16));
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74,222,128,.15);
}
.profile-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border);
  color: var(--text); padding: 6px 12px 6px 6px;
  border-radius: 999px; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: border-color .2s ease;
}
.profile-chip:hover { border-color: var(--accent); }
.profile-chip .avatar { width: 28px; height: 28px; font-size: 12px; margin: 0; }

.progress-card {
  margin: 4px 14px 8px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  animation: slideDown .4s ease both;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.progress-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; margin-bottom: 8px; }
.progress-head span:first-child { color: var(--text-dim); }
.progress-pct { font-weight: 800; color: var(--accent); font-size: 15px; }
.progress-track { height: 8px; background: var(--card-2); border-radius: 99px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px;
  transition: width .5s cubic-bezier(.22, 1, .36, 1);
  box-shadow: 0 0 12px rgba(74,222,128,.5);
}

.day-tabs {
  display: flex; gap: 8px;
  padding: 6px 14px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.day-tabs::-webkit-scrollbar { display: none; }
.day-tab {
  flex: 1 0 auto; min-width: 62px;
  text-align: center;
  padding: 8px 4px 10px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 10px 10px 0 0;
  color: var(--text-dim);
  cursor: pointer;
  transition: all .18s ease;
  position: relative;
}
.day-tab .dt-name { font-size: 12px; font-weight: 700; display: block; }
.day-tab .dt-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--card-2); display: inline-block; margin-top: 5px;
  transition: background .3s ease;
}
.day-tab.today .dt-name { color: var(--accent-2); }
.day-tab.active { color: var(--text); background: var(--card); border-bottom-color: var(--accent); }
.day-tab.active .dt-dot { background: var(--accent); box-shadow: 0 0 8px rgba(74,222,128,.6); }
.day-tab.done .dt-dot { background: var(--accent); }
.day-tab.today .dt-name::after { content: "·"; color: var(--accent-2); }
.day-tab .dt-count { font-size: 10px; opacity: .75; margin-top: 1px; display: block; }

.day-content { padding: 2px 14px 30px; max-width: 640px; margin: 0 auto; }
.day-title { font-size: 21px; font-weight: 800; margin: 8px 2px 14px; display: flex; align-items: center; gap: 10px; }
.day-title .emoji { animation: floaty 2.6s ease-in-out infinite; display: inline-block; }
.day-title .date-full { font-size: 13px; color: var(--text-dim); font-weight: 500; }

.block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  animation: fadeUp .4s ease both;
}
.block-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 10px;
  border-bottom: 1px solid rgba(35,45,61,.6);
  background: linear-gradient(90deg, rgba(74,222,128,.05), transparent 70%);
}
.block-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.block.kind-evening .block-title { 
  color: var(--accent-2); 
  
}
.block.kind-evening { 
  margin-bottom: 100px;
}
.block.kind-rest .block-title { color: var(--warn); }
.block-tools { display: flex; gap: 6px; opacity: 0; transition: opacity .15s ease; }
.block:hover .block-tools, .block.editing .block-tools { opacity: 1; }
.mini-btn {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--card-2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s ease;
}
.mini-btn:hover { color: var(--text); border-color: var(--accent); }
.mini-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.block-body { padding: 6px 0; }

.item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid rgba(35,45,61,.45);
  transition: background .15s ease;
  animation: fadeUp .3s ease both;
}
.item:last-child { border-bottom: none; }
.item:hover { background: rgba(255,255,255,.015); }
.check {
  flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--card-2);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; color: transparent;
  transition: all .2s cubic-bezier(.2, 1.3, .4, 1);
  position: relative;
}
.check:hover { border-color: var(--accent); }
.item.done .check {
  background: linear-gradient(135deg, var(--accent), #16a34a);
  border-color: transparent;
  color: #052e16;
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(74,222,128,.4);
}
.item-text { flex: 1; min-width: 0; }
.item-name { font-size: 15px; font-weight: 600; line-height: 1.3; transition: color .2s ease; }
.item-detail { font-size: 12.5px; color: var(--text-dim); margin-top: 1px; font-weight: 500; }
.item.done .item-name { color: var(--text-dim); text-decoration: line-through; text-decoration-color: rgba(154,167,184,.5); }
.item.done .item-detail { text-decoration: line-through; opacity: .6; }
.item-tools { display: flex; gap: 6px; opacity: 0; transition: opacity .15s ease; }
.item:hover .item-tools, .item.editing .item-tools { opacity: 1; }
.item-edit-input, .item-edit-detail {
  width: 100%;
  background: var(--bg-soft); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px;
  padding: 8px 12px; font-size: 14.5px; font-family: inherit;
  outline: none;
}
.item-edit-detail { margin-top: 5px; font-size: 13px; }
.item-edit-input:focus, .item-edit-detail:focus { border-color: var(--accent); }
.item-actions-inline { display: flex; gap: 8px; margin-top: 8px; }

.add-row {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px;
  color: var(--text-dim); font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: all .18s ease;
  border-top: 1px dashed rgba(35,45,61,.6);
  background: transparent; width: 100%;
}
.add-row:hover { color: var(--accent); background: rgba(74,222,128,.04); }
.add-block-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 12px;
  margin: 2px 0 16px;
  border-radius: 14px;
  border: 1.5px dashed var(--border);
  background: transparent;
  color: var(--text-dim); font-size: 13.5px; font-weight: 700;
  cursor: pointer; transition: all .18s ease;
}
.add-block-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(74,222,128,.04); }

.day-rest {
  text-align: center;
  padding: 26px 18px;
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 4px 0 14px;
  animation: floaty 4s ease-in-out infinite;
}
.day-rest .rest-emoji { font-size: 40px; }
.day-rest .rest-title { font-size: 18px; font-weight: 800; margin-top: 6px; }
.day-rest .rest-sub { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

.modal {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(4, 7, 12, .7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .2s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%; max-width: 520px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px 22px 0 0;
  padding: 22px 20px calc(18px + env(safe-area-inset-bottom));
  animation: sheetUp .3s cubic-bezier(.2, 1.2, .4, 1) both;
  max-height: 86vh; overflow-y: auto;
}
@media (min-width: 560px) {
  .modal { align-items: center; padding: 20px; }
  .modal-card { border-radius: 22px; }
}
@keyframes sheetUp { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-card h3 { font-size: 18px; margin-bottom: 14px; }
.modal-card label { display: block; font-size: 12.5px; color: var(--text-dim); font-weight: 700; margin: 12px 0 5px; text-transform: uppercase; letter-spacing: .5px; }
.modal-card input[type=text], .modal-card textarea, .modal-card select {
  width: 100%;
  background: var(--bg-soft); border: 1px solid var(--border);
  color: var(--text); border-radius: 12px;
  padding: 12px 14px; font-size: 15px; font-family: inherit; outline: none;
}
.modal-card input:focus, .modal-card textarea:focus, .modal-card select:focus { border-color: var(--accent); }
.modal-card textarea { resize: vertical; min-height: 60px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.btn {
  border: none; border-radius: 12px;
  padding: 11px 20px; font-size: 14.5px; font-weight: 700;
  cursor: pointer; transition: all .18s ease;
  font-family: inherit;
}
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #16a34a);
  color: #052e16;
  box-shadow: 0 6px 16px rgba(74,222,128,.3);
}
.btn.primary:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn.ghost { background: var(--card-2); color: var(--text-dim); border: 1px solid var(--border); }
.btn.ghost:hover { color: var(--text); }
.btn.danger { background: rgba(248,113,113,.12); color: var(--danger); border: 1px solid rgba(248,113,113,.3); }
.btn.small { padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.seg { display: flex; gap: 6px; }
.seg-btn {
  flex: 1; padding: 10px; border-radius: 10px;
  background: var(--card-2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 13.5px; font-weight: 700; cursor: pointer;
  transition: all .15s ease; font-family: inherit;
}
.seg-btn:hover { border-color: var(--accent); }
.seg-btn.sel { background: rgba(74,222,128,.15); border-color: var(--accent); color: var(--accent); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--card-2); border: 1px solid var(--border);
  color: var(--text); font-size: 13.5px; font-weight: 600;
  padding: 11px 20px; border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: all .3s cubic-bezier(.2, 1.2, .4, 1);
  z-index: 2500; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: var(--accent); color: var(--accent); }

@keyframes confetti {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(-140px) rotate(540deg); opacity: 0; }
}
.celebrate { position: fixed; top: 45%; left: 50%; z-index: 90; pointer-events: none; font-size: 34px; animation: confetti 1.4s ease-out forwards; }

.credit {
  position: fixed; bottom: 8px; right: 12px;
  color: #86868b; font-size: 11px; z-index: 30;
  pointer-events: none;
  opacity: .8;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

@media (min-width: 640px) {
  .day-tabs { justify-content: center; }
  .day-tab { min-width: 78px; }
}

.bottom-nav {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  max-width: 420px;
  height: 74px;
  background: rgba(22, 28, 38, .85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .5);
  z-index: 1000;
  animation: navUp .4s cubic-bezier(.2, 1.2, .4, 1) both;
}
@keyframes navUp { from { opacity: 0; transform: translateX(-50%) translateY(30px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: #86868b;
  background: transparent;
  border: none;
  transition: all .25s ease;
  padding: 10px 22px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  position: relative;
  flex: 1;
}
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.nav-item.active { color: #fff; }
.nav-item.active::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 34px;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(74, 222, 128, .7);
}
.nav-icon { width: 26px; height: 26px; }
.icon-week {
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%234ade80" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/><line x1="8" y1="14" x2="8.01" y2="14"/><line x1="12" y1="14" x2="12.01" y2="14"/><line x1="16" y1="14" x2="16.01" y2="14"/><line x1="8" y1="18" x2="8.01" y2="18"/><line x1="12" y1="18" x2="12.01" y2="18"/><line x1="16" y1="18" x2="16.01" y2="18"/></svg>') center/contain no-repeat;
}
.icon-stats {
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%234ade80" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/><line x1="3" y1="20" x2="21" y2="20"/></svg>') center/contain no-repeat;
}
.nav-item.active .icon-week { filter: drop-shadow(0 0 6px rgba(74,222,128,.8)); }
.nav-item.active .icon-stats { filter: drop-shadow(0 0 6px rgba(74,222,128,.8)); }

.view { animation: fadeUp .3s ease both; }
.stats-wrap { max-width: 640px; margin: 0 auto; padding: 10px 14px 20px; }
#stats-modes { margin-bottom: 14px; max-width: 340px; margin-left: auto; margin-right: auto; }
.period-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.period-nav .icon-btn { width: 40px; height: 40px; font-size: 14px; }
.period-label { flex: 1; text-align: center; font-size: 16px; font-weight: 800; }
.stats-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
  animation: fadeUp .4s ease both;
}
.stat-card::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(120px 60px at 90% -10%, var(--glow, rgba(74,222,128,.18)), transparent 70%);
  pointer-events: none;
}
.stat-card .sc-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); }
.stat-card .sc-value { font-size: 26px; font-weight: 900; margin-top: 2px; line-height: 1.15; }
.stat-card .sc-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 1px; }
.stat-card.c-cyan { --glow: rgba(34, 211, 238, .18); }
.stat-card.c-cyan .sc-value { color: var(--accent-2); }
.stat-card.c-green .sc-value { color: var(--accent); }
.stat-card.c-amber { --glow: rgba(251, 191, 36, .16); }
.stat-card.c-amber .sc-value { color: var(--warn); }
.stat-card.c-orange { --glow: rgba(251, 146, 60, .18); }
.stat-card.c-orange .sc-value { background: linear-gradient(135deg, #fb923c, #f87171); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

.stats-chart {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 14px 10px;
}
.chart-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; color: var(--text-dim); margin-bottom: 4px; padding: 0 4px; }
.chart { display: flex; align-items: flex-end; gap: 5px; height: 170px; padding: 6px 2px 0; }
.bar-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; cursor: pointer; }
.bar-track { width: 100%; max-width: 34px; height: 150px; display: flex; align-items: flex-end; justify-content: center; background: rgba(255,255,255,.02); border-radius: 8px 8px 0 0; position: relative; }
.bar-fill {
  width: 100%;
  min-height: 3px;
  border-radius: 8px 8px 2px 2px;
  background: linear-gradient(180deg, var(--accent), #16a34a);
  transition: height .6s cubic-bezier(.22, 1, .36, 1), filter .2s ease;
}
.bar-col:hover .bar-fill { filter: brightness(1.25); }
.bar-col.empty .bar-fill { background: var(--card-2); border: 1px solid var(--border); }
.bar-col.low .bar-fill { background: linear-gradient(180deg, #fbbf24, #b45309); }
.bar-col.perfect .bar-fill { background: linear-gradient(180deg, #4ade80, #16a34a); box-shadow: 0 0 12px rgba(74,222,128,.55); }
.bar-label { font-size: 10px; color: var(--text-dim); margin-top: 5px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bar-col.today .bar-label { color: var(--accent-2); font-weight: 800; }
.chart.compact { gap: 2px; }
.chart.compact .bar-track { max-width: 100%; border-radius: 4px 4px 0 0; }
.chart.compact .bar-fill { border-radius: 3px 3px 1px 1px; }
.stats-empty { text-align: center; color: var(--text-dim); padding: 34px 16px; background: var(--card); border: 1px dashed var(--border); border-radius: 16px; font-size: 14px; }

@media (min-width: 640px) {
  .stats-cards { grid-template-columns: repeat(4, 1fr); }
}

.item.warn {
  background: rgba(248, 113, 113, .05);
  border-bottom-color: rgba(248, 113, 113, .15);
}
.item.warn:last-child { border-bottom: none; }
.item.warn .item-name { color: #fca5a5; font-weight: 600; }
.item.warn .item-detail { color: rgba(252, 165, 165, .75); }
.warn-badge {
  flex: none;
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  background: rgba(248, 113, 113, .12);
  border: 1px solid rgba(248, 113, 113, .35);
  border-radius: 50%;
}
.icon-edit {
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%234ade80" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5z"/><path d="M15 5l4 4"/></svg>') center/contain no-repeat;
}
#nav-edit.active .icon-edit { filter: drop-shadow(0 0 6px rgba(74,222,128,.8)); }

.fab {
  position: fixed;
  right: 18px;
  bottom: 104px;
  width: 58px; height: 58px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #22d3ee, #0ea5e9);
  font-size: 26px;
  cursor: pointer;
  z-index: 900;
  box-shadow: 0 8px 24px rgba(14, 165, 233, .45);
  transition: transform .18s ease, box-shadow .18s ease;
  display: flex; align-items: center; justify-content: center;
}
.fab:active { transform: scale(.92); }
.fab.hidden { display: none; }

.race-card h3 { margin-bottom: 4px; }
.race-card input[type=text] { margin-bottom: 8px; }
.race-dials { display: flex; gap: 14px; justify-content: center; margin: 10px 0 4px; flex-wrap: wrap; }
.dial-box { display: flex; flex-direction: column; align-items: center; }
.dial-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); margin-bottom: 6px; }
.dial { width: 190px; height: 190px; position: relative; touch-action: none; user-select: none; -webkit-user-select: none; }
.dial svg { width: 100%; height: 100%; display: block; overflow: visible; }
.dial-ring { fill: none; stroke: var(--card-2); stroke-width: 2.5; }
.dial-tick { stroke: var(--border); stroke-width: 2; }
.dial-tick.maj { stroke: var(--text-dim); stroke-width: 3; }
.dial-value { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.dial-value .dv-main { font-size: 34px; font-weight: 900; line-height: 1; }
.dial-value .dv-sub { font-size: 11px; color: var(--text-dim); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; margin-top: 3px; }
.dial-knob {
  cursor: grab;
  fill: #0d1117;
  stroke: var(--accent);
  stroke-width: 4;
  filter: drop-shadow(0 0 8px rgba(74, 222, 128, .7));
  transition: stroke .15s ease;
}
.dial.dragging .dial-knob { stroke: var(--accent-2); }
.dial.dragging { cursor: grabbing; }
.dial:active .dial-knob { cursor: grabbing; }

.race-block { margin-top: 2px; }
.race-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(35,45,61,.45);
}
.race-row:last-child { border-bottom: none; }
.race-icon {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  background: rgba(34, 211, 238, .14);
  border: 1px solid rgba(34, 211, 238, .35);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.race-info { flex: 1; min-width: 0; }
.race-name { font-size: 15px; font-weight: 700; }
.race-meta { display: flex; gap: 10px; margin-top: 2px; flex-wrap: wrap; }
.race-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700;
  color: var(--accent-2);
  background: rgba(34, 211, 238, .08);
  border: 1px solid rgba(34, 211, 238, .2);
  border-radius: 99px; padding: 2px 9px;
}
.race-done-tag { font-size: 11px; color: var(--accent); font-weight: 800; }

.stats-races { margin-top: 12px; }
.stats-races-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; color: var(--text-dim); margin-bottom: 8px; }
.race-stat-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 100px;
  animation: fadeUp .3s ease both;
}
.race-stat-date { font-size: 12px; color: var(--text-dim); font-weight: 700; min-width: 64px; }
.race-stat-info { flex: 1; min-width: 0; }
.race-stat-name { font-size: 14px; font-weight: 700; }
.stat-card.wide { grid-column: span 2; }
.stat-card.wide .sc-value { font-size: 20px; }
.race-avg {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.rav-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
}
.rav-value { font-size: 16px; font-weight: 900; color: var(--accent); line-height: 1.1; }
.rav-label { font-size: 9.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; font-weight: 700; }
.rav-cell:nth-child(2) .rav-value { color: var(--accent-2); }
.rav-cell:nth-child(3) .rav-value { background: linear-gradient(135deg, #fb923c, #f87171); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.race-tools { display: flex; gap: 6px; flex: none; }
.race-stat-row .mini-btn { opacity: 1; }
