/* Cairn web portal */
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --sidebar: #eef0f4;
  --text: #1b1e24;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #3b82f6;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --overdue: #dc2626;
  --today: #d97706;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0,0,0,.12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216;
    --panel: #181b21;
    --sidebar: #14161b;
    --text: #e8eaee;
    --muted: #9aa1ac;
    --line: #262a32;
    --accent: #60a5fa;
    --accent-text: #0c1220;
    --danger: #f87171;
    --overdue: #f87171;
    --today: #fbbf24;
    --shadow: 0 10px 30px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.spacer { flex: 1; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea {
  font: inherit; color: var(--text);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.btn {
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 8px; padding: 8px 14px;
}
.btn:hover { filter: brightness(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
.btn.ghost { background: transparent; border-style: dashed; color: var(--muted); }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.danger-ghost, .btn.tiny.danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn.tiny { padding: 3px 10px; font-size: 13px; }
.icon-btn {
  background: transparent; border: none; border-radius: 8px;
  width: 34px; height: 34px; font-size: 17px; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--line); color: var(--text); }

/* ---------- login ---------- */
.login-screen {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 34px 30px; width: 340px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 7px;
}
.login-logo { font-size: 44px; text-align: center; }
.login-card h1 { margin: 0; text-align: center; font-size: 26px; }
.login-sub { margin: 0 0 14px; text-align: center; color: var(--muted); }
.login-card label { font-size: 13px; color: var(--muted); margin-top: 6px; }
.login-card .btn { margin-top: 16px; padding: 11px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 8px; text-align: center; }

/* ---------- layout ---------- */
.app { display: flex; height: 100dvh; }
.sidebar {
  width: 270px; flex-shrink: 0; background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 10px 10px;
}
.sidebar-head { display: flex; align-items: center; padding: 0 8px 12px; }
.brand { font-weight: 700; font-size: 17px; flex: 1; }
.close-sidebar { display: none; }
.list-nav { flex: 1; overflow-y: auto; }
.nav-section { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 14px 10px 5px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: transparent; border: none; border-radius: 9px;
  padding: 8px 10px; text-align: left; font-size: 15px;
}
.nav-item:hover { background: var(--line); }
.nav-item.active { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.nav-item .nav-icon { font-size: 17px; width: 22px; text-align: center; }
.nav-item .nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--line); border-radius: 20px; padding: 1px 8px; min-width: 14px; text-align: center;
}
.nav-item.active .badge { background: rgba(255,255,255,.25); color: inherit; }
.badge.overdue { background: var(--overdue); color: #fff; }
.new-list-btn { margin: 10px 4px 8px; }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  border-top: 1px solid var(--line); padding: 12px 8px 4px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent);
  color: var(--accent-text); font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.user-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.menu-btn { display: none; }
.list-title { font-size: 19px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { flex: 1; overflow-y: auto; padding: 18px clamp(14px, 4vw, 44px) 40px; }

/* ---------- add row ---------- */
.add-row { display: flex; gap: 8px; margin-bottom: 16px; max-width: 760px; }
.add-row input[type="date"] { width: 150px; flex-shrink: 0; color: var(--muted); }
.add-row .btn { flex-shrink: 0; }

/* ---------- items ---------- */
.items { list-style: none; margin: 0; padding: 0; max-width: 760px; }
.item {
  display: flex; align-items: flex-start; gap: 11px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 11px 13px; margin-bottom: 7px;
  cursor: pointer; transition: opacity .15s;
}
.item:hover { border-color: var(--accent); }
.item.done { opacity: .55; }
.item.done .item-text { text-decoration: line-through; color: var(--muted); }
.check {
  appearance: none; flex-shrink: 0; margin-top: 2px; padding: 0;
  width: 21px; height: 21px; border: 2px solid var(--muted); border-radius: 50%;
  cursor: pointer; display: grid; place-content: center; background: transparent;
}
.check:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after { content: "✓"; color: var(--accent-text); font-size: 13px; font-weight: 800; }
.item-body { flex: 1; min-width: 0; }
.item-text { overflow-wrap: anywhere; }
.item-sub { display: flex; gap: 8px; align-items: center; margin-top: 3px; flex-wrap: wrap; }
.due-chip { font-size: 12px; font-weight: 600; color: var(--muted); }
.due-chip.overdue { color: var(--overdue); }
.due-chip.today { color: var(--today); }
.note-hint { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 320px; }
.by-hint { font-size: 11px; color: var(--muted); opacity: .8; }

.completed-block { max-width: 760px; margin-top: 22px; }
.completed-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.completed-toggle {
  background: transparent; border: none; color: var(--muted); font-size: 13px; font-weight: 700;
  padding: 4px 6px; border-radius: 6px;
}
.completed-toggle:hover { background: var(--line); }

.empty-state { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty-emoji { font-size: 52px; margin-bottom: 8px; }

/* ---------- modals ---------- */
dialog {
  border: none; border-radius: 16px; background: var(--panel); color: var(--text);
  box-shadow: var(--shadow); padding: 0; width: min(430px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0,0,0,.45); }
.modal-form { display: flex; flex-direction: column; gap: 7px; padding: 24px; }
.modal-form h2 { margin: 0 0 8px; font-size: 19px; }
.modal-form h3 { margin: 16px 0 4px; font-size: 15px; }
.modal-form label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }
.hint-inline { font-weight: 400; opacity: .8; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; align-items: center; }

.emoji-row, .color-row { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-opt {
  font-size: 19px; width: 38px; height: 38px; border-radius: 9px;
  border: 1px solid var(--line); background: transparent;
}
.emoji-opt.sel { border: 2px solid var(--accent); background: var(--line); }
.color-opt { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; }
.color-opt.sel { border-color: var(--text); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { flex: 1; padding: 9px; background: transparent; border: none; }
.seg button.sel { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.due-edit-row { display: flex; gap: 8px; align-items: center; }

.user-list { list-style: none; margin: 4px 0; padding: 0; }
.user-list li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.user-list .u-name { flex: 1; }
.user-list .u-role { font-size: 11px; color: var(--muted); }
.add-user-row { display: flex; gap: 8px; margin-top: 8px; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); font-weight: 600;
  border-radius: 30px; padding: 10px 20px; box-shadow: var(--shadow);
  max-width: calc(100vw - 40px); z-index: 60;
}

/* ---------- mobile ---------- */
@media (max-width: 820px) {
  .sidebar {
    position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(300px, 84vw);
    transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .sidebar-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; display: none; }
  .sidebar-scrim.show { display: block; }
  .menu-btn, .close-sidebar { display: inline-flex; }
  .add-row { flex-wrap: wrap; }
  .add-row input[type="text"], .add-row #add-text { min-width: 100%; }
}
