:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f242d;
  --line: #2a313c;
  --text: #e6e9ef;
  --muted: #9aa4b2;
  --accent: #f5c542;
  --must: #e67c73;
  --ok: #0b8043;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 18px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; }
.brand span { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tabs button {
  background: transparent; color: var(--muted); border: 0; padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font-size: 14px;
}
.tabs button:hover { background: var(--panel-2); color: var(--text); }
.tabs button.active { background: var(--panel-2); color: var(--text); font-weight: 600; }
.status { color: var(--muted); font-size: 12px; min-width: 90px; text-align: right; }
.status.saving { color: var(--accent); }

main { max-width: 1000px; margin: 0 auto; padding: 22px 18px 80px; }
h1.view-title { font-size: 22px; margin: 4px 0 4px; }
.view-sub { color: var(--muted); margin: 0 0 18px; font-size: 13px; }

.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.btn:hover { border-color: #3a4350; }
.btn.primary { background: var(--accent); color: #1a1a1a; border-color: var(--accent); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--must); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px; position: relative; overflow: hidden;
}
.card .colorbar { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; }
.card.pad-left { padding-left: 18px; }

.cat-head { display: flex; align-items: center; gap: 10px; }
.swatch { width: 16px; height: 16px; border-radius: 4px; flex: none; border: 1px solid rgba(255,255,255,.15); }
.title { font-weight: 600; font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.pill.must { background: rgba(230,124,115,.15); color: var(--must); }
.pill.should { background: rgba(154,164,178,.15); color: var(--muted); }
.pill.star { background: rgba(245,197,66,.18); color: var(--accent); }

.group-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 0 8px; }

ul.list { list-style: none; padding: 0; margin: 8px 0 0; }
ul.list li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
ul.list li:first-child { border-top: 0; }
.check { width: 18px; height: 18px; cursor: pointer; accent-color: var(--ok); flex: none; }
.task-text { flex: 1; }
.task-text.done { text-decoration: line-through; color: var(--muted); }

table.today { width: 100%; border-collapse: collapse; }
table.today th, table.today td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.today th { color: var(--muted); font-weight: 500; font-size: 12px; }
.time-input { width: 110px; }

input, select, textarea {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 14px; font-family: inherit; width: 100%;
}
textarea { resize: vertical; min-height: 60px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: 480px; max-width: 100%; max-height: 88vh; overflow: auto; padding: 20px; }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.color-cell { height: 32px; border-radius: 8px; cursor: pointer; border: 2px solid transparent; }
.color-cell.sel { border-color: #fff; }
.color-cell.taken { opacity: .22; cursor: not-allowed; }
.maprow { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.maprow input[type=text] { flex: 1; }
.focus-bar { display:flex; gap:10px; align-items:center; background:var(--panel-2); border:1px solid var(--line); border-radius:10px; padding:10px 14px; margin-bottom:18px; flex-wrap:wrap; }
.day-card { padding-top: 12px; }
.day-card.today-card { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: linear-gradient(180deg, rgba(245,197,66,.06), transparent 60%); }
.day-card.today-card .title { color: var(--accent); }

/* ---------- Month calendar grid ---------- */
.cal-grid { display: grid; grid-template-columns: 40px repeat(7, 1fr); gap: 6px; }
.cal-head { text-align: center; font-size: 11px; letter-spacing: .05em; color: var(--muted); text-transform: uppercase; padding: 6px 0 2px; }
.cal-kw {
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--accent);
  cursor: pointer; border-radius: 8px; transition: background .12s ease;
}
.cal-kw:hover { background: var(--panel-2); }
.cal-cell {
  display: flex; flex-direction: column; gap: 6px; min-height: 76px; padding: 8px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  cursor: pointer; transition: border-color .12s ease, background .12s ease, transform .06s ease;
}
.cal-cell:hover { border-color: #3a4350; background: var(--panel-2); }
.cal-cell:active { transform: translateY(1px); }
.cal-cell.out { opacity: .4; }
.cal-cell.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: linear-gradient(180deg, rgba(245,197,66,.08), transparent 60%); }
.cal-daynum { font-weight: 700; font-size: 15px; line-height: 1; }
.cal-cell.today .cal-daynum { color: var(--accent); }
.cal-count { align-self: flex-start; }

/* ---------- Keyboard focus visibility (a11y) ---------- */
.btn:focus-visible, .tabs button:focus-visible, .cal-cell:focus-visible, .cal-kw:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible, .check:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

@media (max-width: 560px) {
  .cal-grid { grid-template-columns: 26px repeat(7, 1fr); gap: 3px; }
  .cal-cell { min-height: 52px; padding: 5px; gap: 3px; }
  .cal-daynum { font-size: 13px; }
  .cal-head { font-size: 10px; }
}

/* Shared tab: notification badge (lights up when others shared something new) */
.tab-badge {
  display: inline-block; background: var(--accent); color: #1a1a1a;
  border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700;
  line-height: 16px; vertical-align: middle;
}
#tabs button.has-news { color: var(--accent); }

/* Help button (top right) */
.help-btn {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  border: 1px solid var(--accent); background: var(--accent); color: #1a1a1a;
  cursor: pointer; font-weight: 700; font-size: 14px; line-height: 1; margin: 0 10px;
}
.help-btn:hover { filter: brightness(1.15); }

/* User chip in the top bar (name from registration + sign out) */
.user-chip { display: flex; align-items: center; gap: 8px; flex: none; }
.user-chip .user-name {
  font-size: 13px; color: var(--text); background: var(--panel-2);
  border-radius: 999px; padding: 4px 12px; white-space: nowrap;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis;
}
