:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --border: #e5e7eb;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --card: #1f2937;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --accent: #60a5fa;
    --border: #374151;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--card); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 18px; white-space: nowrap; }
.brand a { color: var(--text); }
.brand .dot { color: var(--muted); }
.who { position: relative; }
.who > summary { list-style: none; cursor: pointer; color: var(--accent); }
.who > summary::-webkit-details-marker { display: none; }
.who > summary::after { content: "▾"; font-size: 12px; margin-left: 2px; color: var(--muted); }
.who-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 20; min-width: 110px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .08); padding: 4px 0;
}
.who-menu a { display: block; padding: 8px 14px; font-size: 15px; font-weight: 500; }
.who-menu a.active { color: var(--accent); font-weight: 700; }
nav a { margin-left: 14px; color: var(--muted); font-size: 15px; }
nav a.active { color: var(--accent); font-weight: 600; }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 32px); }
h1 { font-size: 24px; margin: 4px 0 16px; }
.today { color: var(--muted); margin: 0 0 12px; }
.section-title { font-size: 17px; margin: 24px 0 10px; display: flex; justify-content: space-between; }
.more { font-size: 14px; font-weight: 400; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.meet { margin-bottom: 12px; }
.meet > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 40px; }
.meet > summary::-webkit-details-marker { display: none; }
.meet-date { font-size: 18px; font-weight: 600; }
.meet-days { color: var(--muted); white-space: nowrap; }
.meet-days b { font-size: 30px; color: var(--accent, #e0457b); margin: 0 2px; }
.meet-form { display: flex; gap: 8px; margin-top: 12px; }
.meet-form input { flex: 1; min-width: 0; }
.meet-form .meet-clear { background: var(--bg); color: var(--muted); }
.weather-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.weather-head { display: flex; justify-content: space-between; align-items: center; }
.weather { position: relative; }
.weather h2 { font-size: 22px; margin: 0; padding-right: 96px; }
.weather .icon { position: absolute; top: 12px; right: 16px; font-size: 88px; line-height: 1; }
.weather .temp { font-size: 60px; font-weight: 700; line-height: 1.1; margin: 6px 0 4px; }
.weather .desc { color: var(--muted); font-size: 14px; }
.forecast { list-style: none; padding: 0; margin: 12px 0 0; border-top: 1px solid var(--border); }
.forecast li { display: grid; grid-template-columns: 3.2em 1.6em 1fr auto 4em; align-items: center; gap: 6px; padding: 6px 0; font-size: 14px; }
.forecast .fc-icon { font-size: 20px; line-height: 1; }
.forecast .fc-rain { text-align: right; }
.form { display: flex; flex-direction: column; gap: 10px; }
.form.inline { flex-direction: row; }
.form.inline input { flex: 1; min-width: 0; }
input, textarea, button { font: inherit; font-size: 16px; }
input:not([type=radio]):not([type=range]), textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
textarea { resize: vertical; }
button {
  padding: 10px 18px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); margin-top: 10px; }
button.link { background: none; color: var(--muted); padding: 0; font-weight: 400; font-size: 13px; }
.eink-status { display: flex; gap: 12px; align-items: center; margin-top: 8px; font-size: 14px; flex-wrap: wrap; }
.eink-status form { margin: 0; }
.messages { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 10px; }
.message .meta { display: flex; gap: 10px; align-items: baseline; font-size: 13px; color: var(--muted); }
.message .meta strong { color: var(--text); font-size: 14px; }
.message .meta form { margin-left: auto; }
.message p { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; }
.empty { color: var(--muted); text-align: center; padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius); padding: 14px; font-size: 14px; }
img.eink { width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; background: #fff; display: block; }
.segmented { display: flex; gap: 16px; }
.range { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.range input { flex: 1; }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.form-foot button { margin-left: auto; }
.form.compact input { padding: 8px 10px; }
.form.compact button { padding: 8px 14px; }
.picker { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border); color: var(--text); font-size: 15px;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .count { font-size: 12px; opacity: .8; }
.new-list { margin-bottom: 12px; }
.new-list button.secondary { margin-top: 0; }
.todo-card { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.todo-card h3 { margin: 0; font-size: 16px; display: flex; gap: 8px; align-items: baseline; }
.todo-card h3 a { color: var(--text); }
.todo-items { list-style: none; padding: 0; margin: 0; }
.todo-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.todo-item:last-child { border-bottom: 0; }
.todo-item form { margin: 0; }
.todo-text { flex: 1; word-break: break-word; }
.todo-item.done .todo-text { text-decoration: line-through; color: var(--muted); }
.login-page { display: flex; justify-content: center; padding-top: 12vh; }
.login-card { width: min(340px, 100%); }
.login-card h1 { margin: 0 0 16px; text-align: center; }
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 14px; }
.login-card select { font: inherit; font-size: 16px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
.login-error { color: #dc2626; font-size: 14px; margin: 0; }
form.inline-edit { flex: 1; min-width: 0; display: flex; }
input.todo-text:not([type=radio]):not([type=range]) {
  width: 100%; min-width: 0; padding: 2px 0; border: 0; border-bottom: 1px solid transparent;
  border-radius: 0; background: transparent; color: inherit; cursor: text;
}
input.todo-text:not([type=radio]):not([type=range]):focus {
  outline: none; border-bottom-color: var(--accent); text-decoration: none; color: var(--text);
}
.sheet-list li.done input.todo-text { text-decoration: line-through; color: var(--muted); }
button.check {
  width: 24px; height: 24px; padding: 0; border-radius: 50%; flex-shrink: 0;
  background: transparent; border: 2px solid var(--muted); color: #fff; font-size: 14px; line-height: 1;
}
.todo-item.done button.check { background: var(--accent); border-color: var(--accent); }
.todo-actions { display: flex; flex-direction: column; gap: 10px; }
.todo-actions details form { margin-top: 8px; }
button.link.danger { color: #dc2626; }
:root { --chat-bg: #ededed; --mine: #95ec69; --mine-text: #111; --other: #fff; }
@media (prefers-color-scheme: dark) {
  :root { --chat-bg: #111111; --mine: #3eb575; --mine-text: #fff; --other: #2c2c2c; }
}
body.page-chat { background: var(--chat-bg); }
.chat { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.chat-time { align-self: center; font-size: 12px; color: var(--muted); }
.bubble-row { display: flex; gap: 10px; align-items: flex-start; }
.bubble-row.mine { flex-direction: row-reverse; }
.avatar {
  width: 40px; height: 40px; border-radius: 6px; flex: none; display: grid; place-items: center;
  color: #fff; font-weight: 600; font-size: 17px;
}
.av-0 { background: #f59e0b; } .av-1 { background: #ec4899; } .av-2 { background: #10b981; }
.av-3 { background: #8b5cf6; } .av-4 { background: #9ca3af; }
.bubble-col { display: flex; flex-direction: column; align-items: flex-start; max-width: calc(100% - 100px); }
.mine .bubble-col { align-items: flex-end; }
.bubble {
  position: relative; padding: 9px 12px; border-radius: 6px; background: var(--other); color: var(--text);
  font-size: 16px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; outline: none;
}
.bubble::before {
  content: ""; position: absolute; top: 14px; left: -6px; border-style: solid;
  border-width: 6px 6px 6px 0; border-color: transparent var(--other) transparent transparent;
}
.mine .bubble { background: var(--mine); color: var(--mine-text); }
.mine .bubble::before { left: auto; right: -6px; border-width: 6px 0 6px 6px; border-color: transparent transparent transparent var(--mine); }
.bubble-actions { display: none; margin: 4px 0 0; }
.bubble-col:focus-within .bubble-actions { display: block; }
.chat-card { background: var(--chat-bg); display: flex; flex-direction: column; gap: 14px; }
.chat-bar { display: flex; gap: 8px; align-items: flex-end; }
.chat-bar textarea { flex: 1; min-width: 0; resize: none; height: 42px; max-height: 120px; background: var(--card); }
.chat-bar input.chat-name { width: 72px; flex: none; background: var(--card); }
.chat-bar button { flex: none; background: #07c160; }
.chat-bar.fixed {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  max-width: 760px; margin: 0 auto;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 8px);
  background: var(--card); border-top: 1px solid var(--border);
}
.chat-page { padding-bottom: 80px; }

main.wide { max-width: 1200px; }
.todo-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 28px; }
.todo-head h1 { margin: 0; }
.todo-head form { flex: 0 1 360px; }
.todo-head button.secondary { margin-top: 0; }
.todo-board { display: flex; flex-direction: column; gap: 10px; }
details.todo-list { padding: 0; margin-bottom: 10px; }
.todo-board details.todo-list { margin-bottom: 0; }
details.todo-list > summary {
  list-style: none; display: flex; align-items: center; gap: 8px; padding: 14px 16px;
  cursor: pointer; font-weight: 600; font-size: 16px;
}
details.todo-list > summary::-webkit-details-marker { display: none; }
details.todo-list > summary::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 22px; line-height: 1; transition: transform .15s; }
details.todo-list[open] > summary::after { transform: rotate(90deg); }
details.todo-list .count { background: var(--bg); color: var(--muted); border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 500; }
.todo-body { padding: 0 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.list-settings > summary { cursor: pointer; }
@media (min-width: 768px) {
  .todo-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); align-items: start; gap: 16px; }
  .todo-board details.todo-list > summary { cursor: default; }
  .todo-board details.todo-list > summary::after { display: none; }
}
.todo-board .todo-items {
  height: 280px; overflow-y: auto; overscroll-behavior: contain;
  background: repeating-linear-gradient(to bottom, transparent 0 39px, var(--border) 39px 40px);
  background-attachment: local;
}
.todo-board .todo-item { height: 40px; box-sizing: border-box; padding: 0; }
.todo-board .todo-item:last-child { border-bottom: 1px solid var(--border); }
.todo-board .todo-text { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.todo-board .todo-items .empty { display: none; }
.todo-board .todo-items { scrollbar-width: thin; scrollbar-color: var(--muted) transparent; }
.chat-img { display: block; max-width: 100%; height: auto; border-radius: 6px; cursor: zoom-in; background: var(--border); outline: none; }
.img-btn {
  flex: none; width: 42px; height: 42px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--muted);
}
.chat-bar.sending .img-btn { opacity: .4; pointer-events: none; }
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .9); display: grid; place-items: center; cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
@media (min-width: 1000px) { .todo-board { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1200px) {
  .todo-board {
    --board-w: min(calc(100vw - 48px), 1800px);
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: var(--board-w); margin-left: calc(50% - var(--board-w) / 2);
  }
}
@media (min-width: 768px) and (max-width: 999px) { .todo-board { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.home-chat { height: 320px; overflow-y: auto; overscroll-behavior: contain; cursor: pointer; margin: -4px -4px 0; padding: 4px; }
.home-chat .chat-img { width: auto; height: 120px; max-width: 100%; object-fit: cover; }
.home-chat .bubble { cursor: auto; }

.eink-stage { position: relative; max-width: 800px; }
.eink-stage .hotspot {
  position: absolute; margin: 0; padding: 0; background: transparent;
  border: 2px dashed transparent; border-radius: 1.8%/3%; cursor: pointer;
}
.eink-stage .hotspot:hover, .eink-stage .hotspot:focus-visible {
  border-color: var(--accent); background: rgba(37, 99, 235, .08);
}
.eink-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.eink-actions button { margin: 0; }
dialog.sheet {
  width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  border: 1px solid var(--border); border-radius: 16px; padding: 0;
  background: var(--card); color: var(--text); box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, .35); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 4px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-head form { margin: 0; }
.sheet-x {
  width: 32px; height: 32px; padding: 0; border-radius: 50%;
  background: var(--bg); color: var(--muted); font-size: 15px; font-weight: 400;
}
.sheet-body { padding: 8px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.sheet-body form { margin: 0; }
.sheet-body .note { margin: 0; color: var(--muted); font-size: 13px; }
.sheet-label { margin: 4px 0 -4px; color: var(--muted); font-size: 13px; }
dialog.sheet button { margin-top: 0; }
.field-row { display: flex; gap: 8px; align-items: stretch; }
.field-row input { flex: 1; min-width: 0; height: 44px; }
.field-row button { height: 44px; padding: 0 18px; flex-shrink: 0; }
.pick-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.pick-list:empty { display: none; }
.pick {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; text-align: left; font-weight: 500;
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
}
.pick small { color: var(--muted); font-weight: 400; font-size: 13px; }
.pick .pick-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pick.on { border-color: var(--accent); color: var(--accent); }
.pick .tick { font-weight: 700; }
.recent-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.recent-list li {
  display: inline-flex; align-items: center; height: 34px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg);
}
.recent-list li.on { border-color: var(--accent); }
.recent-list form { margin: 0; display: flex; height: 100%; }
.recent-list button {
  margin: 0; border: 0; border-radius: 0; background: none; height: 100%;
  font-size: 14px; font-weight: 500; color: var(--text);
}
.recent-list li.on .recent-pick { color: var(--accent); }
.recent-pick { padding: 0 4px 0 14px; }
.recent-x { padding: 0 12px 0 6px; color: var(--muted) !important; font-size: 16px !important; }
.recent-x:hover { color: #dc2626 !important; }
.geo-status { color: var(--muted); font-size: 13px; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  padding: 6px 12px; font-size: 14px; font-weight: 500;
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
}
.sheet-list { list-style: none; padding: 0; margin: 0; max-height: 40vh; overflow-y: auto; }
.sheet-list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border);
}
.sheet-list li:last-child { border-bottom: 0; }
.sheet-list li > span { flex: 1; overflow-wrap: anywhere; }
.sheet-list form { margin: 0; }
.sheet-list .days { color: var(--muted); font-size: 14px; white-space: nowrap; }
.sheet-list .empty { color: var(--muted); }
.countdown-add { display: flex; flex-direction: column; gap: 8px; }
.date-field { position: relative; flex: 0 0 150px; display: flex; }
.date-field input[name=day] { flex: 1; padding-right: 42px; }
.date-field .cal-icon {
  position: absolute; right: 12px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%);
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none;
}
.sheet .date-field input.date-pick {
  position: absolute; right: 4px; top: 4px; width: 36px; max-width: 36px; height: 36px; min-width: 0; flex: none;
  padding: 0; border: 0; opacity: 0; cursor: pointer;
}
.sheet-list li.done > span { text-decoration: line-through; color: var(--muted); }
.sheet-list li.done button.check { background: var(--accent); border-color: var(--accent); }
