/* ============================================================
   小记 · 待办 APP  —— 主题变量
   ============================================================ */
:root {
  --nav-w: 148px;
  --compose-w: 248px;
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="light"] {
  --bg: #F6F5F2;
  --bg-nav: #EFEDE8;
  --bg-compose: #F1EFEA;
  --surface: #FFFFFF;
  --surface-2: #FAF9F7;
  --surface-hover: #F2F1ED;
  --border: #E4E1DA;
  --border-strong: #D4D0C7;
  --text: #22252A;
  --text-2: #5C6269;
  --text-3: #9AA0A6;
  --accent: #1F9D6B;
  --accent-soft: #E7F4EE;
  --accent-text: #FFFFFF;
  --danger: #C8503C;
  --danger-soft: #FBEAE6;
  --shadow: 0 1px 2px rgba(24, 26, 30, .05), 0 6px 18px rgba(24, 26, 30, .05);
  --shadow-pop: 0 8px 34px rgba(24, 26, 30, .16);
  --due-pill-bg: #FFF4E2;
  --due-pill-text: #9A6B1E;
  --chip: #EDEBE5;
}

html[data-theme="dark"] {
  --bg: #17181A;
  --bg-nav: #1D1F21;
  --bg-compose: #1D1F21;
  --surface: #212326;
  --surface-2: #26282C;
  --surface-hover: #2A2D31;
  --border: #31343A;
  --border-strong: #3D4147;
  --text: #E6E7E9;
  --text-2: #A2A7AD;
  --text-3: #6E747B;
  --accent: #3EC48C;
  --accent-soft: #1E3329;
  --accent-text: #10201A;
  --danger: #E0735E;
  --danger-soft: #34211D;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .28);
  --shadow-pop: 0 8px 34px rgba(0, 0, 0, .5);
  --due-pill-bg: #33291A;
  --due-pill-text: #E3B86B;
  --chip: #2A2D31;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
input, textarea { outline: none; }

::selection { background: var(--accent); color: var(--accent-text); }

/* ============================================================
   三栏骨架
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--nav-w) var(--compose-w) minmax(0, 1fr);
  height: 100%;
}

/* ---------------- 左栏：导航 ---------------- */
.col-nav {
  width: var(--nav-w);
  background: var(--bg-nav);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 10px 12px;
  gap: 14px;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 2px;
}
.brand-mark {
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: .3px; }

.nav-search {
  position: relative;
  display: flex;
  align-items: center;
}
.nav-search-icon {
  position: absolute;
  left: 8px;
  color: var(--text-3);
  pointer-events: none;
}
.nav-search input {
  width: 100%;
  height: 30px;
  padding: 0 8px 0 26px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.nav-search input::placeholder { color: var(--text-3); }
.nav-search input:focus { border-color: var(--accent); background: var(--surface); }
.nav-search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.nav-menu { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  text-align: left;
  transition: background .12s, color .12s;
}
.nav-item svg { flex: none; opacity: .85; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.is-active svg { opacity: 1; }

.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }

.ic-moon { display: none; }
html[data-theme="dark"] .ic-sun { display: none; }
html[data-theme="dark"] .ic-moon { display: block; }

/* ---------------- 中栏：批量录入 ---------------- */
.col-compose {
  width: var(--compose-w);
  background: var(--bg-compose);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 14px 14px;
  gap: 12px;
}

.compose-head { padding: 0 2px; }
.compose-title { font-size: 15px; font-weight: 600; }
.compose-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }

.compose-input {
  flex: 1;
  width: 100%;
  min-height: 0;
  resize: none;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  line-height: 1.85;
  font-size: 13.5px;
}
.compose-input::placeholder { color: var(--text-3); line-height: 1.85; }
.compose-input:focus { border-color: var(--accent); }

.compose-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.compose-hint { font-size: 11.5px; color: var(--text-3); }

.split-btn {
  margin-left: auto;
  margin-right: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .12s, color .12s;
}

.split-btn:hover { border-color: var(--accent); color: var(--accent); }
.split-btn:disabled { opacity: .5; cursor: default; }
kbd {
  display: inline-block;
  padding: 0 4px;
  min-width: 17px;
  text-align: center;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  font-family: inherit;
  font-size: 10.5px;
  color: var(--text-2);
}

.btn-primary {
  padding: 0 14px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 600;
  transition: opacity .12s;
}
.btn-primary:hover { opacity: .9; }
.btn-primary:disabled { opacity: .4; cursor: default; }

.btn-ghost {
  padding: 0 14px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-3); }

/* ---------------- 右栏：卡片流 ---------------- */
.col-stream {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.stream-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 16px 22px 10px;
  flex: none;
}
.stream-title { font-size: 15px; font-weight: 600; }
.stream-count { font-size: 12px; color: var(--text-3); }

.stream-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 22px 40px;
  scrollbar-width: thin;
}
.stream-scroll::-webkit-scrollbar { width: 9px; }
.stream-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 9px;
  border: 3px solid var(--bg);
}

.cards { display: flex; flex-direction: column; gap: 12px; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px 10px;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.card-time {
  font-size: 11.5px;
  color: var(--text-3);
  letter-spacing: .2px;
}
.card-del {
  opacity: 0;
  width: 22px; height: 22px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  transition: opacity .12s, background .12s, color .12s;
}
.card:hover .card-del { opacity: 1; }
.card-del:hover { background: var(--danger-soft); color: var(--danger); }

.card-items { display: flex; flex-direction: column; }

/* ---------------- 条目 ---------------- */
.item { border-top: 1px solid transparent; }
.item + .item { border-top-color: var(--border); }

.item-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 7px 2px;
}
.item-check {
  flex: none;
  width: 16px; height: 16px;
  margin-top: 2px;
  border-radius: 50%;
  border: 1.6px solid var(--border-strong);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  color: transparent;
  transition: border-color .12s, background .12s, color .12s;
}
.item-check:hover { border-color: var(--accent); }
.item-check svg { width: 10px; height: 10px; }
.item.done .item-check { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.item-main { flex: 1; min-width: 0; }
.item-text {
  cursor: text;
  word-break: break-word;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.5;
  outline: none;
  border-radius: 4px;
}
.item-text:focus { background: var(--surface-hover); }
.item.done .item-text { color: var(--text-3); text-decoration: line-through; }

.item-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.due-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--due-pill-bg);
  color: var(--due-pill-text);
  font-size: 11px;
  line-height: 1.7;
}
.due-pill.is-over { background: var(--danger-soft); color: var(--danger); }
.remark-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--chip);
  color: var(--text-2);
  font-size: 11px;
  line-height: 1.7;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-expand {
  margin: 2px 0 8px 25px;
  padding: 8px 0 8px 12px;
  border-left: 2px solid var(--border-strong);
  display: none;
}
.item.open .item-expand { display: block; }

.exp-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.exp-label { font-size: 11.5px; color: var(--text-3); flex: none; width: 32px; }

.exp-remark {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  resize: none;
  line-height: 1.5;
}
.exp-remark:focus { border-color: var(--accent); background: var(--surface); }

.exp-due {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12.5px;
}
.exp-due:focus { border-color: var(--accent); }
html[data-theme="dark"] .exp-due::-webkit-calendar-picker-indicator { filter: invert(1) opacity(.7); }

.quick-btns { display: flex; gap: 5px; flex-wrap: wrap; }
.quick-btn {
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
}
.quick-btn:hover { border-color: var(--accent); color: var(--accent); }

.exp-actions { display: flex; gap: 6px; margin-top: 8px; }
.exp-btn {
  padding: 2px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 11.5px;
}
.exp-btn:hover { border-color: var(--border-strong); color: var(--text); }
.exp-btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

/* ---------------- 空态 / 底部 ---------------- */
.stream-foot {
  padding: 18px 0 10px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}
.empty {
  padding: 60px 0;
  text-align: center;
}
.empty-title { font-size: 14px; color: var(--text-2); }
.empty-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ============================================================
   手机端：悬浮按钮 + 全屏录入
   ============================================================ */
.fab { display: none; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.sheet[hidden] { display: none; }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.sheet-title { font-size: 15px; font-weight: 600; }
.sheet-cancel, .sheet-save { font-size: 14px; color: var(--text-2); min-width: 44px; }
.sheet-save { color: var(--accent); font-weight: 600; text-align: right; }
.sheet-save:disabled { color: var(--text-3); font-weight: 400; }

.sheet-input {
  flex: 1;
  width: 100%;
  border: none;
  background: transparent;
  padding: 14px 16px;
  resize: none;
  font-size: 16px;
  line-height: 1.9;
  color: var(--text);
}
.sheet-input::placeholder { color: var(--text-3); }
.sheet-hint {
  flex: none;
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-3);
}

/* ============================================================
   设置弹层
   ============================================================ */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(20, 22, 26, .42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-mask[hidden] { display: none; }

.modal {
  width: 460px;
  max-width: 100%;
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
}
.modal-narrow { width: 340px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  width: 26px; height: 26px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
}
.modal-close:hover { background: var(--surface-hover); color: var(--text); }

.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field-input {
  height: 32px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}
.field-input:focus { border-color: var(--accent); background: var(--surface); }
.field-note { font-size: 11.5px; color: var(--text-3); }
.field-note code, .setting-block-note code {
  padding: 0 4px;
  border-radius: 4px;
  background: var(--chip);
  font-size: 11px;
}
.field-row { display: flex; gap: 10px; }
.field-half { flex: 1; min-width: 0; }

.setting-actions { display: flex; align-items: center; gap: 10px; }
.setting-status { font-size: 12px; color: var(--text-3); }
.setting-status.ok { color: var(--accent); }
.setting-status.err { color: var(--danger); }

.setting-block {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.setting-block-title { font-size: 12.5px; font-weight: 600; }
.setting-block-note { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }

/* 账号区 */
.acct-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
}
.acct-label { width: 48px; flex: none; font-size: 12.5px; color: var(--text-2); }
.acct-row .field-input { flex: 1; min-width: 0; }
.acct-val { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.acct-val.is-ok { color: var(--accent); }
.acct-val.is-off { color: var(--text-3); }

/* 登录/注册 tab */
.tabs { display: flex; gap: 4px; }
.tab {
  padding: 3px 12px;
  border-radius: 16px;
  font-size: 13px;
  color: var(--text-2);
}
.tab.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.link-btn {
  font-size: 12.5px;
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--accent); }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 120;
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  box-shadow: var(--shadow-pop);
}
.toast[hidden] { display: none; }

/* ============================================================
   响应式：<=760px 降级为单栏
   ============================================================ */
@media (max-width: 760px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .col-nav {
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
  }
  .brand { padding: 0; }
  .brand-name { display: none; }
  .nav-search { flex: 1; min-width: 90px; max-width: 240px; }
  .nav-menu { flex-direction: row; gap: 4px; }
  .nav-foot { margin: 0; flex-direction: row; gap: 4px; margin-left: auto; }
  .nav-item { width: auto; padding: 0 9px; height: 30px; }
  .nav-item span { display: none; }
  .nav-item.is-active span { display: inline; }
  #themeBtn span { display: none !important; }

  .col-compose { display: none; }

  .col-stream { grid-column: 1; }
  .stream-head { padding: 12px 14px 8px; }
  .stream-scroll { padding: 0 14px 90px; }

  .fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 18px;
    bottom: calc(22px + env(safe-area-inset-bottom));
    z-index: 50;
    width: 54px; height: 54px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-text);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
  }
}
