/* Notely web — bảng màu của app, sáng/tối, 3 cột trên máy tính, 1 cột trên điện thoại. */

:root {
  --ink: #1C1B19;
  --on-ink: #FAF8F4;
  --accent: #8A6A3B;
  --paper: #F5F2EC;
  --surface: #FFFFFF;
  --raised: #FBFAF7;
  --hairline: #E4DFD6;
  --muted: #8A857C;
  --red: #B8483D;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --ink-soft: color-mix(in srgb, var(--ink) 6%, transparent);
  --shadow: 0 1px 2px rgba(28, 27, 25, .05), 0 8px 28px rgba(28, 27, 25, .08);
  --serif: "New York", "Iowan Old Style", Georgia, "Noto Serif", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #F2EEE7; --on-ink: #151413; --accent: #CBAA6E; --paper: #0E0E0F; --surface: #1A1A1C;
    --raised: #232325; --hairline: #2E2D2B; --muted: #8E8A83; --red: #D8665A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 32px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #F2EEE7; --on-ink: #151413; --accent: #CBAA6E; --paper: #0E0E0F; --surface: #1A1A1C;
  --raised: #232325; --hairline: #2E2D2B; --muted: #8E8A83; --red: #D8665A;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 32px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; border-radius: 6px; }

.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.boot img { border-radius: 14px; opacity: .85; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* Nút */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink);
  font-weight: 500; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--raised); }
.btn.primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn.primary:hover { opacity: .9; }
.btn.accent { background: var(--accent); color: var(--on-ink); border-color: var(--accent); }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn.block { width: 100%; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { color: var(--accent); font-size: 14px; }
.link:hover { text-decoration: underline; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; display: inline-grid; place-items: center;
  color: var(--muted); flex: none; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--ink-soft); color: var(--ink); }
.icon-btn.accent { color: var(--accent); }
.icon-btn.on { color: var(--accent); }
.spacer { flex: 1; }

/* Đăng nhập */
.auth { position: fixed; inset: 0; overflow: auto; display: grid; place-items: center; padding: 32px 16px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 18px; padding: 32px 28px 24px; box-shadow: var(--shadow); text-align: center;
}
.auth-logo { border-radius: 15px; display: block; margin: 0 auto 12px; }
.auth-title { font: 600 30px/1.1 var(--serif); margin: 0 0 6px; letter-spacing: -.01em; }
.auth-sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.auth form { text-align: left; display: grid; gap: 14px; }
.auth-links { display: flex; justify-content: center; gap: 16px; min-height: 20px; }
.auth-foot { color: var(--muted); font-size: 12.5px; margin: 18px 0 0; }

.seg { display: flex; padding: 3px; background: var(--paper); border: 1px solid var(--hairline); border-radius: 10px; margin-bottom: 18px; }
.seg button { flex: 1; height: 32px; border-radius: 7px; color: var(--muted); font-size: 14px; font-weight: 500; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }
.field input, .field select, .input {
  height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--hairline);
  background: var(--raised); outline: none; width: 100%; min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-error { color: var(--red); font-size: 13.5px; margin: 0; }
.form-info { color: var(--muted); font-size: 13.5px; margin: 0; }
.check-row { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink); }
.check-row input { accent-color: var(--accent); width: 16px; height: 16px; }

/* Bố cục 3 cột */
.app {
  height: 100%; height: 100dvh;
  display: grid; grid-template-columns: 248px minmax(300px, 360px) 1fr;
}
.sidebar {
  background: var(--paper); border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.pane { min-width: 0; min-height: 0; }
.list { background: var(--raised); border-right: 1px solid var(--hairline); display: flex; flex-direction: column; }
.editor { background: var(--surface); display: flex; flex-direction: column; overflow: hidden; }
.scrim { display: none; }
.only-narrow { display: none; }

/* Thanh bên */
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 10px; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.brand b { font: 600 20px/1 var(--serif); letter-spacing: -.01em; }
.side-scroll { flex: 1; overflow: auto; padding: 6px 10px 12px; }
.side-new { margin: 6px 10px 8px; }
.side-new .btn { width: 100%; justify-content: flex-start; }
.nav-h { display: flex; align-items: center; justify-content: space-between; margin: 18px 8px 4px; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.nav-h .icon-btn { width: 24px; height: 24px; border-radius: 6px; }
.nav-h .icon-btn svg { width: 15px; height: 15px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px;
  border-radius: 8px; color: var(--ink); text-align: left; font-size: 14.5px;
}
.nav-item svg { color: var(--muted); flex: none; }
.nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.nav-item:hover { background: var(--ink-soft); }
.nav-item[aria-current="true"] { background: var(--accent-soft); }
.nav-item[aria-current="true"] svg, .nav-item[aria-current="true"] .label { color: var(--accent); }
.nav-item[aria-current="true"] .label { font-weight: 600; }
.nav-empty { color: var(--muted); font-size: 13px; padding: 2px 10px; }
.side-foot {
  border-top: 1px solid var(--hairline); padding: 10px 12px; display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--muted);
}
.side-foot .status { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; overflow: hidden; }
.side-foot .status span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .status svg { width: 15px; height: 15px; flex: none; }
.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Danh sách */
.list-head { padding: 14px 14px 10px; display: grid; gap: 10px; border-bottom: 1px solid var(--hairline); }
.list-head .row { display: flex; align-items: center; gap: 4px; }
.list-title { font: 600 21px/1.2 var(--serif); margin: 0 0 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -.01em; }
.search {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--hairline);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-ico { color: var(--muted); display: grid; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; height: 100%; }
.search input::-webkit-search-cancel-button { filter: grayscale(1); opacity: .5; }
.search kbd { font: 11px var(--sans); color: var(--muted); border: 1px solid var(--hairline); border-radius: 5px; padding: 1px 5px; }

.notices:empty { display: none; }
.notices { padding: 10px 12px 0; display: grid; gap: 8px; }
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-size: 13px;
  background: var(--accent-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.notice.warn { background: color-mix(in srgb, var(--red) 9%, transparent); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.notice p { margin: 0; flex: 1; }
.notice .link { font-size: 13px; white-space: nowrap; }

.notes { flex: 1; overflow: auto; padding: 4px 12px 24px; overscroll-behavior: contain; }
.group-h { font-size: 12px; font-weight: 600; color: var(--muted); margin: 16px 6px 6px; letter-spacing: .02em; }
.card {
  display: block; width: 100%; text-align: left; padding: 12px 14px; margin-bottom: 6px;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--hairline)); }
.card[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.card-title { display: flex; gap: 6px; align-items: baseline; font-weight: 600; font-size: 15px; line-height: 1.35; }
.card-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.card-title svg { width: 13px; height: 13px; color: var(--accent); flex: none; align-self: center; }
.card-snippet {
  color: var(--muted); font-size: 13.5px; margin-top: 3px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); min-width: 0; }
.card-meta .date { flex: none; font-variant-numeric: tabular-nums; }
.card-meta .nb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 45%; }
.card-meta .tags { display: flex; gap: 4px; overflow: hidden; min-width: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 999px;
  background: var(--ink-soft); color: var(--muted); font-size: 11.5px; white-space: nowrap;
}
.empty { text-align: center; color: var(--muted); padding: 56px 20px; font-size: 14px; }
.empty h3 { font: 600 18px var(--serif); color: var(--ink); margin: 0 0 6px; }

/* Trình soạn thảo */
.ed-bar {
  display: flex; align-items: center; gap: 4px; padding: 10px 14px; border-bottom: 1px solid var(--hairline);
  min-height: 55px; flex-wrap: nowrap;
}
.ed-bar .meta { color: var(--muted); font-size: 12.5px; margin-right: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.nb-pick {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 8px;
  color: var(--muted); font-size: 13.5px; max-width: 220px; min-width: 0;
}
.nb-pick:hover { background: var(--ink-soft); color: var(--ink); }
.nb-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-scroll { flex: 1; overflow: auto; }
.ed-inner { max-width: 760px; margin: 0 auto; padding: 32px 40px 120px; }
.ed-title {
  display: block; width: 100%; border: 0; outline: 0; resize: none; background: none; overflow: hidden;
  font: 600 30px/1.25 var(--serif); letter-spacing: -.015em; padding: 0; margin: 0 0 6px;
}
.ed-title::placeholder, .ed-body::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.ed-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0 18px; }
.ed-tags .chip { height: 24px; font-size: 12.5px; padding: 0 4px 0 9px; }
.ed-tags .chip button { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
.ed-tags .chip button:hover { background: var(--ink-soft); color: var(--ink); }
.ed-tags .chip button svg { width: 12px; height: 12px; }
.ed-tags input {
  border: 0; outline: 0; background: none; font-size: 13px; color: var(--muted); width: 120px; height: 24px; padding: 0 4px;
}
.ed-tags input:focus { color: var(--ink); }
.ed-body {
  display: block; width: 100%; min-height: 50vh; border: 0; outline: 0; resize: none; background: none; padding: 0;
  font: 16px/1.7 var(--sans); overflow: hidden; tab-size: 4;
}
.ed-locked { text-align: center; padding: 80px 20px; color: var(--muted); }
.ed-locked h3 { font: 600 22px var(--serif); color: var(--ink); margin: 10px 0 6px; }
.ed-locked .big { font-size: 40px; }
.ed-banner {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 14px; margin: 0 0 20px;
  border-radius: 10px; background: color-mix(in srgb, var(--red) 8%, transparent); color: var(--ink); font-size: 14px;
}
.ed-banner p { margin: 0; flex: 1; min-width: 160px; }
.ed-empty { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 24px; }
.ed-empty img { width: 56px; height: 56px; border-radius: 14px; opacity: .9; }
.ed-empty h3 { font: 600 20px var(--serif); color: var(--ink); margin: 14px 0 4px; }
.ed-empty p { margin: 0 0 16px; font-size: 14px; }
.kbd-hints { font-size: 12.5px; color: var(--muted); margin-top: 12px; }
.kbd-hints kbd { font: 11px var(--sans); border: 1px solid var(--hairline); border-radius: 5px; padding: 1px 5px; }

/* Markdown */
.md { font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; cursor: text; min-height: 40vh; }
.md.placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.md > :first-child { margin-top: 0; }
.md p { margin: 0 0 .8em; }
.md h2, .md h3, .md h4 { font-family: var(--serif); font-weight: 600; line-height: 1.3; letter-spacing: -.01em; margin: 1.3em 0 .45em; }
.md h2 { font-size: 24px; } .md h3 { font-size: 20px; } .md h4 { font-size: 17px; }
.md ul, .md ol { margin: 0 0 .8em; padding-left: 1.5em; }
.md li { margin: .15em 0; }
.md li::marker { color: var(--muted); }
.md ul.checklist { list-style: none; padding-left: 0; }
.md li.check { display: flex; gap: 10px; align-items: flex-start; }
.md li.check .box {
  width: 18px; height: 18px; margin-top: 4px; flex: none; border-radius: 5px;
  border: 1.5px solid color-mix(in srgb, var(--muted) 80%, transparent); display: grid; place-items: center;
}
.md li.check .box:hover { border-color: var(--accent); }
.md li.check.done .box { background: var(--accent); border-color: var(--accent); }
.md li.check.done .box::after { content: ""; width: 9px; height: 5px; border: 2px solid var(--on-ink); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.md li.check.done > span { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.md blockquote { margin: 0 0 .8em; padding: 2px 0 2px 14px; border-left: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--hairline); margin: 1.4em 0; }
.md a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 2px; }
.md code { font: .9em var(--mono); background: var(--ink-soft); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--raised); border: 1px solid var(--hairline); border-radius: 10px; padding: 12px 14px; overflow: auto; }
.md pre code { background: none; padding: 0; }
.md strong { font-weight: 650; }

/* Menu & hộp thoại */
.menu {
  position: fixed; z-index: 50; min-width: 200px; max-width: calc(100vw - 32px); max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px; box-shadow: var(--shadow); padding: 5px;
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; border-radius: 7px; text-align: left; font-size: 14px;
}
.menu button:hover, .menu button:focus-visible { background: var(--ink-soft); outline: none; }
.menu button svg { color: var(--muted); }
.menu button.danger { color: var(--red); }
.menu button.danger svg { color: var(--red); }
.menu button .tick { margin-left: auto; color: var(--accent); }
.menu hr { border: 0; border-top: 1px solid var(--hairline); margin: 5px 4px; }
.menu .menu-h { font-size: 11.5px; color: var(--muted); padding: 6px 10px 2px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }

.modal {
  border: 1px solid var(--hairline); border-radius: 16px; padding: 0; background: var(--surface); color: var(--ink);
  width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(14, 14, 15, .38); backdrop-filter: blur(2px); }
.modal form, .modal .m-wrap { display: grid; gap: 14px; padding: 22px; }
.modal h3 { font: 600 21px/1.25 var(--serif); margin: 0; letter-spacing: -.01em; }
.modal p { margin: 0; color: var(--muted); font-size: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.modal.wide { width: min(560px, calc(100vw - 32px)); }
.code-box {
  font: 600 18px/1.4 var(--mono); letter-spacing: .06em; text-align: center; padding: 14px; border-radius: 10px;
  background: var(--raised); border: 1px dashed var(--accent); color: var(--ink); user-select: all; overflow-wrap: anywhere;
}

/* Cài đặt */
.set-sec { border-top: 1px solid var(--hairline); padding-top: 14px; display: grid; gap: 10px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; flex-wrap: wrap; }
.set-row .k { color: var(--muted); }
.set-row .v { font-weight: 500; overflow-wrap: anywhere; text-align: right; }
.set-h { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.usage { display: grid; gap: 4px; font-size: 13px; }
.usage .top { display: flex; justify-content: space-between; gap: 8px; }
.usage .top span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 999px; background: var(--ink-soft); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.bar i.full { background: var(--red); }
.plan-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13px; }
.seg.small { margin: 0; }
.seg.small button { height: 28px; font-size: 13px; padding: 0 12px; white-space: nowrap; flex: none; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: var(--shadow); transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Máy tính bảng: thanh bên thành ngăn kéo */
@media (max-width: 1099px) {
  .app { grid-template-columns: minmax(280px, 340px) 1fr; }
  .only-narrow { display: inline-grid; }
  .sidebar {
    position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: min(280px, 86vw);
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow);
  }
  .app.drawer .sidebar { transform: none; }
  .app.drawer .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(14, 14, 15, .3); }
}

/* Điện thoại: một cột */
@media (max-width: 759px) {
  body { font-size: 16px; }
  .app { grid-template-columns: 100%; }
  .list, .editor { grid-column: 1; grid-row: 1; border-right: 0; }
  .app[data-view="list"] .editor { display: none; }
  .app[data-view="editor"] .list { display: none; }
  .list-head { padding: 12px 16px 10px; }
  .notes { padding: 4px 16px 32px; }
  .notices { padding: 10px 16px 0; }
  .ed-bar { padding: 8px 10px; }
  .ed-inner { padding: 20px 16px 120px; }
  .ed-title { font-size: 26px; }
  .search kbd { display: none; }
  .ed-bar .meta { display: none; }
  .nb-pick { max-width: 140px; }
  .modal form, .modal .m-wrap { padding: 18px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.only-phone { display: none; }
@media (max-width: 759px) { .only-phone { display: inline-grid; } }

/* ——— Tính năng mới: tệp đính kèm, AI, tạo nhanh, Hỏi Notely ——— */
.toast.has-action { pointer-events: auto; display: flex; align-items: center; gap: 14px; }
.toast-btn { color: var(--accent); font-weight: 600; font-size: 14px; }
:root:not([data-theme="light"]) .toast-btn { color: color-mix(in srgb, var(--accent) 80%, var(--on-ink)); }
.hint { color: var(--muted); font-size: 12.5px; margin: 0; }
.chip.big { height: 28px; padding: 0 11px; font-size: 13px; color: var(--ink); background: var(--surface); border: 1px solid var(--hairline); cursor: pointer; }
.chip.big:hover { border-color: var(--accent); }
.chip.big svg { width: 14px; height: 14px; color: var(--muted); }

.card-meta .prog, .card-meta .files { display: inline-flex; align-items: center; gap: 3px; flex: none; font-variant-numeric: tabular-nums; }
.card-meta .prog svg, .card-meta .files svg { width: 12px; height: 12px; }
.card-meta .prog.full { color: var(--accent); }

/* Tệp đính kèm */
.att { margin: 22px 0 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.att-thumb {
  aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--hairline); background: var(--raised);
  display: grid; place-items: center; color: var(--muted);
}
.att-thumb:hover { border-color: var(--accent); }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-thumb .ph { display: grid; justify-items: center; gap: 4px; padding: 6px; text-align: center; }
.att-thumb .ph small { font-size: 11px; line-height: 1.3; }
.att-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 12px; border-radius: 10px;
  border: 1px solid var(--hairline); background: var(--raised);
}
.att-ico { width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.att-main { flex: 1; min-width: 0; cursor: pointer; }
.att-name { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-meta { color: var(--muted); font-size: 12.5px; }
.att-audio audio { width: 100%; max-width: 420px; height: 36px; margin-top: 6px; }
.att-note { color: var(--muted); font-size: 12.5px; margin: 2px 0 0; }
.att-note.warn { color: var(--red); }
.att-text { white-space: pre-wrap; font: 13.5px/1.55 var(--sans); max-height: 50vh; overflow: auto; background: var(--raised); border: 1px solid var(--hairline); border-radius: 10px; padding: 12px; margin: 0; }
.app.dragging .editor, .app.dragging .list { outline: 2px dashed color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: -8px; }

.viewer-modal { width: min(980px, calc(100vw - 32px)); }
.viewer { gap: 10px !important; }
.v-head { display: flex; align-items: center; gap: 4px; }
.v-head .v-t { flex: 1; min-width: 0; }
.v-head h3 { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-head p { font-size: 12.5px; }
.v-head .icon-btn:disabled { opacity: .35; cursor: default; }
.v-body { min-height: 200px; max-height: calc(100dvh - 170px); display: grid; place-items: center; background: var(--raised); border-radius: 10px; overflow: auto; }
.v-body img { max-width: 100%; max-height: calc(100dvh - 170px); object-fit: contain; display: block; }
.v-body iframe { width: 100%; height: calc(100dvh - 180px); border: 0; background: #fff; }
.v-body audio { width: min(480px, 90%); }
.v-loading { color: var(--muted); padding: 40px; text-align: center; font-size: 14px; }

/* Bảng AI dưới ghi chú */
.ai-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 22px; }
.ai-panel > *, .att > * { min-width: 0; }
.ai-panel:empty { display: none; }
.ai-btn { justify-self: start; color: var(--accent); }
.ai-btn svg { color: var(--accent); }
.ev-card, .dg, .sugg {
  border-radius: 14px; border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--hairline));
  background: color-mix(in srgb, var(--accent) 6%, var(--surface)); padding: 12px 14px;
}
.ev-h, .dg-h { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.ev-h svg, .dg-h svg { width: 15px; height: 15px; }
.dg-h .icon-btn { width: 28px; height: 28px; }
.ev-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.ev-row + .ev-row { border-top: 1px solid var(--hairline); }
.ev-date { width: 42px; height: 42px; border-radius: 9px; background: var(--surface); border: 1px solid var(--hairline); display: grid; place-items: center; align-content: center; flex: none; line-height: 1.05; }
.ev-date small { font-size: 9px; font-weight: 700; color: var(--red); }
.ev-date b { font-size: 18px; font-weight: 600; }
.ev-main { flex: 1; min-width: 0; }
.ev-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-time { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-added { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-size: 12.5px; font-weight: 600; }
.ev-added svg { width: 14px; height: 14px; }
.dg-sum { font: italic 17px/1.45 var(--serif); color: var(--muted); margin: 0 0 8px; }
.dg-stale { color: var(--accent); font-size: 12.5px; margin: 0 0 8px; }
.dg-sec { background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px; padding: 10px 14px; margin-top: 8px; }
.dg-st { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.dg-sec.hot .dg-st { color: var(--accent); }
.dg-sec ul { margin: 0; padding-left: 1.2em; font-size: 14.5px; line-height: 1.55; }
.dg-sec li.task { list-style: "○  "; }
.dg.loading { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.dg.loading svg { color: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.sugg { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.sugg > svg { color: var(--accent); flex: none; }
.sugg-main { flex: 1; min-width: 160px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.backlinks { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.backlinks .set-h { width: 100%; }
.ed-foot { margin-top: 28px; color: var(--muted); font-size: 12.5px; }
.md a.wikilink { text-decoration-style: dashed; }
.ai-preview { max-height: 55vh; overflow: auto; border: 1px solid var(--hairline); border-radius: 12px; padding: 14px 16px; background: var(--raised); }
.ai-preview h4 { font: 600 19px/1.3 var(--serif); margin: 0 0 8px; }
.ai-preview .md { min-height: 0; cursor: auto; font-size: 15px; }
.steps { margin: 0; padding-left: 1.2em; color: var(--muted); font-size: 14px; display: grid; gap: 4px; }
.steps li::marker { color: var(--accent); }

/* Đọc chính tả */
.dictate { justify-items: stretch; }
.dictate .seg { justify-self: center; }
.mic-btn {
  justify-self: center; width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: var(--on-ink); box-shadow: var(--shadow); transition: transform .15s, background .15s;
}
.mic-btn svg { width: 28px; height: 28px; }
.mic-btn.on { background: var(--red); color: #fff; animation: pulse 1.6s ease-in-out infinite; }
.d-state { text-align: center; }
.d-text { height: auto; min-height: 120px; padding: 10px 12px; resize: vertical; line-height: 1.55; }

/* Hỏi Notely */
.ask-modal { width: min(720px, calc(100vw - 32px)); height: min(760px, calc(100dvh - 48px)); }
.ask-modal .ask { height: 100%; grid-template-rows: auto 1fr auto auto; }
.ask-head { display: flex; align-items: center; gap: 6px; }
.ask-log { overflow: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; min-height: 0; }
.ask-empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.ask-empty h4 { font: 600 20px var(--serif); color: var(--ink); margin: 0 0 6px; }
.ask-empty p { margin: 0 auto 16px; max-width: 420px; }
.ask-sugg { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 14px; font-size: 14.5px; line-height: 1.55; }
.msg.me { align-self: flex-end; background: var(--ink); color: var(--on-ink); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: var(--raised); border: 1px solid var(--hairline); border-bottom-left-radius: 4px; }
.msg.bot .md { min-height: 0; font-size: 14.5px; cursor: auto; }
.msg.bot .md p:last-child { margin-bottom: 0; }
.msg.err { border-color: color-mix(in srgb, var(--red) 35%, transparent); color: var(--red); }
.msg.thinking { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.msg.thinking svg { color: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.src { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.src > span { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.ask-input { display: flex !important; gap: 8px; align-items: flex-end; padding: 0 !important; border: 1px solid var(--hairline); border-radius: 12px; background: var(--raised); }
.ask-input textarea { flex: 1; border: 0; outline: 0; background: none; resize: none; padding: 10px 12px; min-height: 42px; max-height: 160px; line-height: 1.45; }
.ask-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ask-input .icon-btn { margin: 4px; }

/* Cài đặt: bảng gói, phím tắt */
.plans { overflow-x: auto; border: 1px solid var(--hairline); border-radius: 10px; }
.plans table { width: 100%; border-collapse: collapse; font-size: 13px; }
.plans th, .plans td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
.plans tr:last-child td { border-bottom: 0; }
.plans th { font-weight: 600; }
.plans th small { display: block; font-weight: 500; color: var(--accent); font-size: 11px; }
.plans td:first-child { color: var(--muted); }
.plans .cur { background: var(--accent-soft); }
.upgrade { font-size: 13.5px !important; color: var(--ink) !important; font-weight: 500; }
.keys { border-collapse: collapse; font-size: 14px; }
.keys td { padding: 5px 10px 5px 0; }
.keys kbd { font: 12px var(--sans); border: 1px solid var(--hairline); border-radius: 6px; padding: 2px 7px; background: var(--raised); white-space: nowrap; }
@media (max-width: 759px) {
  .att-grid { grid-template-columns: repeat(3, 1fr); }
  .ev-row .btn span { display: none; }
  .ev-row .btn { padding: 0 9px; }
  .ev-row .icon-btn { width: 28px; }
  .ask-modal { height: calc(100dvh - 24px); }
  .msg { max-width: 94%; }
}

/* Danh sách dài: vẽ thêm khi cuộn tới đây. */
.list-more { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }

/* Menu: mục bị tắt */
.menu button[aria-disabled="true"] { opacity: .45; cursor: default; }

/* Hạn 📅 trong checklist và "Việc cần làm" */
.due { display: inline-flex; align-items: center; gap: 2px; font-size: .82em; padding: 0 7px; border-radius: 999px; background: var(--ink-soft); color: var(--muted); white-space: nowrap; vertical-align: 1px; font-variant-numeric: tabular-nums; }
.due.overdue { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.md li.check.done .due { background: none; }
.nav-item[data-overdue] .count { color: var(--red); font-weight: 600; }
.task-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; margin: 0 0 6px; border: 1px solid var(--hairline); border-radius: var(--radius); background: var(--surface); transition: opacity .3s; }
.task-row .box { width: 18px; height: 18px; margin-top: 2px; flex: none; border-radius: 5px; border: 1.5px solid color-mix(in srgb, var(--muted) 80%, transparent); display: grid; place-items: center; }
.task-row .box:hover { border-color: var(--accent); }
.task-row.overdue .box { border-color: color-mix(in srgb, var(--red) 70%, transparent); }
.task-row.done { opacity: .45; }
.task-row.done .box { background: var(--accent); border-color: var(--accent); }
.task-row.done .box::after { content: ""; width: 9px; height: 5px; border: 2px solid var(--on-ink); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.task-row.done .task-text { text-decoration: line-through; }
.task-main { flex: 1; min-width: 0; display: grid; gap: 4px; text-align: left; }
.task-text { display: flex; gap: 6px; align-items: baseline; font-size: 14.5px; line-height: 1.4; overflow-wrap: anywhere; }
.task-text svg { width: 14px; height: 14px; color: var(--accent); flex: none; align-self: center; }
.task-text code { font: .9em var(--mono); }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 12px; color: var(--muted); min-width: 0; }
.task-meta .due { font-size: 11.5px; }
.task-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 100%; }
.empty kbd { font: 12px var(--sans); border: 1px solid var(--hairline); border-radius: 6px; padding: 1px 6px; background: var(--surface); }

/* Lời nhắc của ghi chú */
.chip.remind { height: 26px; padding: 0 9px; gap: 4px; font-size: 12.5px; color: var(--accent); background: var(--accent-soft); border: 0; cursor: pointer; flex: none; }
.chip.remind svg { width: 13px; height: 13px; }
.chip.remind.past { color: var(--muted); background: var(--ink-soft); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }

/* Lịch sử phiên bản & chia sẻ */
.modal.ver-modal { width: min(920px, calc(100vw - 32px)); }
.modal.share-modal { width: min(600px, calc(100vw - 32px)); }
.ver-head { display: flex; align-items: center; gap: 8px; }
.ver-head .hint { display: inline-flex; align-items: center; gap: 4px; }
.ver-head .hint svg { width: 14px; height: 14px; }
.ver-body { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 14px; min-height: 360px; }
.ver-list { display: grid; align-content: start; gap: 4px; max-height: min(62vh, 560px); overflow: auto; padding-right: 2px; }
.ver-item { display: grid; gap: 1px; text-align: left; padding: 8px 10px; border-radius: 10px; border: 1px solid transparent; }
.ver-item:hover { background: var(--ink-soft); }
.ver-item[aria-selected="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.ver-item b { font-size: 14px; font-weight: 600; }
.ver-item span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ver-item small { font-size: 12.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.ver-item small svg { width: 12px; height: 12px; color: var(--accent); }
.ver-prev { min-width: 0; display: grid; gap: 10px; align-content: start; border-left: 1px solid var(--hairline); padding-left: 14px; }
.ver-ptop { display: flex; align-items: flex-start; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.ver-title { font: 600 18px/1.3 var(--serif); }
.ver-meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.ver-view { max-height: min(48vh, 440px); overflow: auto; border: 1px solid var(--hairline); border-radius: 10px; background: var(--raised); }
.ver-view .md { min-height: 0; cursor: auto; font-size: 14.5px; padding: 12px 14px; }
.ver-view > .hint { padding: 12px 14px; }
.ver-prev .actions { align-items: center; justify-content: space-between; flex-wrap: nowrap; }
.ver-prev .actions .hint { flex: 1; }
.diff { font: 12.5px/1.55 var(--mono); padding: 6px 0; }
.dl { display: flex; gap: 8px; padding: 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.dl .dm { flex: none; width: 1ch; color: var(--muted); user-select: none; }
.dl.add { background: color-mix(in srgb, #2f9e5b 14%, transparent); }
.dl.add .dm { color: #2f9e5b; }
.dl.del { background: color-mix(in srgb, var(--red) 12%, transparent); }
.dl.del .dm { color: var(--red); }
.dl.del .dt { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--red) 50%, transparent); }
.dl.skip { color: var(--muted); font-family: var(--sans); font-size: 12px; padding: 3px 10px; background: var(--ink-soft); }
.d-add { color: #2f9e5b; font-weight: 600; }
.d-del { color: var(--red); font-weight: 600; }
.sh-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sh-form { padding: 0 !important; }
.sh-card { display: flex; gap: 16px; align-items: center; padding: 14px; border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--hairline)); border-radius: 14px; background: var(--accent-soft); }
.sh-qr { flex: none; background: #fff; border-radius: 10px; padding: 6px; line-height: 0; }
.sh-main { flex: 1; min-width: 0; display: grid; gap: 8px; }
.sh-url { display: flex; gap: 6px; }
.sh-url .input { height: 34px; font: 13px var(--mono); }
.sh-main .link { display: inline-flex; align-items: center; gap: 4px; font-size: 13.5px; }
.sh-main .link svg { width: 14px; height: 14px; }
.sh-row { display: flex; align-items: center; gap: 6px; padding: 8px 0; }
.sh-row + .sh-row { border-top: 1px solid var(--hairline); }
.sh-rmain { flex: 1; min-width: 0; }
.sh-rurl { display: flex; align-items: center; gap: 6px; font: 13px var(--mono); }
.sh-rurl span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-rurl svg { width: 14px; height: 14px; color: var(--accent); flex: none; }

/* Ghi âm cuộc họp & biên bản */
.rec-face { display: grid; justify-items: center; gap: 10px; padding: 6px 0; }
.rec-time { font: 600 40px/1 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.rec-meter { width: min(280px, 80%); height: 6px; border-radius: 999px; background: var(--ink-soft); overflow: hidden; }
.rec-meter i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .08s linear; }
.rec-ctrl { display: flex; align-items: center; gap: 14px; }
.rec-main { color: var(--red); }
.rec-main.on { color: #fff; }
.rec-live { font-size: 13.5px; color: var(--muted); max-height: 90px; overflow: auto; background: var(--raised); border: 1px solid var(--hairline); border-radius: 10px; padding: 8px 10px; }
.steps li.ok { color: var(--ink); }
.steps li.ok::marker { content: "✓  "; }
.steps li.now { color: var(--ink); font-weight: 600; }
.steps li.now::marker { content: "…  "; }
.modal.mt-modal { width: min(760px, calc(100vw - 32px)); }
.mt-sec { display: grid; gap: 8px; }
.mt-sec .set-h small { text-transform: none; letter-spacing: 0; font-weight: 500; }
.mt-area { height: auto; padding: 9px 12px; line-height: 1.5; resize: vertical; }
.mt-items { display: grid; gap: 6px; }
.mt-item { display: grid; grid-template-columns: minmax(0, 1fr) 150px 150px auto auto; gap: 6px; align-items: center; }
.mt-item .input { height: 36px; font-size: 14px; }
.mt-sec > .btn { justify-self: start; }
.mt-next { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; flex-wrap: wrap; }
.mt-speakers { display: flex; flex-wrap: wrap; gap: 8px; }
.mt-sp { display: flex; align-items: center; gap: 6px; }
.mt-sp .input { height: 34px; width: 150px; font-size: 14px; }
.sp-badge { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13px; }
.mt-tr summary { cursor: pointer; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.mt-transcript { max-height: 220px; overflow: auto; font-size: 13.5px; line-height: 1.55; background: var(--raised); border: 1px solid var(--hairline); border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
.mt-transcript p { color: var(--ink) !important; margin: 0 0 6px !important; }
.mt .notice { margin: 0; }

@media (max-width: 759px) {
  .ver-body { grid-template-columns: 1fr; }
  .ver-list { max-height: 180px; }
  .ver-prev { border-left: 0; padding-left: 0; }
  .sh-grid { grid-template-columns: 1fr; }
  .sh-card { flex-direction: column; align-items: stretch; }
  .sh-qr { align-self: center; }
  .mt-item { grid-template-columns: 1fr 1fr; }
  .mt-item .mt-task { grid-column: 1 / -1; }
}

/* Ảnh đại diện */
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; overflow: hidden;
  background: var(--accent-soft); color: var(--accent); font: 600 13px/1 var(--sans); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.big { width: 64px; height: 64px; font-size: 26px; }
.avatar-btn { border-radius: 50%; flex: none; display: inline-grid; }
.avatar-btn:hover .avatar { box-shadow: 0 0 0 2px var(--accent-soft); }
.set-account { display: flex; align-items: center; gap: 14px; }
.set-acc-main { display: grid; gap: 4px; min-width: 0; flex: 1; font-size: 14px; }
.set-acc-main .k { color: var(--muted); font-size: 12.5px; }
.set-acc-main .v { font-weight: 500; overflow-wrap: anywhere; }
.set-acc-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
/* Hộp thoại mới: cột lưới co lại theo chiều rộng hộp thoại (URL dài không đẩy tràn). */
.modal .m-wrap.share, .modal .m-wrap.ver, .modal .m-wrap.rec, .modal form.mt { grid-template-columns: minmax(0, 1fr); }
