:root {
    --primary: #4f46e5;
    --primary-rgb: 79, 70, 229;
    --primary-strong: #3730a3;
    --accent: #818cf8;
    --bg: #f3f5fb;
    --bg-soft: #eef1f8;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-solid: #ffffff;
    --surface-raised: #ffffff;
    --text: #172033;
    --text-soft: #65718a;
    --heading: #10182a;
    --border: #dfe4ee;
    --border-strong: #cbd3e2;
    --success: #16a34a;
    --success-rgb: 22, 163, 74;
    --danger: #dc2626;
    --shadow-sm: 0 2px 8px rgba(20, 30, 55, 0.06);
    --shadow-md: 0 14px 35px rgba(20, 30, 55, 0.10);
    --shadow-lg: 0 24px 70px rgba(20, 30, 55, 0.14);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --font-family: 'Kanit', 'Leelawadee UI', Tahoma, sans-serif;
    --header-height: 76px;
}

html[data-theme="sky"] {
    --primary: #0284c7;
    --primary-rgb: 2, 132, 199;
    --primary-strong: #075985;
    --accent: #38bdf8;
}

html[data-theme="emerald"] {
    --primary: #059669;
    --primary-rgb: 5, 150, 105;
    --primary-strong: #047857;
    --accent: #34d399;
}

html[data-theme="rose"] {
    --primary: #e11d48;
    --primary-rgb: 225, 29, 72;
    --primary-strong: #9f1239;
    --accent: #fb7185;
}

html[data-theme="amber"] {
    --primary: #d97706;
    --primary-rgb: 217, 119, 6;
    --primary-strong: #92400e;
    --accent: #fbbf24;
}

html[data-mode="dark"] {
    color-scheme: dark;
    --bg: #0c1220;
    --bg-soft: #111a2c;
    --surface: rgba(18, 27, 46, 0.9);
    --surface-solid: #121b2e;
    --surface-raised: #172238;
    --text: #e6ebf5;
    --text-soft: #9da9bf;
    --heading: #f8fafc;
    --border: #26344d;
    --border-strong: #34445f;
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.22);
    --shadow-md: 0 16px 38px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.36);
}

html[data-font="prompt"] { --font-family: 'Prompt', 'Leelawadee UI', Tahoma, sans-serif; }
html[data-font="sarabun"] { --font-family: 'Sarabun', 'Leelawadee UI', Tahoma, sans-serif; }
html[data-font="system"] { --font-family: system-ui, -apple-system, 'Segoe UI', 'Leelawadee UI', Tahoma, sans-serif; }

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at 15% 0%, rgba(var(--primary-rgb), 0.10), transparent 28rem),
        radial-gradient(circle at 92% 12%, rgba(var(--primary-rgb), 0.07), transparent 24rem),
        var(--bg);
    color: var(--text);
    font-family: var(--font-family);
    font-size: 16px;
    line-height: 1.55;
    transition: background-color .25s ease, color .25s ease;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a,
select,
input {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
}

svg {
    display: block;
    fill: currentColor;
}

.container {
    width: min(1240px, calc(100% - 36px));
    margin-inline: auto;
}

.page-shell {
    flex: 1;
    padding-top: 32px;
    padding-bottom: 120px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Header */
.main-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    min-height: var(--header-height);
    border-bottom: 1px solid rgba(var(--primary-rgb), 0.08);
    background: var(--surface-solid);
    background: color-mix(in srgb, var(--surface-solid) 84%, transparent);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .04);
}

.header-flex {
    min-height: var(--header-height);
    display: grid;
    grid-template-columns: minmax(190px, 1fr) auto minmax(190px, 1fr);
    align-items: center;
    gap: 20px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    width: max-content;
    text-decoration: none;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    color: white;
    border-radius: 14px;
    background: linear-gradient(145deg, var(--accent), var(--primary-strong));
    box-shadow: 0 10px 24px rgba(var(--primary-rgb), .28), inset 0 1px 0 rgba(255,255,255,.28);
}

.brand-mark svg {
    width: 23px;
    height: 23px;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
}

.brand-copy strong {
    color: var(--heading);
    font-size: 1.18rem;
    letter-spacing: .01em;
}

.brand-copy small {
    margin-top: 5px;
    color: var(--text-soft);
    font-size: .72rem;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-soft);
}

.nav-link {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 10px;
    color: var(--text-soft);
    text-decoration: none;
    font-weight: 500;
    transition: color .2s ease, background .2s ease, box-shadow .2s ease;
}

.nav-link svg {
    width: 19px;
    height: 19px;
}

.nav-link:hover {
    color: var(--heading);
}

.nav-link.active {
    color: var(--primary);
    background: var(--surface-solid);
    box-shadow: var(--shadow-sm);
}

.header-actions {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-button {
    width: 43px;
    height: 43px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-solid);
    color: var(--text);
    cursor: pointer;
    list-style: none;
    transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.icon-button:hover {
    transform: translateY(-1px);
    border-color: rgba(var(--primary-rgb), .5);
    background: rgba(var(--primary-rgb), .08);
    color: var(--primary);
}

.icon-button svg {
    width: 20px;
    height: 20px;
}

.moon-icon { display: none; }
html[data-mode="dark"] .sun-icon { display: none; }
html[data-mode="dark"] .moon-icon { display: block; }

.appearance-menu {
    position: relative;
}

.appearance-menu > summary::-webkit-details-marker {
    display: none;
}

.appearance-menu[open] > summary {
    color: var(--primary);
    border-color: rgba(var(--primary-rgb), .5);
    background: rgba(var(--primary-rgb), .08);
}

.appearance-panel {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 290px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-solid);
    box-shadow: var(--shadow-lg);
    animation: pop-in .16s ease-out;
}

@keyframes pop-in {
    from { opacity: 0; transform: translateY(-6px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.panel-heading {
    display: flex;
    flex-direction: column;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.panel-heading strong { color: var(--heading); }
.panel-heading small { color: var(--text-soft); font-size: .78rem; }

.setting-field {
    display: grid;
    gap: 6px;
    margin-top: 12px;
    color: var(--text-soft);
    font-size: .84rem;
}

.setting-field select,
.compact-select select,
.input-select,
.icon-select {
    width: 100%;
    min-height: 42px;
    padding: 8px 36px 8px 11px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-raised);
    color: var(--text);
    outline: none;
    cursor: pointer;
}

.setting-field select:focus,
.compact-select select:focus,
.input-select:focus,
.icon-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .12);
}

/* Shared controls */
.btn {
    min-height: 43px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 17px;
    border: 1px solid transparent;
    border-radius: 11px;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}

.btn svg {
    width: 19px;
    height: 19px;
}

.btn:hover { transform: translateY(-1px); }

.btn-primary {
    color: white;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    box-shadow: 0 10px 24px rgba(var(--primary-rgb), .24);
}

.btn-primary:hover {
    box-shadow: 0 14px 30px rgba(var(--primary-rgb), .32);
}

.btn-secondary {
    color: var(--text);
    background: var(--surface-solid);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover { border-color: rgba(var(--primary-rgb), .4); }

.btn-ghost {
    color: var(--text-soft);
    background: transparent;
    border-color: transparent;
}

.btn-ghost:hover {
    color: var(--heading);
    background: var(--bg-soft);
}

.btn-small {
    min-height: 38px;
    padding: 7px 12px;
    font-size: .88rem;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 10px;
    color: var(--primary);
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .14em;
}

/* Home */
.hero-panel {
    position: relative;
    overflow: hidden;
    min-height: 270px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
    padding: clamp(28px, 5vw, 58px);
    border: 1px solid rgba(var(--primary-rgb), .18);
    border-radius: 30px;
    background:
        linear-gradient(120deg, rgba(var(--primary-rgb), .16), rgba(var(--primary-rgb), .04)),
        var(--surface-solid);
    box-shadow: var(--shadow-md);
}

.hero-panel::before,
.hero-panel::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.hero-panel::before {
    width: 360px;
    height: 360px;
    right: -110px;
    top: -180px;
    background: radial-gradient(circle, rgba(var(--primary-rgb), .20), transparent 68%);
}

.hero-panel::after {
    width: 180px;
    height: 180px;
    right: 22%;
    bottom: -130px;
    border: 38px solid rgba(var(--primary-rgb), .07);
}

.hero-copy,
.hero-stat {
    position: relative;
    z-index: 1;
}

.hero-copy h1 {
    margin: 0;
    color: var(--heading);
    font-size: clamp(2rem, 4.2vw, 3.7rem);
    line-height: 1.13;
    letter-spacing: -.035em;
}

.hero-copy h1 span { color: var(--primary); }

.hero-copy p {
    max-width: 660px;
    margin: 18px 0 0;
    color: var(--text-soft);
    font-size: clamp(1rem, 1.4vw, 1.12rem);
}

.hero-stat {
    min-width: 190px;
    min-height: 170px;
    display: grid;
    align-content: center;
    justify-items: center;
    padding: 24px;
    border: 1px solid rgba(var(--primary-rgb), .22);
    border-radius: 24px;
    background: var(--surface-solid);
    background: color-mix(in srgb, var(--surface-solid) 72%, transparent);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.15), var(--shadow-sm);
    text-align: center;
}

.hero-stat strong {
    color: var(--primary);
    font-size: 3.5rem;
    line-height: 1;
}

.hero-stat span {
    margin-top: 10px;
    color: var(--text-soft);
    font-size: .9rem;
}

.content-section { margin-top: 44px; }

.section-header,
.admin-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

.section-header h2,
.admin-heading h1 {
    margin: 0;
    color: var(--heading);
    line-height: 1.25;
}

.section-header h2 { font-size: 1.65rem; }
.admin-heading h1 { font-size: clamp(1.75rem, 3vw, 2.35rem); }

.section-header p,
.admin-heading p {
    margin: 5px 0 0;
    color: var(--text-soft);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.search-box {
    flex: 1;
    min-width: 0;
    min-height: 50px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-solid);
    box-shadow: var(--shadow-sm);
    transition: border-color .18s ease, box-shadow .18s ease;
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), .11), var(--shadow-sm);
}

.search-box svg {
    width: 21px;
    height: 21px;
    flex: 0 0 auto;
    color: var(--text-soft);
}

.search-box input {
    min-width: 0;
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
}

.search-box input::placeholder { color: color-mix(in srgb, var(--text-soft) 75%, transparent); }

.search-box kbd {
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 6px;
    background: var(--bg-soft);
    color: var(--text-soft);
    font-family: inherit;
    font-size: .72rem;
}

.compact-select { width: 180px; }
.compact-select select { min-height: 50px; border-radius: 14px; box-shadow: var(--shadow-sm); }

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 18px;
}

.project-card {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface-solid);
    box-shadow: var(--shadow-sm);
    transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.project-card:hover {
    transform: translateY(-5px);
    border-color: rgba(var(--primary-rgb), .5);
    box-shadow: var(--shadow-md);
}

.project-main-link {
    position: relative;
    min-height: 190px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 24px;
    text-decoration: none;
}

.project-icon {
    width: 62px;
    height: 62px;
    display: grid;
    place-items: center;
    margin-bottom: 21px;
    border: 1px solid rgba(var(--primary-rgb), .16);
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(var(--primary-rgb), .16), rgba(var(--primary-rgb), .05));
    font-size: 2rem;
    filter: drop-shadow(0 8px 12px rgba(var(--primary-rgb), .12));
}

.project-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.project-info strong {
    overflow: hidden;
    color: var(--heading);
    font-size: 1.18rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-info small {
    overflow: hidden;
    margin-top: 5px;
    color: var(--text-soft);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.open-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: var(--text-soft);
    background: var(--bg-soft);
    transition: color .18s ease, transform .18s ease, background .18s ease;
}

.open-indicator svg { width: 17px; height: 17px; }
.project-card:hover .open-indicator { color: white; background: var(--primary); transform: translate(2px, -2px); }

.project-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 48px;
    padding: 10px 18px;
    border-top: 1px solid var(--border);
    background: var(--bg-soft);
}

.online-label,
.footer-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-soft);
    font-size: .78rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(var(--success-rgb), .12);
}

.text-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 7px;
    border: 0;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
    font-size: .78rem;
}

.text-button:hover { color: var(--primary); }
.text-button svg { width: 15px; height: 15px; }

/* Alerts and empty states */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    margin-bottom: 22px;
    border: 1px solid;
    border-radius: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.alert svg { width: 22px; height: 22px; flex: 0 0 auto; }
.alert.success { color: #166534; border-color: #bbf7d0; background: #dcfce7; }
.alert.danger { color: #991b1b; border-color: #fecaca; background: #fee2e2; }
html[data-mode="dark"] .alert.success { color: #bbf7d0; border-color: #166534; background: rgba(22, 101, 52, .35); }
html[data-mode="dark"] .alert.danger { color: #fecaca; border-color: #991b1b; background: rgba(127, 29, 29, .35); }

.empty-state {
    display: grid;
    justify-items: center;
    padding: 60px 24px;
    border: 1px dashed var(--border-strong);
    border-radius: 22px;
    background: var(--surface-solid);
    text-align: center;
}

.empty-state.compact { padding: 38px 22px; }
.empty-state h3 { margin: 8px 0 0; color: var(--heading); }
.empty-state p { margin: 6px 0 22px; color: var(--text-soft); }
.empty-icon { font-size: 2.5rem; }

/* Admin */
.admin-heading { align-items: center; }
.admin-heading .eyebrow { margin-bottom: 5px; }

.admin-toolbar {
    position: sticky;
    top: calc(var(--header-height) + 12px);
    z-index: 40;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 17px;
    background: var(--surface-solid);
    background: color-mix(in srgb, var(--surface-solid) 88%, transparent);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-md);
}

.toolbar-actions {
    display: flex;
    gap: 7px;
    white-space: nowrap;
}

.selection-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 14px 4px;
    color: var(--text-soft);
    font-size: .9rem;
}

.selection-summary > div {
    display: flex;
    align-items: baseline;
    gap: 7px;
}

.selection-summary strong { color: var(--heading); }

.unsaved-badge {
    padding: 4px 10px;
    border: 1px solid rgba(var(--primary-rgb), .25);
    border-radius: 999px;
    color: var(--primary);
    background: rgba(var(--primary-rgb), .09);
    font-size: .78rem;
}

.admin-list {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-solid);
    box-shadow: var(--shadow-sm);
}

.admin-list-head,
.admin-row {
    display: grid;
    grid-template-columns: 72px 150px minmax(300px, 1fr) 165px 70px;
    align-items: center;
    gap: 12px;
}

.admin-list-head {
    min-height: 48px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text-soft);
    font-size: .76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.admin-list-head span:first-child,
.admin-list-head span:nth-child(2),
.admin-list-head span:last-child { text-align: center; }

.admin-row {
    min-height: 94px;
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    transition: background .18s ease, opacity .18s ease;
}

.admin-row:last-child { border-bottom: 0; }
.admin-row:hover { background: rgba(var(--primary-rgb), .035); }
.admin-row.is-selected { background: rgba(var(--primary-rgb), .055); }
.admin-row.dragging { opacity: .45; }
.admin-row.drag-over { box-shadow: inset 0 3px 0 var(--primary); }

.select-cell,
.icon-cell,
.drag-cell { display: flex; justify-content: center; }

.switch-check {
    position: relative;
    display: inline-flex;
    cursor: pointer;
}

.switch-check input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch-check span {
    position: relative;
    width: 46px;
    height: 26px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--bg-soft);
    transition: .2s ease;
}

.switch-check span::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--surface-solid);
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
    transition: transform .2s ease;
}

.switch-check input:checked + span {
    border-color: var(--primary);
    background: var(--primary);
}

.switch-check input:checked + span::after { transform: translateX(20px); }
.switch-check input:focus-visible + span { box-shadow: 0 0 0 4px rgba(var(--primary-rgb), .15); }

.icon-select { min-width: 120px; }

.project-fields {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(130px, .7fr) minmax(180px, 1.3fr);
    align-items: center;
    gap: 12px;
}

.project-fields code {
    overflow: hidden;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-soft);
    color: var(--text-soft);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .8rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.input-custom-name {
    width: 100%;
    min-height: 43px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    background: var(--surface-raised);
    color: var(--text);
    transition: border-color .18s ease, box-shadow .18s ease;
}

.input-custom-name:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .12);
}

.drag-handle {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-soft);
    cursor: grab;
}

.drag-handle:hover { border-color: var(--border); background: var(--bg-soft); color: var(--primary); }
.drag-handle:active { cursor: grabbing; }
.drag-handle svg { width: 22px; height: 22px; }

.sticky-save-bar {
    position: fixed;
    z-index: 900;
    left: 50%;
    bottom: 18px;
    width: min(1180px, calc(100% - 36px));
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 14px 12px 20px;
    border: 1px solid rgba(var(--primary-rgb), .22);
    border-radius: 20px;
    background: var(--surface-solid);
    background: color-mix(in srgb, var(--surface-solid) 91%, transparent);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    transform: translateX(-50%);
}

.save-summary {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.save-icon {
    width: 43px;
    height: 43px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 12px;
    background: rgba(var(--primary-rgb), .10);
}

.save-summary div {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.save-summary strong { color: var(--heading); }
.save-summary small { overflow: hidden; color: var(--text-soft); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.save-actions { display: flex; align-items: center; gap: 8px; }
.btn-save { min-width: 235px; }

/* Footer */
.main-footer {
    border-top: 1px solid var(--border);
    background: var(--surface-solid);
}

.footer-flex {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    color: var(--text-soft);
    font-size: .82rem;
}

.footer-flex p { margin: 0; }

/* Toast */
.toast-region {
    position: fixed;
    z-index: 2000;
    right: 20px;
    bottom: 20px;
    display: grid;
    gap: 10px;
    pointer-events: none;
}

.toast {
    min-width: 230px;
    max-width: 360px;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-solid);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    animation: toast-in .2s ease-out;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

[hidden] { display: none !important; }

@media (max-width: 1000px) {
    .header-flex { grid-template-columns: 1fr auto; }
    .main-nav { order: 3; grid-column: 1 / -1; width: 100%; justify-content: center; margin-bottom: 10px; }
    .main-header { position: relative; }
    .admin-toolbar { top: 12px; }
    .admin-list-head { display: none; }
    .admin-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; border: 0; background: transparent; box-shadow: none; overflow: visible; }
    .admin-row {
        min-width: 0;
        display: grid;
        grid-template-columns: 70px 1fr 42px;
        align-items: start;
        gap: 13px;
        padding: 16px;
        border: 1px solid var(--border) !important;
        border-radius: 16px;
        background: var(--surface-solid);
        box-shadow: var(--shadow-sm);
    }
    .select-cell { grid-column: 1; grid-row: 1; justify-content: flex-start; }
    .icon-cell { grid-column: 2; grid-row: 1; justify-content: stretch; }
    .drag-cell { grid-column: 3; grid-row: 1; }
    .project-fields { grid-column: 1 / -1; grid-row: 2; grid-template-columns: 1fr; }
    .target-cell { grid-column: 1 / -1; grid-row: 3; }
    .icon-select { width: 100%; }
}

@media (max-width: 760px) {
    :root { --header-height: 66px; }
    .container { width: min(100% - 24px, 1240px); }
    .page-shell { padding-top: 20px; padding-bottom: 165px; }
    .header-flex { gap: 10px; }
    .brand-copy small { display: none; }
    .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
    .main-nav { overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
    .main-nav::-webkit-scrollbar { display: none; }
    .nav-link { flex: 1 0 auto; justify-content: center; padding-inline: 13px; }
    .appearance-panel { position: fixed; top: 74px; right: 12px; left: 12px; width: auto; }
    .hero-panel { min-height: auto; flex-direction: column; align-items: stretch; gap: 26px; padding: 28px 22px; border-radius: 22px; }
    .hero-stat { min-height: 110px; grid-template-columns: auto auto; justify-content: center; align-items: center; gap: 14px; }
    .hero-stat strong { font-size: 2.8rem; }
    .hero-stat span { margin: 0; text-align: left; }
    .section-header,
    .admin-heading { align-items: stretch; flex-direction: column; }
    .section-header .btn,
    .admin-heading .btn { width: 100%; }
    .home-toolbar,
    .admin-toolbar { align-items: stretch; flex-direction: column; }
    .compact-select { width: 100%; }
    .toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .admin-list { grid-template-columns: 1fr; }
    .selection-summary { align-items: flex-start; flex-direction: column; }
    .sticky-save-bar {
        bottom: 10px;
        width: calc(100% - 20px);
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
        border-radius: 17px;
    }
    .save-summary { display: none; }
    .save-actions { display: grid; grid-template-columns: .7fr 1.3fr; }
    .btn-save { min-width: 0; }
    .footer-flex { min-height: 86px; align-items: flex-start; justify-content: center; flex-direction: column; gap: 4px; padding-block: 18px; }
    .toast-region { right: 12px; bottom: 100px; left: 12px; }
    .toast { min-width: 0; max-width: none; }
}

@media (max-width: 460px) {
    .brand-copy strong { font-size: 1rem; }
    .header-actions { gap: 5px; }
    .icon-button { width: 39px; height: 39px; }
    .nav-link span { font-size: .84rem; }
    .hero-copy h1 { font-size: 1.9rem; }
    .project-grid { grid-template-columns: 1fr; }
    .project-card-footer { padding-inline: 14px; }
    .search-box kbd { display: none; }
    .admin-row { grid-template-columns: 60px 1fr 40px; }
    .save-actions { grid-template-columns: 1fr; }
    .save-actions .btn-ghost { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
