:root {
  --bg: #0D1015;
  --card: #161B22;
  --card-2: #1C222B;
  --line: #222934;
  --line-2: #343D4A;
  --text: #E8ECF2;
  --muted: #9AA4B2;
  --soft: #B8C1CD;
  --accent: #E8B04B;
  --ok: #5CC8A8;
  --danger: #E07A5F;
  --radius: 22px;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  line-height: 1.4;
}
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(30px, 5vw, 44px); font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 20px; font-weight: 600; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.page { max-width: 1360px; margin: 0 auto; padding: 32px 16px 64px; display: flex; flex-direction: column; gap: 16px; }

/* Header */
.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; padding-bottom: 8px; }
.eyebrow { font-family: var(--mono); font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.top-actions form { margin: 0; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 999px; background: var(--card); border: 1px solid #252C36; font-size: 14px; color: var(--soft); }
.pill svg { color: var(--ok); }

/* Buttons & inputs */
.btn { min-height: 44px; padding: 0 18px; border-radius: 12px; font: inherit; font-size: 15px; cursor: pointer; border: 1px solid transparent; }
.btn-primary { background: var(--accent); color: var(--bg); font-weight: 600; }
.btn-primary:hover { background: #F3CB7C; }
.btn-ghost { background: transparent; color: var(--text); border-color: #252C36; border-radius: 999px; }
.btn-ghost:hover { border-color: var(--line-2); }
input[type=text], input[type=password] {
  width: 100%; min-height: 44px; padding: 0 14px; border-radius: 12px;
  background: var(--card-2); border: 1px solid var(--line-2); color: var(--text); font: inherit; font-size: 16px;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Cards & grid */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.span-2 { grid-column: span 2; }
@media (max-width: 760px) { .span-2 { grid-column: auto; } .grid { grid-template-columns: 1fr; } }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.soon { margin: 0; padding: 18px; border-radius: 14px; border: 1px dashed var(--line-2); color: var(--muted); font-size: 15px; }

/* Ticker */
.ticker { flex-direction: row; flex-wrap: wrap; gap: 0; padding: 4px 8px; border-radius: 16px; }
.tick { flex: 1 1 200px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; }
.tick-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tick-name { font-size: 13px; color: var(--muted); }
.tick-val { font-size: 16px; font-weight: 500; white-space: nowrap; }
.tick-val.muted { font-size: 13px; }
.tick-chg { font-size: 13px; margin-left: 4px; }
.up { color: var(--ok); }
.down { color: #E8925F; }
.spark { flex: none; }
.spark.trend { color: var(--accent); vertical-align: middle; }
@media (max-width: 760px) {
  .ticker { width: 100%; max-width: calc(100vw - 32px); flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
  .tick { flex: 0 0 auto; scroll-snap-align: start; padding: 10px 14px; }
  .tick .spark { display: none; }
}
.spark path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Tasks */
.progress { height: 6px; border-radius: 999px; background: #232A35; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.task { display: flex; align-items: center; gap: 4px; border-radius: 12px; }
.task:hover { background: var(--card-2); }
.task-toggle { flex: 1; display: flex; align-items: center; gap: 14px; min-height: 48px; padding: 6px 8px; border: 0; background: transparent; color: inherit; font: inherit; font-size: 16px; text-align: left; cursor: pointer; }
.check { width: 24px; height: 24px; flex: none; border-radius: 8px; border: 2px solid #4A5462; display: flex; align-items: center; justify-content: center; color: transparent; }
.is-done .check { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.is-done .task-title { color: #7D8796; text-decoration: line-through; }
.task-delete { width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 22px; border-radius: 10px; cursor: pointer; opacity: 0; }
.task:hover .task-delete, .task-delete:focus-visible { opacity: 1; }
@media (hover: none) { .task-delete { opacity: 1; } }
.task-delete:hover { color: var(--danger); }
.empty { margin: 0; }
.task-add { display: flex; gap: 8px; }
.task-add input { flex: 1; }

/* Agenda */
.agenda { display: flex; flex-direction: column; gap: 18px; max-height: 520px; overflow-y: auto; padding-right: 4px; }
.agenda-day { display: flex; flex-direction: column; gap: 8px; }
.agenda-label { font-size: 13px; font-weight: 600; color: var(--soft); text-transform: uppercase; letter-spacing: 0.06em; }
.event { display: flex; gap: 12px; }
.event-time { width: 72px; flex: none; font-size: 14px; color: var(--soft); padding-top: 12px; }
.event-body { --c: var(--accent); flex: 1; min-width: 0; background: var(--card-2); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; }
.event-title::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 8px; vertical-align: middle; }
.event-title { font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }

/* Weather */
.weather { border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.weather-cool { background: #1A2433; color: #9DB8E0; }
.weather-warm { background: #2A2318; color: var(--accent); }
.weather-top { display: flex; justify-content: space-between; align-items: center; }
.weather-city { font-size: 17px; font-weight: 600; color: var(--text); }
.weather .muted { color: var(--soft); }
.weather-main { display: flex; align-items: baseline; gap: 10px; }
.weather-temp { font-size: 40px; font-weight: 500; color: var(--text); }
.weather-meta { display: flex; flex-wrap: wrap; gap: 16px; }

/* Mood */
.mood-now { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 0; }
.mood-value { font-size: 56px; font-weight: 500; }
.mood-scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.mood-btn { min-height: 48px; border-radius: 12px; font-family: var(--mono); font-size: 18px; cursor: pointer; background: var(--card-2); color: var(--soft); border: 1px solid #2A323E; }
.mood-btn:hover { border-color: var(--line-2); }
.mood-btn.is-active { color: var(--bg); border-color: transparent; font-weight: 600; }
.mood-history { display: flex; flex-direction: column; gap: 8px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 56px; }
.bar { flex: 1; height: 4px; border-radius: 4px; background: #2A323E; transition: height .3s ease; }

/* Backlinks */
a { color: var(--accent); text-decoration: none; }
a:hover { color: #F3CB7C; text-decoration: underline; }
.back { display: inline-block; font-size: 14px; margin-bottom: 8px; }
.notice { margin: 0; padding: 12px 16px; border-radius: 12px; background: #18302A; color: #8FE0C6; font-size: 15px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.last-article { flex: 1 1 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.card .stat { background: var(--card-2); border: 0; padding: 12px 14px; }
.card .stat-val { font-size: 22px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.stat-val { font-size: 26px; font-weight: 500; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; font-weight: 500; color: var(--muted); padding: 8px 10px 12px; }
.table td { border-top: 1px solid #232A35; padding: 12px 10px; vertical-align: top; }
.table .num { text-align: right; }
.cell-title { font-weight: 500; margin-bottom: 2px; }
.actions { display: flex; gap: 4px; justify-content: flex-end; }
.actions form { margin: 0; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line-2); background: transparent; color: var(--soft); font-size: 18px; cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--soft); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.badge { display: inline-flex; padding: 3px 10px; border-radius: 999px; font-size: 13px; background: #232A35; color: var(--soft); white-space: nowrap; }
.badge-ok { background: #18302A; color: #8FE0C6; }
.badge-bad { background: #3A1F1A; color: #F4B5A4; }
.dead { margin-top: 8px; font-size: 14px; }
.dead summary { cursor: pointer; color: #E8925F; }
.dead ul { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.dead li a { overflow-wrap: anywhere; }
textarea { width: 100%; padding: 12px 14px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line-2); color: var(--text); font: inherit; font-family: var(--mono); font-size: 14px; resize: vertical; }
.bl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.bl-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid #232A35; font-size: 15px; }
.bl-list li:first-child { border-top: 0; }
.bl-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 28px; }
.login-card p { margin: 0; }
.login-mark { width: 52px; height: 52px; border-radius: 16px; background: #2A2318; color: var(--accent); display: flex; align-items: center; justify-content: center; }
.form { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--soft); }
.form .check-label { flex-direction: row; align-items: flex-start; gap: 10px; color: var(--text); cursor: pointer; }
.check-label input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.alert { padding: 12px 14px; border-radius: 12px; background: #3A1F1A; color: #F4B5A4; font-size: 14px; }
