/* kabin – Oberfläche. Warme, ruhige Identität: Papier-Canvas, Tannengrün-
   Akzent, Serif-Wortmarke, farbige Boards als "Räume". Ohne Framework. */

:root {
    --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --bg: #f2ede3;
    --surface: #fffdf9;
    --lane-bg: #e8e0d1;
    --lane-on-color: rgba(255, 253, 249, 0.85);
    --ink: #2c2823;
    --muted: #857b6d;
    --border: #e2dacb;
    --accent: #2f6f5c;
    --accent-hover: #245b4b;
    --danger: #b0432e;
    --danger-hover: #8f3524;
    --shadow-sm: 0 1px 2px rgba(60, 46, 25, 0.12);
    --shadow-md: 0 4px 14px rgba(60, 46, 25, 0.16);
    --shadow-lg: 0 12px 32px rgba(40, 30, 15, 0.28);
    --radius: 8px;
    --header-h: 56px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    font-family: var(--font-sans);
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

#app { display: flex; flex-direction: column; height: 100vh; }
.loading { padding: 2rem; color: var(--muted); }

/* -------------------------------------------------------- Buttons */

.btn {
    font: inherit;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    line-height: 1.2;
    transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn:hover { background: #f6f1e8; border-color: #d4cab8; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-small { padding: 0.3rem 0.65rem; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--surface); border-color: #e3c3ba; color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.icon-btn {
    border: none; background: transparent; cursor: pointer;
    padding: 0.15rem 0.35rem; border-radius: 5px; font-size: 0.9rem; color: var(--muted);
}
.icon-btn:hover { background: rgba(44, 40, 35, 0.08); color: var(--ink); }

/* -------------------------------------------------------- Header */

.app-header {
    display: flex; align-items: center; gap: 1rem;
    height: var(--header-h); padding: 0 1.1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0; z-index: 2;
}
.brand {
    display: inline-flex; align-items: baseline; gap: 0.35rem;
    font-family: var(--font-serif);
    font-weight: 600; font-size: 1.4rem; letter-spacing: -0.01em;
    color: var(--accent);
}
.brand-version {
    font-family: var(--font-sans); font-size: 0.68rem; font-weight: 500;
    letter-spacing: 0; color: var(--muted);
}

.board-tabs { display: flex; gap: 0.2rem; overflow-x: auto; flex: 1; }
.board-tab {
    font: inherit; white-space: nowrap;
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.35rem 0.75rem; border: 1px solid transparent;
    border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.board-tab:hover { background: var(--lane-bg); color: var(--ink); }
.board-tab.active { background: var(--lane-bg); color: var(--ink); font-weight: 600; }
.tab-dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15); flex-shrink: 0; }

.header-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

/* -------------------------------------------------------- Board */

.board-main { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.board-toolbar { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 1.1rem; }
.board-name {
    font-family: var(--font-serif); font-weight: 600; font-size: 1.3rem;
    letter-spacing: -0.01em; margin: 0; margin-right: 0.3rem;
}

.board-scroll {
    display: flex; align-items: flex-start; gap: 0.8rem;
    padding: 0.9rem 1.1rem 1.1rem; margin: 0 0.6rem 0.6rem;
    border-radius: 12px;
    overflow-x: auto; flex: 1; min-height: 0;
    background: transparent;
    transition: background 0.2s;
}
.board-scroll.has-color { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06); }

.lanes { display: flex; align-items: flex-start; gap: 0.8rem; }

.lane {
    display: flex; flex-direction: column; width: 286px; max-height: 100%;
    background: var(--lane-bg); border-radius: 10px; flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}
.has-color .lane { background: var(--lane-on-color); backdrop-filter: blur(2px); }

.lane-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.55rem 0.65rem; cursor: grab;
}
.lane-header:active { cursor: grabbing; }
.lane-title { font-weight: 600; font-size: 0.95rem; }
.lane-menu { display: flex; gap: 0.1rem; }

.lane-cards {
    display: flex; flex-direction: column; gap: 0.5rem;
    padding: 0.25rem 0.55rem; overflow-y: auto; min-height: 2.5rem;
}

.add-card, .add-lane {
    font: inherit; border: none; background: transparent; color: var(--muted);
    text-align: left; cursor: pointer; padding: 0.5rem 0.65rem; border-radius: 7px;
    transition: background 0.12s, color 0.12s;
}
.add-card { margin: 0.35rem 0.55rem 0.55rem; }
.add-card:hover { background: rgba(44, 40, 35, 0.08); color: var(--ink); }

.add-lane { width: 286px; flex-shrink: 0; background: rgba(44, 40, 35, 0.05); color: var(--muted); }
.add-lane:hover { background: rgba(44, 40, 35, 0.1); color: var(--ink); }
.has-color .add-lane { background: rgba(255, 255, 255, 0.35); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.25); }
.has-color .add-lane:hover { background: rgba(255, 255, 255, 0.5); }

/* -------------------------------------------------------- Karten */

.card {
    background: var(--surface); border-radius: 7px; box-shadow: var(--shadow-sm);
    padding: 0.55rem 0.7rem; cursor: pointer; font-size: 0.9rem;
    border: 1px solid rgba(44, 40, 35, 0.04);
    transition: box-shadow 0.12s, transform 0.06s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card:active { transform: scale(0.998); }
.card-headline { font-weight: 600; }
.card-headline p { margin: 0; }
.card-body {
    margin-top: 0.35rem; color: var(--muted); font-size: 0.85rem;
    overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
}
.card-body p { margin: 0 0 0.35rem; }
.card-body :last-child { margin-bottom: 0; }
/* Listen kompakt halten – Standard-Einrückung verschwendet Kartenplatz. */
.card-headline ul, .card-headline ol,
.card-body ul, .card-body ol { margin: 0.25rem 0; padding-left: 1.15rem; }
.card-headline li, .card-body li { margin: 0.1rem 0; }
.card-headline pre, .card-body pre {
    background: #efe9dd; padding: 0.4rem; border-radius: 5px; overflow-x: auto; font-size: 0.8rem;
}
.card-headline code, .card-body code {
    background: #efe9dd; padding: 0.05rem 0.28rem; border-radius: 3px; font-family: var(--font-mono); font-size: 0.85em;
}

.sortable-ghost { opacity: 0.35; }
.sortable-chosen { box-shadow: var(--shadow-lg); }

/* -------------------------------------------------------- Login */

.login { display: flex; align-items: center; justify-content: center; flex: 1; }
.login-form {
    display: flex; flex-direction: column; gap: 0.5rem;
    width: min(90vw, 340px); padding: 2.25rem;
    background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}
.login-title {
    font-family: var(--font-serif); font-weight: 600; font-size: 2rem;
    margin: 0 0 0.75rem; text-align: center; letter-spacing: -0.02em; color: var(--accent);
}

/* -------------------------------------------------------- Leerzustand */

.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 1rem; flex: 1; color: var(--muted);
}

/* -------------------------------------------------------- Archiv */

.archive { padding: 1.25rem; overflow-y: auto; flex: 1; }
.archive-board-name { font-family: var(--font-serif); margin: 1rem 0 0.5rem; }
.archive-lane { margin: 0 0 1rem 0.5rem; }
.archive-lane-title { margin: 0.5rem 0; color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.archive-card { cursor: default; max-width: 480px; margin-bottom: 0.5rem; }
.archive-card .btn { margin-top: 0.5rem; }

/* -------------------------------------------------------- Dialoge */

.dialog {
    border: none; border-radius: 12px; padding: 0;
    box-shadow: var(--shadow-lg); width: min(92vw, 520px);
    background: var(--surface); color: var(--ink);
}
.dialog::backdrop { background: rgba(40, 30, 15, 0.4); backdrop-filter: blur(1px); }
.dialog-form { display: flex; flex-direction: column; gap: 0.5rem; padding: 1.4rem; }
.dialog-title { font-family: var(--font-serif); margin: 0 0 0.5rem; font-size: 1.25rem; }
.dialog-label { font-size: 0.78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.dialog-message { margin: 0; color: var(--muted); }
.dialog-input {
    font: inherit; width: 100%; padding: 0.55rem; border: 1px solid var(--border);
    border-radius: var(--radius); resize: vertical; background: #fffefb; color: var(--ink);
}
.dialog-input:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.dialog-headline { font-weight: 600; }
.dialog-body { min-height: 9rem; font-family: var(--font-mono); font-size: 0.85rem; border-top-left-radius: 0; border-top-right-radius: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.85rem; flex-wrap: wrap; }

/* Markdown-Toolbar */
.md-toolbar {
    display: flex; gap: 0.15rem; flex-wrap: wrap;
    padding: 0.3rem; border: 1px solid var(--border); border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0; background: #f3eee4;
}
.md-btn {
    font: inherit; font-size: 0.85rem; min-width: 1.9rem;
    padding: 0.2rem 0.45rem; border: 1px solid transparent; border-radius: 5px;
    background: transparent; color: var(--ink); cursor: pointer; line-height: 1.4;
}
.md-btn:hover { background: var(--surface); border-color: var(--border); }

/* Farb-Swatches */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 0.6rem; margin: 0.4rem 0; }
.swatch {
    height: 52px; border-radius: 9px; border: 2px solid transparent; cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); position: relative;
}
.swatch:hover { transform: scale(1.05); }
.swatch.selected { border-color: var(--ink); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08), 0 0 0 2px var(--surface); }
.swatch-default {
    background: repeating-linear-gradient(45deg, #efe9dd, #efe9dd 6px, #e2dacb 6px, #e2dacb 12px);
    font-size: 0.72rem; color: var(--muted); font-weight: 600;
}
.swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* -------------------------------------------------------- Fehlerbanner */

.toast-banner {
    position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 2rem);
    color: #fff; padding: 0.65rem 1.1rem; border-radius: var(--radius);
    box-shadow: var(--shadow-md); opacity: 0; pointer-events: none;
    transition: opacity 0.2s, transform 0.2s; max-width: 90vw; z-index: 1000;
}
.toast-banner.error { background: var(--danger); }
.toast-banner.info { background: var(--accent); }
.toast-banner.visible { opacity: 1; transform: translate(-50%, 0); }

/* -------------------------------------------------------- Bewegung / Mobil */

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
    .swatch:hover { transform: none; }
}

@media (max-width: 640px) {
    .app-header { flex-wrap: wrap; height: auto; padding: 0.5rem; gap: 0.5rem; }
    .board-tabs { order: 3; width: 100%; }
    .lane, .add-lane { width: 84vw; }
    .board-scroll { margin: 0 0.4rem 0.4rem; }
}
