:root {
  --bg: #0b0f14;
  --panel: #131a22;
  --panel-2: #1b2530;
  --text: #e6edf3;
  --muted: #8b97a4;
  --accent: #7cc4ff;
  --user: #1f6feb;
  --error: #ff6b6b;
  --line: #1e2731;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(env(safe-area-inset-top), 12px) 16px 12px;
  border-bottom: 1px solid var(--line);
}
.title { font-weight: 700; letter-spacing: 0.02em; }
.icon-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid #263039;
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 14px;
}

.views { flex: 1; position: relative; overflow: hidden; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; }
.view[hidden] { display: none; }
.scroll-view { overflow-y: auto; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }

/* chat */
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: var(--radius); white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--user); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid #202a34; border-bottom-left-radius: 4px; }
.msg.error { border-color: var(--error); color: var(--error); }
.composer { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
#input {
  flex: 1; resize: none; background: var(--panel-2); color: var(--text);
  border: 1px solid #263039; border-radius: 12px; padding: 12px 14px; font: inherit; max-height: 160px;
}
#input:focus { outline: none; border-color: var(--accent); }
#send { background: var(--accent); color: #05202f; border: none; border-radius: 12px; padding: 0 18px; font-weight: 700; }

/* todo */
.cat-head { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; margin: 16px 4px 6px; }
.cat-head:first-child { margin-top: 4px; }
.todo-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid #202a34; border-radius: 12px;
  padding: 10px 12px; margin-bottom: 8px;
}
.todo-row .check {
  background: transparent; border: none; color: var(--accent); font-size: 22px; line-height: 1; padding: 0; width: 28px;
}
.todo-row .todo-text { flex: 1; }
.todo-row.done .todo-text { color: var(--muted); text-decoration: line-through; }
.todo-row .del { background: transparent; border: none; color: var(--muted); font-size: 22px; line-height: 1; width: 28px; }
.add-task { display: flex; gap: 8px; margin-top: 14px; }
.add-task input {
  background: var(--panel-2); color: var(--text); border: 1px solid #263039; border-radius: 10px; padding: 10px 12px; font: inherit;
}
.add-task #addText { flex: 2; }
.add-task #addCat { flex: 1; min-width: 0; }
.add-task button { background: var(--accent); color: #05202f; border: none; border-radius: 10px; padding: 0 16px; font-weight: 700; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* calendar */
.cal-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seg { display: flex; border: 1px solid #263039; border-radius: 10px; overflow: hidden; margin-right: auto; }
.segbtn { background: var(--panel-2); color: var(--muted); border: none; padding: 8px 14px; font: inherit; }
.segbtn.active { background: var(--accent); color: #05202f; font-weight: 700; }
.navbtn { background: var(--panel-2); color: var(--text); border: 1px solid #263039; border-radius: 10px; padding: 8px 12px; font: inherit; min-width: 40px; }
.cal-date { color: var(--muted); font-weight: 600; margin: 10px 2px 12px; }
.cal-row { display: flex; gap: 12px; background: var(--panel); border: 1px solid #202a34; border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.cal-time { color: var(--accent); font-variant-numeric: tabular-nums; font-size: 14px; white-space: pre; min-width: 52px; }
.cal-title { font-weight: 600; }
.cal-notes { color: var(--muted); font-size: 14px; margin-top: 2px; }
.day-head { color: var(--text); font-weight: 700; font-size: 14px; margin: 16px 2px 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.day-head.is-today { color: var(--accent); }
.day-empty { color: var(--muted); font-size: 14px; margin: 0 2px 8px; }

/* tab bar */
.tabbar {
  display: flex; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: transparent; border: none; color: var(--muted);
  padding: 12px 0; font: inherit; font-size: 14px;
}
.tab.active { color: var(--accent); font-weight: 700; }

/* settings dialog */
dialog { background: var(--panel); color: var(--text); border: 1px solid #263039; border-radius: 16px; padding: 20px; width: min(92vw, 420px); }
dialog::backdrop { background: rgba(0,0,0,0.6); }
.settings-form h2 { margin: 0 0 12px; font-size: 18px; }
.settings-form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.settings-form input {
  display: block; width: 100%; margin-top: 6px; background: var(--panel-2); color: var(--text);
  border: 1px solid #263039; border-radius: 10px; padding: 10px 12px; font: inherit;
}
.row { display: flex; gap: 8px; justify-content: flex-end; }
.row button { border-radius: 10px; padding: 9px 16px; border: 1px solid #263039; background: var(--panel-2); color: var(--text); font: inherit; }
.row button.primary { background: var(--accent); color: #05202f; border: none; font-weight: 700; }
