:root {
  color-scheme: light;
  --ink: #30353a;
  --muted: #69727b;
  --paper: #fbfaf2;
  --canvas: #e7ebef;
  --line: #cbd3db;
  --brand-blue: #5890cd;
  --accent: #4879b0;
  --accent-hover: #3b6798;
  --soft: #e9f0f8;
  --danger: #9b3d35;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background-color: var(--canvas);
  background-image:
    radial-gradient(circle at 15% 8%, rgb(255 255 255 / 72%), transparent 38%),
    linear-gradient(118deg, rgb(255 255 255 / 24%), rgb(132 145 157 / 10%)),
    repeating-linear-gradient(0deg, rgb(255 255 255 / 12%) 0 1px, rgb(112 124 135 / 3%) 1px 2px);
  color: var(--ink);
  line-height: 1.55;
}
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: var(--accent); text-underline-offset: 3px; }

.topbar {
  align-items: center; display: flex; justify-content: space-between; margin: auto;
  max-width: 920px; min-height: 76px; padding: 14px 22px;
}
.brand { align-items: center; color: var(--ink); display: flex; gap: 12px; text-decoration: none; }
.brand-logo { width: 48px; height: 48px; border: 1px solid rgb(72 121 176 / 24%); border-radius: 12px; display: block; object-fit: cover; box-shadow: 0 7px 20px rgb(45 70 94 / 14%); }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: 12px; margin-top: -2px; }

.shell { margin: 0 auto; max-width: 920px; padding: 14px 22px 80px; }
.auth-card, .composer, .notes-section {
  background: var(--paper); border: 1px solid var(--line); border-radius: 24px;
  box-shadow: 0 16px 42px rgb(39 48 43 / 6%);
}
.auth-card { margin: 10vh auto 0; max-width: 460px; padding: 34px; }
.composer { padding: 30px; }
.notes-section { margin-top: 18px; padding: 28px 30px 34px; }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 750; letter-spacing: .12em; margin: 0 0 5px; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { letter-spacing: -.025em; line-height: 1.2; }
h1 { font-size: clamp(26px, 6vw, 38px); margin-bottom: 10px; }
h2 { font-size: clamp(23px, 5vw, 30px); margin-bottom: 0; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 9px; margin-top: 24px; }
label { font-size: 14px; font-weight: 650; }
input, textarea {
  background: #fff; border: 1px solid #cfc9bd; border-radius: 13px; color: var(--ink);
  outline: none; padding: 13px 14px; width: 100%;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(72 121 176 / 18%); }
textarea { min-height: 130px; resize: vertical; }
.stack .button { margin-top: 8px; width: 100%; }

.button {
  align-items: center; border: 1px solid transparent; border-radius: 999px; display: inline-flex;
  font-weight: 720; justify-content: center; min-height: 44px; padding: 10px 18px;
}
.button:disabled { cursor: wait; opacity: .62; }
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-hover); }
.button.ghost { background: transparent; border-color: #cfc9bd; color: var(--ink); }
.button.ghost:hover { background: #ece7dd; }
.button.danger-button { background: var(--danger); color: #fff; }
.button.compact { min-height: 38px; padding: 7px 14px; }
.section-heading { align-items: flex-start; display: flex; justify-content: space-between; gap: 16px; }
.local-badge { background: var(--soft); border-radius: 999px; color: var(--accent); font-size: 12px; font-weight: 750; padding: 6px 10px; white-space: nowrap; }
.composer-skill-picker { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; color: var(--muted); font-size: 13px; }
.composer-skill-picker select { min-height: 38px; max-width: 70%; border: 1px solid #cfc9bd; border-radius: 12px; background: #fff; color: var(--ink); padding: 0 12px; }
.composer textarea { border: 0; border-top: 1px solid var(--line); border-radius: 0; box-shadow: none; margin-top: 18px; min-height: 150px; padding: 18px 2px; }
.composer-footer { align-items: center; border-top: 1px solid var(--line); display: flex; justify-content: space-between; padding-top: 16px; }

.toolbar { display: grid; gap: 10px; grid-template-columns: minmax(180px, 1fr) auto auto auto; margin-top: 24px; }
.search-box { align-items: center; display: flex; position: relative; }
.search-box span { color: var(--muted); font-size: 24px; left: 13px; position: absolute; }
.search-box input { padding-left: 40px; }
.category-filter { align-items: center; display: flex; gap: 6px; white-space: nowrap; }
.category-filter select { background: #fff; border: 1px solid #cfc9bd; border-radius: 13px; color: var(--ink); min-height: 44px; padding: 0 10px; }
.trash-toggle { align-items: center; display: flex; gap: 8px; white-space: nowrap; }
.trash-toggle input { accent-color: var(--accent); height: 18px; padding: 0; width: 18px; }
.export-row { align-items: center; display: flex; flex-wrap: wrap; font-size: 13px; gap: 8px 14px; margin: 15px 2px 5px; }
.sync-panel {
  align-items: center; background: #fff2cd; border: 1px solid #ead799; border-radius: 13px;
  color: #684f0f; display: flex; font-size: 13px; font-weight: 650; gap: 12px;
  justify-content: space-between; margin-top: 14px; padding: 9px 11px 9px 14px;
}
.notes-list { display: grid; gap: 12px; margin-top: 18px; }

.tool-section { margin-top: 1.5rem; padding: 1.25rem; border: 1px solid var(--line); border-radius: 1rem; background: rgba(255, 252, 245, .72); }
.skills-list { display: grid; gap: .75rem; }
.skill-card { padding: .85rem; border: 1px solid var(--line); border-radius: .75rem; background: #fffdf8; }
.skill-card h3 { margin: 0 0 .25rem; }
.skill-card pre, .assistant-answer { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 20rem; overflow: auto; }
.assistant-answer { margin: 1rem 0 0; padding: 1rem; border-radius: .75rem; background: #f1eee6; }
.bookkeeper-preview { margin-top: 1rem; padding: 1rem; border: 1px solid #d7b86b; border-radius: .75rem; background: #fff8df; }
.bookkeeper-preview pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 20rem; overflow: auto; }
.note-card { background: #fff; border: 1px solid var(--line); border-radius: 17px; padding: 18px; }
.note-card.deleted { background: #f2eee6; opacity: .88; }
.note-card.pending { background: #fffaf0; border-color: #dfca8b; }
.note-meta { align-items: center; display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 9px; }
.category, .deleted-label { background: var(--soft); border-radius: 999px; color: var(--accent); font-size: 12px; font-weight: 750; padding: 3px 8px; }
.pending-label { background: #fff0bb; border-radius: 999px; color: #6b5108; font-size: 12px; font-weight: 750; padding: 3px 8px; }
.deleted-label { background: #f4dedb; color: var(--danger); }
.note-time { color: var(--muted); font-size: 12px; }
.note-content { font-size: 16px; margin-bottom: 8px; overflow-wrap: anywhere; white-space: pre-wrap; }
.note-summary { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.sync-error { color: var(--danger); font-size: 12px; margin-bottom: 0; }
.note-actions { display: flex; gap: 8px; justify-content: flex-end; }
.note-actions button { background: transparent; border: 0; color: var(--accent); font-weight: 700; min-height: 40px; padding: 6px 9px; }
.note-actions .danger { color: var(--danger); }
.empty-state { color: var(--muted); padding: 48px 20px; text-align: center; }
.empty-state > span { color: var(--accent); font-size: 28px; }
.empty-state h3 { color: var(--ink); margin: 8px 0 4px; }

.toast {
  background: var(--ink); border-radius: 12px; bottom: max(22px, env(safe-area-inset-bottom));
  box-shadow: 0 10px 28px rgb(0 0 0 / 20%); color: #fff; left: 50%; max-width: calc(100% - 32px);
  padding: 11px 16px; position: fixed; transform: translateX(-50%); z-index: 20;
}
dialog { background: transparent; border: 0; padding: 14px; width: min(650px, 100%); }
dialog::backdrop { background: rgb(20 28 24 / 56%); backdrop-filter: blur(2px); }
.dialog-card { background: var(--paper); border-radius: 22px; padding: 24px; }
.compact-dialog { max-width: 480px; }
.dialog-heading { align-items: flex-start; display: flex; justify-content: space-between; }
.dialog-heading h2 { margin-bottom: 18px; }
.icon-button { background: transparent; border: 0; color: var(--muted); font-size: 30px; height: 42px; line-height: 1; width: 42px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.sr-only { height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; clip: rect(0, 0, 0, 0); }

@media (max-width: 620px) {
  .topbar { min-height: 64px; padding: 11px 14px; }
  .brand small { display: none; }
  .brand-logo { border-radius: 10px; height: 40px; width: 40px; }
  .shell { padding: 6px 10px 68px; }
  .auth-card { border-radius: 20px; margin-top: 7vh; padding: 25px 20px; }
  .composer, .notes-section { border-radius: 20px; padding: 22px 18px; }
  .notes-section { margin-top: 10px; }
  .notes-heading { align-items: center; }
  .toolbar { grid-template-columns: 1fr auto; }
  .search-box { grid-column: 1 / -1; }
  .category-filter { grid-column: 1 / -1; }
  .category-filter select { flex: 1; }
  .toolbar .button { min-width: 75px; }
  .local-badge { display: none; }
  .composer textarea { min-height: 130px; }
  .note-card { padding: 15px; }
  .dialog-card { padding: 20px 16px; }
}

@media (prefers-reduced-motion: no-preference) {
  .note-card { animation: appear .22s ease-out; }
  @keyframes appear { from { opacity: 0; transform: translateY(5px); } }
}
