:root{
  --bg: #0f1115;
  --bg-2: #161922;
  --panel: #1b1f2a;
  --panel-2: #222838;
  --line: #2a3043;
  --ink: #e8ecf3;
  --ink-dim: #a6adbf;
  --ink-mute: #707690;
  --accent: #7aa2ff;
  --accent-2: #b4d1ff;
  --lived: #4f6bff;
  --current: #ffd166;
  --ahead: #2c3144;
  --ahead-line: #3a4159;
  --danger: #ff7a8a;
  --good: #7be0a8;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*{ box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin:0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(122,162,255,.18), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(255,209,102,.10), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app{
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 22px 80px;
}

/* Topbar */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 28px;
}
.brand{
  display:flex; align-items:center; gap:10px;
  font-weight: 600;
  letter-spacing: .2px;
}
.brand .dot{
  width:10px; height:10px; border-radius:50%;
  background: linear-gradient(135deg, var(--accent), var(--current));
  box-shadow: 0 0 18px rgba(122,162,255,.6);
}
.brand .name{ font-size: 14px; color: var(--ink-dim); }
.status{
  font-size: 12px;
  color: var(--ink-mute);
  font-family: var(--mono);
}

/* Hero */
.hero{
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.title{
  margin: 0 0 8px;
  font-size: clamp(22px, 3.4vw, 30px);
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.subtitle{
  margin: 0 0 22px;
  color: var(--ink-dim);
  font-size: 14.5px;
  max-width: 60ch;
}

.form{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.field{ display:flex; flex-direction:column; gap:6px; }
.label{
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-mute);
}
.field input{
  appearance:none;
  -webkit-appearance:none;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 16px;
  font-family: var(--sans);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.field input::placeholder{ color: #4f5570; }
.field input:focus{
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(122,162,255,.18);
  background: #131722;
}

.row{
  grid-column: 1 / -1;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 14px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.checkbox{
  display:inline-flex; align-items:center; gap:8px;
  color: var(--ink-dim);
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
}
.checkbox input{ accent-color: var(--accent); width:16px; height:16px; }

.btn{
  appearance:none;
  border:1px solid var(--accent);
  background: linear-gradient(180deg, var(--accent), #5d82ff);
  color: #0b1020;
  font-weight: 600;
  font-size: 14.5px;
  padding: 11px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease, box-shadow .15s ease;
  box-shadow: 0 6px 18px rgba(122,162,255,.25);
}
.btn:hover{ filter: brightness(1.05); }
.btn:active{ transform: translateY(1px); }
.btn.ghost{
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn.ghost:hover{ color: var(--ink); border-color: #3a4159; }
.btn.ghost.danger{ color: var(--danger); border-color: rgba(255,122,138,.35); }
.btn.ghost.danger:hover{ background: rgba(255,122,138,.08); }

.error{
  grid-column: 1 / -1;
  margin-top: 4px;
  color: var(--danger);
  font-size: 13px;
  background: rgba(255,122,138,.08);
  border: 1px solid rgba(255,122,138,.25);
  padding: 10px 12px;
  border-radius: 10px;
}

/* Dashboard */
.dashboard{
  margin-top: 26px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.readout{
  display:grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 18px;
  align-items: stretch;
}
.readout-main{
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  display:flex; flex-direction:column; justify-content:center;
}
.big{
  font-size: clamp(40px, 7vw, 64px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent-2), var(--current));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.big-label{
  margin-top: 6px;
  color: var(--ink-dim);
  font-size: 13.5px;
}
.big-sub{
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  background: rgba(123,224,168,.08);
  border: 1px solid rgba(123,224,168,.25);
  padding: 8px 10px;
  border-radius: 8px;
  display:inline-flex;
  align-items:center;
  gap:6px;
  width: fit-content;
}
.big-sub span{
  color: var(--good);
  font-weight: 600;
}
.readout-side{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.kv{
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  display:flex; flex-direction:column;
}
.kv .k{
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.kv .v{
  font-family: var(--mono);
  font-size: 18px;
  margin-top: 4px;
  color: var(--ink);
}

.counter{
  margin-top: 16px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  display:flex; flex-wrap:wrap; align-items:baseline; gap: 6px 10px;
  font-family: var(--mono);
}
.counter .seg{
  display:inline-flex; align-items:baseline; gap:6px;
}
.counter b{
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
}
.counter i{
  font-style: normal;
  color: var(--ink-mute);
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.counter .sep{ color: var(--ink-mute); opacity:.5; }

.legend{
  margin-top: 14px;
  display:flex; align-items:center; gap: 14px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-dim);
}
.legend .sw{
  display:inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}
.sw.lived{ background: var(--lived); }
.sw.current{
  background: var(--current);
  box-shadow: 0 0 0 2px rgba(255,209,102,.25);
}
.sw.ahead{
  background: var(--ahead);
  border: 1px solid var(--ahead-line);
}
.legend .hint{
  margin-left: auto;
  color: var(--ink-mute);
}

/* Grid */
.grid-wrap{
  margin-top: 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  overflow-x: auto;
}
.grid{
  display: grid;
  /*52 columns: weeks across a year */
  grid-template-columns: repeat(52, 1fr);
  gap: 3px;
  min-width: 720px;
}
.cell{
  aspect-ratio: 1 / 1;
  border-radius: 2px;
  background: var(--ahead);
  border: 1px solid var(--ahead-line);
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
  cursor: default;
}
.cell.lived{
  background: var(--lived);
  border-color: transparent;
}
.cell.current{
  background: var(--current);
  border-color: transparent;
  box-shadow: 0 0 0 2px rgba(255,209,102,.35);
}
.cell:hover{ transform: scale(1.35); z-index: 2; position: relative; }

.tooltip{
  position: fixed;
  pointer-events:none;
  z-index: 50;
  background: #0b0f1a;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-family: var(--mono);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .12s ease, transform .12s ease;
  max-width: 240px;
}
.tooltip.show{ opacity: 1; transform: translateY(0); }
.tooltip .t-line{ color: var(--ink-dim); font-size: 11px; }

.actions{
  margin-top: 18px;
  display:flex; gap: 10px; flex-wrap: wrap;
}
.foot{
  margin-top: 16px;
  color: var(--ink-mute);
  font-size: 12.5px;
  text-align: center;
}

/* Responsive */
@media (max-width: 760px){
  .form{ grid-template-columns: 1fr; }
  .readout{ grid-template-columns: 1fr; }
  .grid{ min-width: 640px; }
  .legend .hint{ margin-left: 0; }
}
@media (max-width: 420px){
  .app{ padding: 18px 14px 60px; }
  .hero, .dashboard{ padding: 18px; }
  .grid{ min-width: 560px; }
}