:root, [data-theme='dark'] {
  --bg: #0b0b0c;
  --panel: #151517;
  --card: #1a1a1d;
  --line: #2a2a2f;
  --text: #ececef;
  --muted: #8c8c96;
  --accent: #9b8cff;
  --accent-ink: #0b0b0c;
  --pin: #ffcf5a;
  --danger: #ff6b6b;
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 14px;
  color-scheme: dark;
}
[data-theme='light'] {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --card: #ffffff;
  --line: #e2e2e8;
  --text: #17171a;
  --muted: #6c6c78;
  --accent: #5b4bdb;
  --accent-ink: #fff;
  --pin: #d99400;
  color-scheme: light;
}
[data-theme='ink'] {
  --bg: #eae8e3;
  --panel: #f3f1ec;
  --card: #f7f5f0;
  --line: #cfccc4;
  --text: #1d1c1a;
  --muted: #6e6a62;
  --accent: #1d1c1a;
  --accent-ink: #f7f5f0;
  --pin: #a3461f;
  --font: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --radius: 4px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; gap: 14px; align-items: center;
  padding: 12px 20px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -0.01em; }
.search { flex: 1; max-width: 520px; }
.search input, .editor input, .editor textarea, .editor select {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); outline: none;
}
.search input:focus, textarea:focus, .editor input:focus { border-color: var(--accent); }
.views { margin-left: auto; }
.views, .seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.views button, .seg button { border: 0; background: none; padding: 5px 11px; border-radius: 7px; color: var(--muted); }
.views button.on, .seg button.on { background: var(--accent); color: var(--accent-ink); }
.icon-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 6px 10px; line-height: 1; display: inline-flex; align-items: center; }
.primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 8px 16px; font-weight: 600; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; }
.danger { color: var(--danger); }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 300px; padding: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.3); display: flex; flex-direction: column; gap: 8px;
}
.menu-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 4px; }
.menu-item { text-align: left; background: none; border: 0; padding: 7px 4px; border-radius: 6px; }
.menu-item:hover { background: var(--card); }

main { max-width: 1280px; margin: 0 auto; padding: 20px; }

/* composer */
.composer { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0 auto 18px; max-width: 720px; }
.composer textarea { width: 100%; border: 0; background: none; resize: none; outline: none; padding: 10px 4px; font-size: 16px; min-height: 52px; }
.composer-bar { display: flex; align-items: center; gap: 8px; }
.hint { color: var(--muted); font-size: 13px; margin-right: auto; }
.hint.warn { color: var(--pin); }
.thumbs { display: flex; gap: 4px; }
.thumbs img { width: 32px; height: 32px; object-fit: cover; border-radius: 6px; cursor: pointer; }
.type-seg { font-size: 13px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.filters .seg { font-size: 13px; }
.tagbar { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 12px; letter-spacing: 0.04em; font-weight: 600; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); padding: 3px 9px; border-radius: 999px;
}
.tag.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tag .n { opacity: 0.6; margin-left: 4px; font-weight: 400; }

/* feed */
.feed { columns: 300px; column-gap: 14px; }
.card {
  break-inside: avoid; margin-bottom: 14px; padding: 14px 14px 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; position: relative; transition: border-color 0.15s, transform 0.15s;
  overflow-wrap: anywhere;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.card.pinned { border-color: color-mix(in srgb, var(--pin) 60%, var(--line)); }
.card.done .body, .card.done .title { text-decoration: line-through; opacity: 0.55; }
.card.dragging { opacity: 0.4; }
.card.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.card .title { font-weight: 700; margin-bottom: 4px; }
.card .body { white-space: pre-wrap; }
.card .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }
.card .meta .spacer { flex: 1; }
.card .quick { opacity: 0; transition: opacity 0.15s; display: flex; gap: 2px; }
.card:hover .quick, .card:focus-within .quick { opacity: 1; }
.card .quick button { background: none; border: 0; padding: 2px 5px; border-radius: 6px; color: var(--muted); }
.card .quick button:hover { background: var(--panel); color: var(--text); }
.badge { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.badge .pin { color: var(--pin); }
.when { display: inline-block; padding: 3px 8px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; margin-top: 8px; }
.when.overdue { color: var(--danger); }
.items { list-style: none; padding: 0; margin: 6px 0 0; }
.items li { display: flex; gap: 8px; align-items: flex-start; padding: 2px 0; }
.items li.checked span { text-decoration: line-through; color: var(--muted); }
.items input { margin-top: 4px; accent-color: var(--accent); }
.link { display: block; margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); text-decoration: none; color: var(--text); font-size: 13px; }
.link small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.yt { position: relative; display: block; margin-top: 8px; }
.yt img { width: 100%; border-radius: 10px; display: block; aspect-ratio: 16/9; object-fit: cover; }
.yt::after { content: '▶'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; color: #fff; text-shadow: 0 2px 12px rgb(0 0 0 / 0.6); }
.attach { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 4px; margin-top: 8px; }
.attach img { width: 100%; border-radius: 8px; object-fit: cover; max-height: 220px; }
.attach.single { grid-template-columns: 1fr; }
mark { background: color-mix(in srgb, var(--pin) 45%, transparent); color: inherit; border-radius: 3px; }

/* board */
.board { display: flex; gap: 14px; overflow-x: auto; align-items: flex-start; padding-bottom: 20px; }
.col { flex: 0 0 290px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.col.over { border-color: var(--accent); }
.col h3 { margin: 2px 4px 10px; font-size: 13px; letter-spacing: 0.06em; display: flex; justify-content: space-between; }
.col h3 span { color: var(--muted); font-weight: 400; }
.col .card { margin-bottom: 10px; }

/* calendar */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cal-head h2 { margin: 0; font-size: 20px; min-width: 200px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { font-size: 12px; color: var(--muted); text-align: center; text-transform: uppercase; }
.cal-day { min-height: 104px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px; font-size: 12px; cursor: pointer; overflow: hidden; }
.cal-day.other { opacity: 0.4; }
.cal-day.today { border-color: var(--accent); }
.cal-day.sel { outline: 2px solid var(--accent); }
.cal-day .d { font-weight: 700; margin-bottom: 4px; }
.cal-day .ev { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 1px 5px; border-radius: 5px; margin-bottom: 2px; background: color-mix(in srgb, var(--accent) 20%, transparent); }
.cal-day .ev.note { background: none; color: var(--muted); }
.cal-list { margin-top: 18px; }

.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* editor */
dialog.editor {
  width: min(620px, 94vw); max-height: 88vh; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--text); padding: 20px;
}
dialog::backdrop { background: rgb(0 0 0 / 0.55); backdrop-filter: blur(2px); }
.editor h2 { margin: 0 0 10px; }
.editor h3 { margin: 16px 0 4px; font-size: 15px; }
.editor label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.editor textarea { min-height: 140px; resize: vertical; }
.editor .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.editor .row.end { justify-content: flex-end; }
.editor .row .spacer { flex: 1; }
.editor .item-row { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.editor .item-row input[type='text'] { flex: 1; padding: 6px 10px; }
.editor .item-row button { background: none; border: 0; color: var(--muted); }
.editor code, #help code { background: var(--card); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.editor .stamp { font-size: 12px; color: var(--muted); }

/* toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; box-shadow: 0 8px 30px rgb(0 0 0 / 0.3); display: flex; gap: 12px; align-items: center; animation: up 0.2s ease-out; }
.toast button { background: none; border: 0; color: inherit; font-weight: 700; text-decoration: underline; }
.toast.reminder { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }

@media (max-width: 720px) {
  .top { flex-wrap: wrap; padding: 10px 12px; }
  .search { order: 5; flex-basis: 100%; max-width: none; }
  main { padding: 12px; }
  .feed { columns: 1; }
  .card .quick { opacity: 1; }
  .cal-day { min-height: 64px; }
  .cal-day .ev { display: none; }
  .cal-day.has::after { content: '•'; color: var(--accent); }
}
