:root {
    color-scheme: light;
    --bg: #f4f3f0;
    --surface-1: #fcfcfb;
    --surface-2: #f0efec;
    --border: #e2e0da;
    --text-primary: #0b0b0b;
    --text-secondary: #52514e;
    --text-muted: #7a7974;
    --accent: #c98500;
    --accent-strong: #8a5a00;
    --link: #2a78d6;
    --critical: #d03b3b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 2px 8px rgba(0, 0, 0, .04);
    --radius: 10px;
    /* label hues: background / text */
    --l0b: #e3eefb; --l0t: #1d4f8f;
    --l1b: #fde8df; --l1t: #9a3a12;
    --l2b: #dcf3ea; --l2t: #0e6b4a;
    --l3b: #fcf0d2; --l3t: #7a5200;
    --l4b: #efe4fa; --l4t: #5b2d8c;
    --l5b: #fbe2ea; --l5t: #8f1f45;
    --l6b: #e0f1f6; --l6t: #155e73;
    --l7b: #ebeae6; --l7t: #3f3e3a;
}
@media (prefers-color-scheme: dark) {
    :root:where(:not([data-theme="light"])) {
        color-scheme: dark;
        --bg: #121211;
        --surface-1: #1a1a19;
        --surface-2: #232321;
        --border: #33332f;
        --text-primary: #f0efec;
        --text-secondary: #c3c2b7;
        --text-muted: #8f8e86;
        --accent: #eda100;
        --accent-strong: #fab219;
        --link: #6da7ec;
        --critical: #e5625c;
        --shadow: none;
        --l0b: #1d2b3d; --l0t: #9cc4f2;
        --l1b: #3a2219; --l1t: #f2a582;
        --l2b: #16302a; --l2t: #79d3b0;
        --l3b: #362b12; --l3t: #f0c75e;
        --l4b: #2c2238; --l4t: #c9a6f0;
        --l5b: #38202a; --l5t: #f09ab7;
        --l6b: #172f36; --l6t: #85cde2;
        --l7b: #2a2a27; --l7t: #c3c2b7;
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #121211; --surface-1: #1a1a19; --surface-2: #232321; --border: #33332f;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
    --accent: #eda100; --accent-strong: #fab219; --link: #6da7ec; --critical: #e5625c; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--text-primary);
    font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
h1, h2 { line-height: 1.25; }
.muted { color: var(--text-muted); }
.error-text { color: var(--critical); margin-top: 14px; min-height: 1em; }
.loading { padding: 48px 0; text-align: center; color: var(--text-muted); }
button.link { background: none; border: 0; color: var(--link); cursor: pointer; font: inherit; padding: 4px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card.warn { border-color: var(--accent); margin-bottom: 16px; font-size: 14px; }
.card.empty { color: var(--text-secondary); text-align: center; padding: 32px 18px; }

/* header */
.top { background: var(--surface-1); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.top-in { display: flex; align-items: center; gap: 12px; height: 56px; }
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; color: var(--text-primary); }
.brand:hover { text-decoration: none; }
.brand span { color: var(--accent); }
.brand.center { justify-content: center; font-size: 20px; }
.user { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); min-width: 0; }
.user img { width: 26px; height: 26px; border-radius: 50%; }
.user .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) { .user .email { display: none; } }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .card { width: 360px; max-width: 100%; text-align: center; padding: 32px 28px; }
.login #gbtn { display: flex; justify-content: center; margin-top: 18px; min-height: 44px; }

/* list */
.page-head { padding: 28px 0 8px; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; }
.page-head p { margin: 0; font-size: 14px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 12px; }
.toolbar input, .toolbar select {
    font: inherit; font-size: 14px; color: var(--text-primary); background: var(--surface-1);
    border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-height: 38px;
}
.toolbar input { flex: 1 1 260px; min-width: 0; }
.toolbar select { flex: 0 1 auto; max-width: 100%; }
.toolbar input:focus, .toolbar select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.labels-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.labels-bar button { font: inherit; font-size: 13px; cursor: pointer; border: 1px solid transparent; }
.labels-bar button b { font-weight: 600; opacity: .65; margin-left: 2px; }
.labels-bar button.on { border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; }
.label-all { background: var(--surface-1); color: var(--text-secondary); border-color: var(--border) !important; border-radius: 999px; padding: 3px 10px; }
.label-all.on { color: var(--text-primary); border-color: var(--text-primary) !important; }

.label { display: inline-flex; align-items: center; gap: 3px; border-radius: 999px; padding: 2px 9px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.l0 { background: var(--l0b); color: var(--l0t); } .l1 { background: var(--l1b); color: var(--l1t); }
.l2 { background: var(--l2b); color: var(--l2t); } .l3 { background: var(--l3b); color: var(--l3t); }
.l4 { background: var(--l4b); color: var(--l4t); } .l5 { background: var(--l5b); color: var(--l5t); }
.l6 { background: var(--l6b); color: var(--l6t); } .l7 { background: var(--l7b); color: var(--l7t); }

.status { font-size: 12px; font-weight: 600; border-radius: 6px; padding: 2px 8px; border: 1px solid var(--border); color: var(--text-secondary); background: var(--surface-2); }
.s-idea { color: var(--accent-strong); border-color: var(--accent); background: transparent; }
.s-refining { color: var(--l4t); background: var(--l4b); border-color: transparent; }
.s-planned { color: var(--l0t); background: var(--l0b); border-color: transparent; }
.s-in-progress { color: var(--l2t); background: var(--l2b); border-color: transparent; }
.s-done { color: var(--l2t); background: transparent; border-color: var(--l2t); }
.s-dropped { color: var(--text-muted); text-decoration: line-through; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; padding-bottom: 40px; }
@media (max-width: 400px) { .grid { grid-template-columns: 1fr; } }
.idea { display: flex; flex-direction: column; gap: 8px; color: var(--text-primary); transition: border-color .12s, transform .12s; }
.idea:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.idea h2 { margin: 0; font-size: 17px; }
.idea-top { display: flex; align-items: center; gap: 8px; }
.key { font: 600 12.5px/1.3 ui-monospace, Menlo, Consolas, monospace; color: var(--accent-strong); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; overflow-wrap: anywhere; }
.excerpt { margin: 0; color: var(--text-secondary); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.idea-labels { display: flex; flex-wrap: wrap; gap: 5px; }
.idea-labels a:hover { text-decoration: none; }
.idea-foot { margin-top: auto; padding-top: 6px; display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; flex-wrap: wrap; }

/* detail */
.back { display: inline-block; margin-top: 22px; font-size: 14px; }
.detail { max-width: 780px; padding-bottom: 60px; }
.detail h1 { font-size: 28px; margin: 10px 0 10px; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 26px; margin: 16px 0 18px; font-size: 13px; }
.meta div { min-width: 0; }
.meta dt { color: var(--text-muted); font-size: 12px; }
.meta dd { margin: 0; }
.section-title { font-size: 18px; margin: 32px 0 12px; }
.section-title .muted { font-weight: 500; font-size: 14px; margin-left: 4px; }
.prose { overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-size: 16px; margin: 18px 0 6px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose blockquote { margin: 10px 0; padding: 2px 12px; border-left: 3px solid var(--accent); color: var(--text-secondary); }
.prose pre { background: var(--surface-2); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; font-size: 14px; }
.prose th, .prose td { border: 1px solid var(--border); padding: 5px 9px; text-align: left; }
.prose th { background: var(--surface-2); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); }
.timeline li { position: relative; margin: 0 0 18px; }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.timeline .when { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
