:root {
  --bg: #F7F6F2;
  --surface: #FFFFFF;
  --surface-subtle: #F2F0EA;
  --border: #E8E5DC;
  --border-strong: #D9D4C7;
  --ink: #1D1C19;
  --ink-2: #5D5A52;
  --ink-3: #969186;
  --amber: #C07A28;
  --amber-bg: #FCF4E6;
  --amber-border: #F2DFBD;
  --sage: #38755E;
  --sage-bg: #ECF5F0;
  --sage-border: #CFE6DA;
  --indigo: #395FD1;
  --indigo-bg: #EDF2FD;
  --indigo-border: #D1DDF9;
  --plum: #6C52C7;
  --plum-bg: #F3EFFC;
  --plum-border: #DFD5F8;
  --danger: #C2413B;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(29,28,25,0.04), 0 2px 8px rgba(29,28,25,0.03);
  --shadow-md: 0 8px 28px rgba(29,28,25,0.08);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei UI", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* OTA receive banner */
.ota-banner {
  display: none;
  background: #1D1C19;
  color: #FAF8F2;
  padding: 9px 20px;
  font-size: 13px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ota-banner.show { display: flex; }
.ota-banner-btn {
  border: none; background: #E3A54F; color: #1D1C19;
  font-weight: 700; padding: 5px 13px; border-radius: 8px; cursor: pointer; font-size: 12.5px; font-family: inherit;
}

/* Desktop app shell — full-bleed warm paper style */
.app-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  background: #F3F1EB;
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.app-logo {
  display: flex; align-items: center; justify-content: space-between; padding: 2px 8px;
}
.logo-left { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; color: var(--ink); }
.logo-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, #2D2B26, #5B5549);
  color: #FFF; display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.sync-pill {
  font-size: 11px; color: var(--sage); background: var(--sage-bg);
  padding: 2px 7px; border-radius: 99px; display: inline-flex; align-items: center; gap: 4px;
}
.sync-pill.offline { color: var(--amber); background: var(--amber-bg); }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.search-box {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 6px 10px; font-size: 12.5px; color: var(--ink-3);
}
.search-box input {
  width: 100%; border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 12.5px; color: var(--ink);
}
.search-box input::placeholder { color: var(--ink-3); }

.nav-group-label {
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  padding: 0 10px; margin-bottom: 4px; letter-spacing: 0.4px;
}
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 9px; cursor: pointer;
  font-size: 13.5px; color: var(--ink-2); border: none; background: transparent;
  font-family: inherit; text-align: left; width: 100%; transition: all 0.14s;
}
.nav-item:hover { background: rgba(29,28,25,0.05); color: var(--ink); }
.nav-item.active {
  background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 3px rgba(29,28,25,0.06);
}
.nav-left { display: flex; align-items: center; gap: 9px; }
.nav-count { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.nav-item.active .nav-count { color: var(--ink-2); }
.nav-divider { height: 1px; background: var(--border); margin: 2px 6px; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px; }
.tag-chip {
  font-size: 12px; color: var(--ink-2); background: rgba(255,255,255,0.7);
  border: 1px solid var(--border); border-radius: 99px; padding: 2px 9px; cursor: pointer;
}
.tag-chip:hover, .tag-chip.active { background: var(--surface); color: var(--ink); border-color: var(--ink); font-weight: 600; }

.sidebar-foot {
  margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border);
}

/* Main */
.main { padding: 24px 32px 86px; overflow-y: auto; min-width: 0; }
.main-narrow { max-width: 780px; margin: 0 auto; }
.main-wide { max-width: 1120px; margin: 0 auto; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; gap: 12px; flex-wrap: wrap;
}
.page-title { font-size: 20px; font-weight: 700; letter-spacing: -0.2px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

/* Composer */
.composer {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px 12px;
  box-shadow: var(--shadow-sm); margin-bottom: 18px;
}
.composer-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.composer-hint { font-size: 12px; color: var(--ink-3); }
.composer textarea {
  width: 100%; border: none; outline: none; resize: none;
  font-family: inherit; font-size: 14.5px; line-height: 1.65;
  color: var(--ink); background: transparent; min-height: 58px;
}
.composer textarea::placeholder { color: #ACA79B; }
.composer-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 10px; border-top: 1px solid #F2F0EA; margin-top: 6px;
  gap: 8px; flex-wrap: wrap;
}
.tool-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.ghost-btn {
  border: 1px solid var(--border); background: var(--bg); color: var(--ink-2);
  border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer;
  font-family: inherit; display: inline-flex; align-items: center; gap: 5px;
  text-decoration: none; transition: all 0.14s;
}
.ghost-btn:hover { background: var(--surface-subtle); color: var(--ink); }
.ghost-btn.on-amber { background: var(--amber-bg); border-color: var(--amber-border); color: var(--amber); font-weight: 600; }
.ghost-btn.on-sage { background: var(--sage-bg); border-color: var(--sage-border); color: var(--sage); font-weight: 600; }
.ghost-btn.on-indigo { background: var(--indigo-bg); border-color: var(--indigo-border); color: var(--indigo); font-weight: 600; }
.ghost-btn.on-plum { background: var(--plum-bg); border-color: var(--plum-border); color: var(--plum); font-weight: 600; }

.primary-btn {
  border: none; background: var(--ink); color: #FFF;
  border-radius: 9px; padding: 6px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: opacity 0.14s;
}
.primary-btn:hover { opacity: 0.88; }
.primary-btn.sage { background: var(--sage); }

/* Filter */
.filter-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 10px; flex-wrap: wrap;
}
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  border: 1px solid transparent; background: transparent; color: var(--ink-2);
  border-radius: 99px; padding: 4px 12px; font-size: 12.5px; cursor: pointer; font-family: inherit;
}
.pill:hover { background: rgba(29,28,25,0.05); }
.pill.active { background: var(--surface); border-color: var(--border); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }

/* Cards */
.card-stack { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 18px;
  box-shadow: var(--shadow-sm); transition: border-color 0.15s;
}
.card:hover { border-color: var(--border-strong); }
.card.feeling {
  background: linear-gradient(180deg, #FCFDFB 0%, #FFFFFF 100%);
  border-color: #DCECE4;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 8px; flex-wrap: wrap;
}
.kind-badge {
  font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px;
  display: inline-flex; align-items: center; gap: 4px;
}
.badge-idea { background: var(--amber-bg); color: var(--amber); }
.badge-feeling { background: var(--sage-bg); color: var(--sage); }
.badge-todo { background: var(--indigo-bg); color: var(--indigo); }
.badge-note { background: var(--plum-bg); color: var(--plum); }

.card-time { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.card-title { font-size: 15.5px; font-weight: 700; color: var(--ink); margin-bottom: 5px; }
.card-body { font-size: 14px; color: #312F2A; white-space: pre-wrap; word-break: break-word; }
.card-body img { max-width: 100%; border-radius: 10px; margin-top: 8px; display: block; border: 1px solid var(--border); }

.update-preview {
  margin-top: 12px; background: #FAF9F5; border-left: 3px solid var(--amber);
  border-radius: 0 9px 9px 0; padding: 9px 12px; font-size: 13px;
}
.update-preview.todo-accent { border-left-color: var(--indigo); background: #F6F8FE; }
.update-preview-meta {
  font-size: 11.5px; color: var(--ink-3); margin-bottom: 3px;
  display: flex; justify-content: space-between; align-items: center;
}
.update-preview-text { color: var(--ink-2); }

.card-foot {
  margin-top: 12px; padding-top: 10px; border-top: 1px solid #F3F1EB;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap;
}
.meta-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); }
.mini-tag { color: var(--ink-2); background: var(--surface-subtle); padding: 1px 8px; border-radius: 99px; font-size: 11.5px; cursor: pointer; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.act-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  border-radius: 7px; padding: 3px 9px; font-size: 12px; cursor: pointer; font-family: inherit; text-decoration: none;
}
.act-btn:hover { background: var(--surface-subtle); color: var(--ink); }
.act-btn.accent { color: var(--amber); border-color: var(--amber-border); background: var(--amber-bg); font-weight: 600; }
.act-btn.accent-indigo { color: var(--indigo); border-color: var(--indigo-border); background: var(--indigo-bg); font-weight: 600; }
.act-btn.accent-plum { color: var(--plum); border-color: var(--plum-border); background: var(--plum-bg); font-weight: 600; }
.act-btn.danger { color: var(--danger); }

.inline-update-box {
  margin-top: 10px; padding: 10px 12px; background: #FAF9F5;
  border: 1px solid var(--border-strong); border-radius: 10px;
  display: flex; gap: 8px; flex-direction: column;
}
.inline-update-box textarea {
  border: none; background: transparent; outline: none; font-family: inherit;
  font-size: 13.5px; color: var(--ink); width: 100%; resize: none;
}

/* Refine dual-pane & built-in Markdown */
.refine-grid {
  display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(290px, 1fr);
  gap: 18px; align-items: start;
}
.refine-grid.split-wide {
  grid-template-columns: minmax(0, 1fr);
}
.editor-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 24px; box-shadow: var(--shadow-sm);
}
.editor-title-input {
  width: 100%; border: none; outline: none; font-family: inherit;
  font-size: 21px; font-weight: 700; color: var(--ink); margin: 10px 0 12px;
}
.editor-body-area {
  width: 100%; border: none; outline: none; resize: vertical; font-family: inherit;
  font-size: 14.5px; line-height: 1.85; color: #2D2B27; min-height: 430px;
  background: transparent;
}
.editor-body-area.md-source {
  font-family: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, var(--font);
  font-size: 13.8px;
  line-height: 1.8;
}
.md-mode-tabs {
  display: inline-flex; background: #EFECE4; padding: 2px; border-radius: 8px; gap: 2px;
}
.md-mode-btn {
  border: none; background: transparent; color: var(--ink-2);
  padding: 3px 10px; border-radius: 6px; font-size: 11.5px; font-weight: 500;
  cursor: pointer; font-family: inherit; transition: all 0.14s;
}
.md-mode-btn.active {
  background: var(--surface); color: var(--ink); font-weight: 700;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.md-toolbar {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 6px 8px; margin-bottom: 12px;
  background: #FAF9F5; border: 1px solid var(--border); border-radius: 10px;
}
.md-tool-btn {
  border: 1px solid transparent; background: transparent; color: var(--ink-2);
  padding: 3px 7px; border-radius: 6px; font-size: 12px; cursor: pointer;
  font-family: inherit; line-height: 1.3; transition: all 0.12s;
}
.md-tool-btn:hover {
  background: var(--surface); border-color: var(--border); color: var(--ink);
}
.md-tool-sep {
  width: 1px; height: 14px; background: var(--border-strong); margin: 0 3px;
}
.md-editor-stage.mode-split {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px; align-items: start;
}
.md-editor-stage.mode-split .md-preview-pane {
  border-left: 1px solid var(--border);
  padding-left: 18px;
  min-height: 430px;
}
.md-preview-pane {
  min-height: 430px;
}
.md-wysiwyg {
  min-height: 430px;
  outline: none;
  cursor: text;
}
.md-wysiwyg:empty::before {
  content: attr(data-placeholder);
  color: #ACA79B;
  pointer-events: none;
}
.md-body .md-pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute; top: 6px; right: 10px; font-size: 10.5px;
  color: rgba(255,255,255,0.45); text-transform: uppercase;
  pointer-events: none;
}

/* Markdown Typography */
.md-body {
  font-size: 14.5px; line-height: 1.8; color: #2D2B27; word-break: break-word;
}
.md-body > *:first-child { margin-top: 0; }
.md-body > *:last-child { margin-bottom: 0; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4, .md-body h5, .md-body h6 {
  color: var(--ink); font-weight: 700; line-height: 1.4; margin: 16px 0 8px;
}
.md-body h1 { font-size: 20px; border-bottom: 1px solid #EFECE4; padding-bottom: 5px; }
.md-body h2 { font-size: 17px; }
.md-body h3 { font-size: 15.5px; }
.md-body h4 { font-size: 14.5px; }
.md-body p { margin: 0 0 10px; white-space: pre-wrap; }
.md-body ul, .md-body ol { margin: 0 0 10px; padding-left: 22px; }
.md-body li { margin: 3px 0; white-space: pre-wrap; }
.md-body ul.md-task-list { list-style: none; padding-left: 4px; }
.md-body .md-task-item { display: flex; align-items: flex-start; gap: 7px; }
.md-body .md-task-item.done > span { text-decoration: line-through; color: var(--ink-3); }
.md-body .md-task-cb { margin-top: 5px; accent-color: var(--plum); cursor: pointer; }
.md-body .md-task-mark { color: var(--ink-3); font-size: 13px; line-height: 1.7; }
.md-body .md-task-mark.checked { color: var(--sage); }
.md-body blockquote {
  margin: 10px 0; padding: 8px 14px;
  border-left: 3px solid var(--plum-border);
  background: #FAF9F6; border-radius: 0 8px 8px 0; color: var(--ink-2);
}
.md-body code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.88em; background: #F2F0EA; color: #8B3A2B;
  padding: 1px 5px; border-radius: 5px;
}
.md-body .md-pre {
  position: relative; margin: 10px 0; padding: 12px 14px;
  background: #23221F; color: #F5F3EE; border-radius: 10px;
  overflow-x: auto; font-size: 13px; line-height: 1.6;
}
.md-body .md-pre code {
  background: transparent; color: inherit; padding: 0; font-size: inherit;
}
.md-body .md-lang {
  position: absolute; top: 6px; right: 10px; font-size: 10.5px;
  color: rgba(255,255,255,0.45); text-transform: uppercase;
}
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.md-body a { color: var(--indigo); text-decoration: underline; text-underline-offset: 2px; }
.md-body mark { background: #FEF0C3; color: var(--ink); padding: 0 3px; border-radius: 3px; }
.md-body img { max-width: 100%; border-radius: 10px; margin: 8px 0; border: 1px solid var(--border); }
.md-body .md-table-wrap { overflow-x: auto; margin: 10px 0; }
.md-body table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.md-body th, .md-body td {
  border: 1px solid var(--border); padding: 6px 10px; text-align: left;
}
.md-body th { background: #FAF9F5; font-weight: 600; }
.md-body .md-empty { color: var(--ink-3); font-size: 13px; }

/* Compact Markdown preview inside Notes cards */
.md-body.md-card-preview {
  font-size: 13px; line-height: 1.6; color: var(--ink-2);
  margin-top: 6px; max-height: 118px; overflow: hidden; position: relative;
}
.md-body.md-card-preview::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, #FFFFFF 100%);
  pointer-events: none;
}
.note-card.pinned .md-body.md-card-preview::after {
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, #FFFFFF 100%);
}
.md-body.md-card-preview h1,
.md-body.md-card-preview h2,
.md-body.md-card-preview h3,
.md-body.md-card-preview h4 {
  font-size: 13.5px; margin: 4px 0 3px; border: none; padding: 0;
}
.md-body.md-card-preview p,
.md-body.md-card-preview ul,
.md-body.md-card-preview ol,
.md-body.md-card-preview blockquote { margin: 0 0 4px; }
.md-body.md-card-preview .md-pre { padding: 6px 8px; font-size: 12px; margin: 4px 0; }
.updates-panel {
  background: #F4F2EC; border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
}
.panel-title {
  font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.update-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 11px; padding: 11px 12px; margin-bottom: 10px; font-size: 13px;
}
.update-item.absorbed { opacity: 0.58; background: #FAF9F6; }
.update-item-top {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11.5px; color: var(--ink-3); margin-bottom: 5px;
}
.absorb-btn {
  border: 1px solid var(--plum-border); background: var(--plum-bg); color: var(--plum);
  border-radius: 6px; padding: 2px 8px; font-size: 11.5px; font-weight: 600; cursor: pointer;
}
.absorb-btn.done { background: var(--sage-bg); border-color: var(--sage-border); color: var(--sage); }

/* Todo */
.todo-section-label {
  font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin: 18px 0 10px;
  display: flex; align-items: center; gap: 7px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.todo-check-row { display: flex; align-items: flex-start; gap: 10px; }
.todo-checkbox {
  width: 18px; height: 18px; border-radius: 6px; border: 2px solid var(--indigo);
  margin-top: 3px; flex-shrink: 0; display: grid; place-items: center; cursor: pointer;
  font-size: 11px; color: #FFF;
}
.todo-checkbox.done { background: var(--sage); border-color: var(--sage); }
.subtasks { margin-top: 9px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); }
.subtask-row { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.progress-mini { height: 5px; width: 72px; background: #E7E9F2; border-radius: 99px; overflow: hidden; display: inline-block; vertical-align: middle; margin-left: 6px; }
.progress-mini > span { display: block; height: 100%; background: var(--indigo); }

/* Notes */
.notes-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.note-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow-sm); cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between; gap: 12px;
}
.note-card:hover { border-color: var(--plum-border); }
.note-card.pinned {
  border-color: var(--plum-border);
  background: linear-gradient(180deg, #FCFAFF 0%, #FFFFFF 100%);
}

/* Review */
.segment { display: inline-flex; background: #ECEAE2; padding: 3px; border-radius: 11px; gap: 3px; }
.seg-btn {
  border: none; background: transparent; padding: 6px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--ink-2); cursor: pointer; font-family: inherit;
}
.seg-btn.active { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.review-top-banner {
  background: linear-gradient(135deg, #FCF7EC 0%, #F3F8F5 100%);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 16px; margin-bottom: 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px;
}

.timeline-day { margin-bottom: 22px; }
.timeline-date { font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.timeline-list { border-left: 2px solid #E4E0D5; margin-left: 7px; padding-left: 18px; display: flex; flex-direction: column; gap: 10px; }
.tl-node { position: relative; }
.tl-dot {
  position: absolute; left: -24px; top: 14px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--surface); border: 2.5px solid var(--amber);
}
.tl-dot.feeling { border-color: var(--sage); }
.tl-dot.todo { border-color: var(--indigo); }
.tl-dot.note { border-color: var(--plum); }

.cal-layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 20px; align-items: start; }
.cal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-sm); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 12px; text-align: center; }
.cal-dow { font-size: 11px; color: var(--ink-3); font-weight: 600; padding-bottom: 4px; }
.cal-cell {
  aspect-ratio: 1; border-radius: 9px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 12.5px; cursor: pointer; border: 1px solid transparent;
}
.cal-cell.lvl1 { background: #F5F2E8; }
.cal-cell.lvl2 { background: #EFE3C8; }
.cal-cell.lvl3 { background: #E3C996; font-weight: 600; }
.cal-cell.selected { border-color: var(--ink); box-shadow: 0 0 0 2px rgba(29,28,25,0.12); font-weight: 700; }
.cal-dots { display: flex; gap: 2px; margin-top: 2px; }
.cal-dots i { width: 4px; height: 4px; border-radius: 50%; display: block; }

.map-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) 320px; gap: 16px; align-items: stretch; }
.map-canvas {
  background: #EDEBE3; border: 1px solid var(--border); border-radius: var(--radius-lg);
  position: relative; min-height: 450px; overflow: hidden; box-shadow: var(--shadow-sm);
}
.map-pin {
  position: absolute; transform: translate(-50%, -50%);
  background: var(--ink); color: #FFF; padding: 5px 11px; border-radius: 99px;
  font-size: 12px; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  cursor: pointer; display: flex; align-items: center; gap: 5px; white-space: nowrap;
  border: 2px solid #FFF;
}
.map-pin:hover, .map-pin.active { background: var(--amber); transform: translate(-50%, -50%) scale(1.07); }
.map-pin.sage { background: var(--sage); }
.map-side { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; display: flex; flex-direction: column; gap: 10px; }

/* Zen */
.zen-wrap {
  max-width: 720px; margin: 18px auto; background: #FFFDF9;
  border: 1px solid #E5E1D6; border-radius: 20px; padding: 36px 42px; box-shadow: var(--shadow-md);
}
.zen-date { font-size: 13px; color: var(--sage); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.mood-row { display: flex; gap: 8px; margin: 14px 0 22px; flex-wrap: wrap; }
.mood-chip {
  border: 1px solid var(--border); background: #FAF9F5; padding: 4px 12px;
  border-radius: 99px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; font-family: inherit;
}
.mood-chip.active { background: var(--sage-bg); border-color: var(--sage-border); color: var(--sage); font-weight: 600; }
.zen-textarea {
  width: 100%; border: none; outline: none; background: transparent; resize: vertical;
  font-family: inherit; font-size: 16px; line-height: 2; color: #2A2925; min-height: 280px;
}

/* Clean Receive-Only Settings */
.field-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field-row label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field-input {
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--ink);
  border-radius: 9px; padding: 8px 11px; font-family: inherit; font-size: 13.5px; width: 100%;
}
.code-pill {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px; background: var(--surface-subtle); padding: 2px 8px; border-radius: 6px; color: var(--ink-2);
}

/* Toast & Auth */
.toast {
  position: fixed; bottom: 82px; left: 50%; transform: translateX(-50%);
  background: #1D1C19; color: #FFF; padding: 8px 16px; border-radius: 99px;
  font-size: 13px; box-shadow: var(--shadow-md); opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 200;
}
.toast.show { opacity: 1; }
.auth-overlay {
  position: fixed; inset: 0; background: var(--bg); z-index: 300;
  display: none; place-items: center; padding: 20px;
}
.auth-overlay.show { display: grid; }
.auth-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 28px; width: 100%; max-width: 360px; box-shadow: var(--shadow-md); text-align: center;
}

/* Mobile Header (Minimal + Breathing Island) & Bottom Tabbar */
.mobile-topbar {
  display: none; position: sticky; top: 0; z-index: 50;
  background: rgba(247,246,242,0.88); backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(232,229,220,0.65);
  padding: calc(env(safe-area-inset-top, 0px) + 7px) 14px 8px;
  grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 8px;
}
.mobile-brand {
  font-size: 14px; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mobile-top-actions {
  display: flex; justify-content: flex-end; align-items: center;
}
.mobile-icon-btn {
  width: 28px; height: 28px; border-radius: 999px;
  border: 1px solid var(--border); background: rgba(255,255,255,0.85);
  display: grid; place-items: center; font-size: 13px; cursor: pointer;
  transition: transform 0.14s, background 0.14s;
}
.mobile-icon-btn:active { transform: scale(0.92); background: var(--sage-bg); }

/* Breathing Island (呼吸岛) */
@keyframes islandBreathe {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(94, 211, 164, 0.55); }
  50% { opacity: 0.72; transform: scale(0.88); box-shadow: 0 0 0 5px rgba(94, 211, 164, 0); }
}
@keyframes islandPulseWarn {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}
.mobile-island {
  height: 28px; min-width: 82px; max-width: 215px;
  padding: 0 12px; border-radius: 999px;
  background: #1D1C19; color: #FAF8F2;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.1px;
  box-shadow: 0 2px 10px rgba(29,28,25,0.16), inset 0 1px 0 rgba(255,255,255,0.08);
  transition: padding 0.28s cubic-bezier(0.22, 1, 0.36, 1), transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), background 0.22s ease;
}
.mobile-island.is-alert {
  padding: 0 15px;
  transform: scale(1.03);
}
.mobile-island.is-error {
  background: #3B1E1C;
}
.island-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  background: #5ED3A4;
  animation: islandBreathe 2.8s ease-in-out infinite;
}
.mobile-island.offline .island-dot {
  background: #F0B45A;
  animation: islandPulseWarn 1.2s ease-in-out infinite;
}
.mobile-island.is-error .island-dot {
  background: #F27970;
  animation: none;
}
.mobile-island.is-alert .island-dot {
  background: #6CE0B0;
  animation: none;
}
.island-text {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.mobile-tabbar {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  height: 62px; background: rgba(255,255,255,0.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  grid-template-columns: repeat(5, 1fr); align-items: center;
}
.m-tab {
  border: none; background: transparent; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--ink-3); cursor: pointer;
}
.m-tab.active { color: var(--ink); font-weight: 700; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-topbar { display: grid; }
  .mobile-tabbar { display: grid; }
  .toast { display: none; }
  .mobile-hide { display: none !important; }
  .main { padding: 12px 14px 86px; }
  .page-header { margin-bottom: 12px; }
  .page-title { font-size: 18px; }
  .refine-grid, .cal-layout, .map-layout, .notes-grid, .md-editor-stage.mode-split { grid-template-columns: 1fr; }
  .md-editor-stage.mode-split .md-preview-pane { border-left: none; border-top: 1px solid var(--border); padding-left: 0; padding-top: 14px; min-height: 180px; }
  .zen-wrap { padding: 22px 18px; }
}

/* Frameless Integrated Desktop Titlebar (0 extra height, Notion/Obsidian style) */
.desktop-drag-strip,
.desktop-win-controls,
.desktop-sidebar-expand {
  display: none;
}

body.is-desktop .desktop-drag-strip {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  z-index: 400;
  -webkit-app-region: drag;
  pointer-events: auto;
}

body.is-desktop .desktop-win-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  position: fixed;
  top: 5px;
  right: 8px;
  z-index: 500;
  -webkit-app-region: no-drag;
}

body.is-desktop .win-btn {
  width: 28px;
  height: 26px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
body.is-desktop .win-btn:hover {
  background: rgba(29, 28, 25, 0.075);
  color: var(--ink);
}
body.is-desktop .win-btn.active {
  background: rgba(29, 28, 25, 0.1);
  color: var(--ink);
}
body.is-desktop .win-btn-close:hover {
  background: #C2413B;
  color: #FFF;
}
body.is-desktop .win-sep {
  width: 1px;
  height: 13px;
  background: var(--border-strong);
  margin: 0 3px;
  opacity: 0.75;
}

body.is-desktop {
  overflow: hidden;
}
body.is-desktop .app-shell {
  max-width: none;
  height: 100vh;
  min-height: 0;
}
body.is-desktop .sidebar {
  padding-top: 16px;
  transition: width 0.18s ease, padding 0.18s ease, opacity 0.15s ease;
}
body.is-desktop .app-logo {
  -webkit-app-region: drag;
}
body.is-desktop .sidebar button,
body.is-desktop .sidebar input,
body.is-desktop .sidebar .tag-chip,
body.is-desktop .main button,
body.is-desktop .main input,
body.is-desktop .main textarea,
body.is-desktop .main a {
  -webkit-app-region: no-drag;
}
body.is-desktop .main {
  height: 100vh;
  padding-top: 36px;
}
body.is-desktop .ota-banner {
  padding-right: 175px;
}
body.is-desktop .mobile-topbar {
  padding-top: 8px;
  padding-right: 172px;
  -webkit-app-region: drag;
}
body.is-desktop .mobile-topbar button {
  -webkit-app-region: no-drag;
}
@media (max-width: 900px) {
  body.is-desktop .desktop-drag-strip {
    display: none;
  }
  body.is-desktop .main {
    height: calc(100vh - 48px);
    padding-top: 14px;
  }
}

/* Collapsed sidebar mode: ultra-lightweight single-column pad */
body.is-desktop.sidebar-collapsed .app-shell {
  grid-template-columns: 0 minmax(0, 1fr);
}
body.is-desktop.sidebar-collapsed .sidebar {
  padding: 0;
  border-right: none;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
body.is-desktop.sidebar-collapsed .desktop-sidebar-expand {
  display: grid;
  place-items: center;
  position: fixed;
  top: 5px;
  left: 10px;
  width: 28px;
  height: 26px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  z-index: 500;
  -webkit-app-region: no-drag;
  transition: background 0.14s, color 0.14s;
}
body.is-desktop.sidebar-collapsed .desktop-sidebar-expand:hover {
  background: rgba(29, 28, 25, 0.075);
  color: var(--ink);
}
@media (max-width: 900px) {
  body.is-desktop.sidebar-collapsed .desktop-sidebar-expand {
    display: none;
  }
}
