/* Token thương hiệu Thinking School (tks-brand). Font tải ngoài bị CSP chặn → dùng font hệ thống dự phòng. */
:root {
  --paper: #ffffff; --paper-2: #f3f5fa; --line: #d7dce8; --ink: #0a0a0b; --ink-muted: #4a5163;
  --tks-blue: #0041ff; --on-blue: #ffffff; --blue-night: #0013a0; --blue-tint: #e8eeff;
  --insight: #ffb21a; --success: #0b7a43; --danger: #c8211f; --focus-ring: #0041ff;
  --font-sans: "Be Vietnam Pro", system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  --radius-sm: 4px; --radius-md: 8px; --radius-pill: 999px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0b0d14; --paper-2: #141826; --line: #2a3044; --ink: #f3f5fa; --ink-muted: #a8b0c4;
    --tks-blue: #5c85ff; --on-blue: #0b0d14; --blue-tint: #131d45; --insight: #ffc24d;
    --success: #4cc38a; --danger: #ff6b61; --focus-ring: #9db4ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0b0d14; --paper-2: #141826; --line: #2a3044; --ink: #f3f5fa; --ink-muted: #a8b0c4;
  --tks-blue: #5c85ff; --on-blue: #0b0d14; --blue-tint: #131d45; --insight: #ffc24d;
  --success: #4cc38a; --danger: #ff6b61; --focus-ring: #9db4ff; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper-2); color: var(--ink); font: 15px/1.5 var(--font-sans); padding-bottom: 96px; }
[hidden] { display: none !important; }
h1 { font-size: 24px; margin: 0 0 8px; font-weight: 800; }
h2 { font-size: 18px; margin: 0 0 8px; font-weight: 700; }
h3 { font-size: 15px; margin: 16px 0 6px; font-weight: 700; }
.muted { color: var(--ink-muted); }
.small { font-size: 13px; }
.error { color: var(--danger); min-height: 1.5em; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.brand img { border-radius: 6px; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-muted); }

main { max-width: 920px; margin: 0 auto; padding: 16px; }
.login { max-width: 380px; margin: 40px auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 24px; }

label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 0; }
label > input, label > textarea, label > select { margin-top: 4px; }
input, textarea, select { width: 100%; font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 10px; min-height: 42px; }
textarea { min-height: 84px; resize: vertical; }
textarea.tall { min-height: 160px; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.hint { font-weight: 400; color: var(--ink-muted); font-size: 12px; display: block; }

button { font: inherit; cursor: pointer; border-radius: var(--radius-sm); min-height: 40px; padding: 8px 14px; }
button.primary { background: var(--tks-blue); color: var(--on-blue); border: 1px solid var(--tks-blue); font-weight: 700; }
button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
button.link { background: none; border: 0; color: var(--tks-blue); padding: 4px; min-height: 0; text-decoration: underline; }
button:disabled { opacity: .5; cursor: not-allowed; }
.login button.primary { width: 100%; margin-top: 16px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > input, .row > select { flex: 1 1 160px; width: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 0 -16px 16px; padding: 0 16px; scrollbar-width: none; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; border-radius: 0; white-space: nowrap; color: var(--ink-muted); font-weight: 600; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--tks-blue); }

.notice { border-left: 4px solid var(--insight); background: var(--paper); padding: 10px 12px; margin-bottom: 12px; border-radius: var(--radius-sm); }
.notice.ok { border-left-color: var(--success); }
.notice.err { border-left-color: var(--danger); }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-head .title { font-weight: 700; }
.id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--ink-muted); word-break: break-all; }
.section-intro { margin: 0 0 12px; color: var(--ink-muted); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list select { width: auto; min-height: 36px; padding: 4px 8px; }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; border-radius: var(--radius-pill); padding: 2px 10px; border: 1px solid var(--line); white-space: nowrap; }
.chip.on { background: var(--blue-tint); color: var(--tks-blue); border-color: transparent; }
.chip.ok { color: var(--success); border-color: currentColor; }
.chip.warn { color: var(--ink); background: var(--insight); border-color: transparent; }
.chip.bad { color: var(--danger); border-color: currentColor; }

.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 10px 0 0; cursor: pointer; }
.switch input { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--tks-blue); flex: none; }
.days { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.days label { margin: 0; font-weight: 500; display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 4px 10px; }
.days input { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--tks-blue); }

details.group > summary { list-style: none; cursor: pointer; }
details.group > summary::-webkit-details-marker { display: none; }
details.group[open] > summary { border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 4px; }
.test-out { white-space: pre-wrap; background: var(--paper-2); border-radius: var(--radius-sm); padding: 10px; margin-top: 8px; }
.post-body { white-space: pre-wrap; background: var(--paper-2); border-radius: var(--radius-sm); padding: 10px; margin: 8px 0; max-height: 240px; overflow: auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); }

dialog { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 0; width: min(560px, 100vw - 24px); max-height: 86vh; background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgba(0, 19, 160, .25); }
.picker { padding: 16px; display: flex; flex-direction: column; gap: 8px; max-height: 86vh; }
.picker-head { display: flex; justify-content: space-between; align-items: center; }
.pick-list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; min-height: 120px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.pick-list li button { width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; color: var(--ink); display: flex; justify-content: space-between; gap: 8px; }
.pick-list li button:hover { background: var(--blue-tint); }
.pick-list li.taken button { opacity: .5; }
.manual summary { cursor: pointer; color: var(--tks-blue); font-size: 13px; }
.manual .row { margin-top: 8px; }
