:root {
    --yellow-bg: #fff59d;
    --pink-bg: #f8bbd0;
    --blue-bg: #b3e5fc;
    --green-bg: #c8e6c9;
    --danger: #e64553;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--wall-bg, #1e1f26);
    color: var(--text);
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
body[data-ink="light"] {
    --surface: rgba(22, 24, 32, 0.78);
    --text: #f8f8f2;
    --muted: #c3c6d7;
    --line: rgba(255, 255, 255, 0.14);
    --input-bg: rgba(0, 0, 0, 0.28);
    --dot: rgba(255, 255, 255, 0.05);
}
body[data-ink="dark"] {
    --surface: rgba(255, 255, 255, 0.92);
    --text: #1c1917;
    --muted: #57534e;
    --line: rgba(0, 0, 0, 0.1);
    --input-bg: #ffffff;
    --dot: rgba(0, 0, 0, 0.04);
}
body[data-theme="dark"] {
    background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 0);
    background-size: 22px 22px;
}
body[data-theme="light"],
body[data-theme="custom"][data-ink="dark"] {
    background-image: radial-gradient(rgba(0, 0, 0, 0.035) 1px, transparent 0);
    background-size: 22px 22px;
}
header.topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-size: 1.15rem;
}
.brand-badge {
    width: 18px;
    height: 18px;
    background: var(--yellow-bg);
    box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.25);
    transform: rotate(-8deg);
    border-radius: 2px;
}
.user-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.88rem;
}
.btn, .icon-btn, select, input, textarea, button { font-family: inherit; }
.btn, .icon-btn {
    cursor: pointer;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--input-bg);
    color: var(--text);
    font-weight: 650;
    font-size: 0.86rem;
}
.btn { padding: 0.48rem 0.8rem; }
.icon-btn {
    width: 2.3rem;
    height: 2.3rem;
    font-size: 1.15rem;
    line-height: 1;
}
.btn-primary {
    background: #fde047;
    color: #18181b;
    border-color: transparent;
}
.workspace {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0.75rem 0 0.4rem;
}
.toolbar {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
    gap: 0.75rem;
    padding: 0 1rem 0.75rem;
}
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.8rem;
    color: var(--text);
}
.panel h2 {
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.55rem;
}
textarea, input[type="text"], input[type="password"], input[type="search"], select {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--input-bg);
    color: var(--text);
    padding: 0.55rem 0.7rem;
    font-size: 0.95rem;
}
textarea { min-height: 64px; max-height: 110px; resize: vertical; }
textarea:focus, input:focus, select:focus { outline: 2px solid #fde047; border-color: transparent; }
.composer-footer, .filter-row, .settings-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.composer-footer { margin-top: 0.55rem; justify-content: space-between; }
.composer-footer select, .filter-row select { width: auto; min-width: 9.5rem; }
.search-input { min-width: 0; }
.filter-row { align-items: stretch; }
.filter-row .search-input { flex: 1 1 140px; }
.swipe-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0 1rem 0.45rem;
    color: var(--muted);
    font-size: 0.8rem;
}
.board-shell {
    flex: 1;
    min-height: 0;
}
#notes-wall {
    height: 100%;
    display: flex;
    flex-flow: column wrap;
    align-content: flex-start;
    align-items: flex-start;
    gap: 0.75rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    padding: 0.35rem 1rem 0.8rem;
}
article.post-it {
    width: min(300px, calc(100vw - 1.75rem));
    max-height: 100%;
    overflow: auto;
    flex: 0 0 auto;
    scroll-snap-align: start;
    padding: 1.15rem 1rem 0.85rem;
    border-radius: 2px 2px 12px 2px;
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.28), 0 2px 4px rgba(0, 0, 0, 0.16);
    position: relative;
}
article.post-it::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 64px;
    height: 14px;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 1px;
}
.note-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.45;
    font-weight: 560;
    margin-bottom: 0.85rem;
}
.note-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.4rem;
    align-items: center;
    border-top: 1px dashed color-mix(in srgb, currentColor 25%, transparent);
    padding-top: 0.5rem;
    font-size: 0.72rem;
}
.note-actions { display: flex; gap: 0.35rem; flex: 0 0 auto; }
.note-btn {
    cursor: pointer;
    color: inherit;
    background: color-mix(in srgb, currentColor 10%, transparent);
    border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
    border-radius: 4px;
    padding: 0.22rem 0.45rem;
    font-size: 0.72rem;
    font-weight: 700;
}
.inline-edit-form textarea {
    min-height: 96px;
    background: rgba(255, 255, 255, 0.72);
    color: #1f2328;
}
.inline-edit-actions { display: flex; justify-content: flex-end; gap: 0.4rem; margin-top: 0.45rem; }
.empty-wall {
    width: min(420px, calc(100vw - 2rem));
    color: var(--muted);
    border: 2px dashed var(--line);
    border-radius: 12px;
    padding: 1.5rem;
    scroll-snap-align: start;
}
dialog.settings {
    width: min(520px, calc(100vw - 1.5rem));
    max-height: min(86dvh, 720px);
    margin: auto;
    overflow: auto;
    border: none;
    border-radius: 14px;
    background: #ffffff;
    color: #1c1917;
    padding: 1.1rem 1.1rem 1.25rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
body[data-ink="light"] dialog.settings {
    background: #242633;
    color: #f8f8f2;
}
dialog.settings .help,
dialog.settings h3,
dialog.settings label { color: inherit; }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog h2 { font-size: 1.15rem; margin-bottom: 0.35rem; }
dialog h3 { font-size: 0.92rem; margin: 1rem 0 0.45rem; }
.help { color: var(--muted); font-size: 0.84rem; margin-bottom: 0.8rem; }
.choice { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
.choice input { width: auto; }
.cat-list { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.7rem; }
.cat-list li {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.35rem 0.4rem;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.cat-edit { flex: 1; display: flex; align-items: center; gap: 0.4rem; }
.cat-edit input[type="text"] { flex: 1; min-width: 0; }
input[type="color"] { width: 2.6rem; height: 2.1rem; padding: 0.15rem; background: transparent; }
.auth-wrapper { max-width: 860px; margin: 3rem auto; padding: 0 1rem; overflow: auto; }
.auth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field { margin-bottom: 0.8rem; }
.field label, .settings-row label { display: block; color: var(--muted); font-size: 0.82rem; margin-bottom: 0.28rem; }
.alert-banner {
    background: rgba(230, 69, 83, 0.16);
    border: 1px solid var(--danger);
    color: #9f1239;
    padding: 0.75rem 0.9rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}
body[data-ink="light"] .alert-banner { color: #ffb4bc; }
@media (max-width: 800px) {
    .toolbar, .auth-grid { grid-template-columns: 1fr; }
    .user-meta .who { display: none; }
    header.topbar { padding-inline: 0.7rem; }
}
@media (max-width: 640px) {
    article.post-it { width: calc(100vw - 1.75rem); }
    .swipe-hint { display: none; }
}

/* Inline styles moved out of templates (CSP forbids inline style blocks) */
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.settings-row.spaced { margin-bottom: 0.7rem; }
#flash {
    position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%);
    background: #e64553; color: #fff; padding: 0.6rem 1rem; border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); z-index: 100; max-width: calc(100vw - 2rem);
}
#flash[hidden] { display: none; }
