/* Light is the default theme; `data-theme="dark"` on <html> switches to dark. */
:root {
    color-scheme: light;

    --bg: #f6f7fb;
    --panel: #ffffff;
    --panel-2: #f1f5f9;
    --line: #e4e7ee;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #4f46e5;
    --accent-strong: #4338ca;
    --accent-2: #0e7490;
    --box-shadow: 0 10px 25px rgba(79, 70, 229, .30);
    --header-gradient: linear-gradient(180deg, rgba(99, 102, 241, .10), transparent);
    --notice-border: #d97706;
    --notice-bg: #fef3c7;
    --notice-text: #92400e;
    --radius: 14px;
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0f172a;
    --panel: #111c34;
    --panel-2: #16233f;
    --line: #24324f;
    --text: #e2e8f0;
    --muted: #93a1bd;
    --accent: #6366f1;
    --accent-strong: #4f46e5;
    --accent-2: #22d3ee;
    --box-shadow: 0 10px 25px rgba(79, 70, 229, .45);
    --header-gradient: linear-gradient(180deg, rgba(99, 102, 241, .16), transparent);
    --notice-border: #b45309;
    --notice-bg: rgba(180, 83, 9, .15);
    --notice-text: #fcd34d;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    transition: background-color .2s ease, color .2s ease;
}

a { color: var(--accent-2); }

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--line);
    background: var(--header-gradient);
}

.app-titles h1 {
    margin: 0;
    font-size: 1.4rem;
    letter-spacing: -.01em;
}

.app-titles p {
    margin: .15rem 0 0;
    color: var(--muted);
    font-size: .9rem;
}

.app-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.app-source {
    font-size: .9rem;
    text-decoration: none;
    border: 1px solid var(--line);
    padding: .4rem .8rem;
    border-radius: 999px;
    color: var(--text);
}

.app-source:hover { border-color: var(--accent); }

.theme-toggle {
    border-radius: 999px;
    padding: .4rem .8rem;
}

.page {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem;
    display: grid;
    gap: 1.25rem;
}

.notice:empty { display: none; }

.notice {
    margin: 0;
    padding: .6rem .9rem;
    border: 1px solid var(--notice-border);
    background: var(--notice-bg);
    border-radius: 10px;
    color: var(--notice-text);
    font-size: .9rem;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.card-header h2 {
    margin: 0 0 .25rem;
    font-size: 1.1rem;
}

.card-header p {
    margin: 0;
    color: var(--muted);
    font-size: .88rem;
}

code {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: .05rem .3rem;
    font-size: .85em;
}

.stage {
    display: flex;
    align-items: center;
    min-height: 120px;
    margin: 1rem 0;
    padding: 1rem;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}

.box {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: #4f46e5;
    box-shadow: var(--box-shadow);
}

.box2 { background: #0ea5e9; border-radius: 50%; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.spacer { flex: 1 1 auto; }

.btn {
    appearance: none;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    border-radius: 9px;
    padding: .45rem .8rem;
    font-size: .85rem;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.btn:hover { border-color: var(--accent); }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.btn-primary:hover { background: var(--accent-strong); }

.dots {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: .6rem;
    margin: 1rem 0;
    max-width: 320px;
}

.dot {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--accent-2);
    opacity: .25;
    transform: scale(.55);
}

.morph {
    width: 220px;
    height: 132px;
}

.morph path {
    fill: none;
    stroke: var(--accent-2);
    stroke-width: 6;
    stroke-linejoin: round;
}

.morph-target {
    visibility: hidden;
}

.drag-stage {
    position: relative;
    min-height: 180px;
    touch-action: none;
}

.drag-box {
    cursor: grab;
    background: #0ea5e9;
    box-shadow: 0 10px 25px rgba(14, 165, 233, .35);
}

.drag-box:active { cursor: grabbing; }

.readout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: .5rem 1.25rem;
    margin: 1rem 0;
}

.readout > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px dashed var(--line);
    padding-bottom: .35rem;
}

.readout dt { color: var(--muted); font-size: .85rem; }
.readout dd { margin: 0; font-variant-numeric: tabular-nums; }

.status {
    margin: 1rem 0 0;
    color: var(--muted);
    font-size: .85rem;
    min-height: 1.2em;
}
