:root {
    color-scheme: light;
    --bg: #eef3f7;
    --panel: rgba(255, 255, 255, 0.88);
    --panel-strong: #ffffff;
    --ink: #142433;
    --muted: #586a7a;
    --line: rgba(20, 36, 51, 0.08);
    --brand: #0b6e99;
    --brand-deep: #094f77;
    --accent: #f0b24a;
    --danger: #b33a3a;
    --shadow: 0 24px 60px rgba(27, 47, 68, 0.12);
    --tile-head-bg: rgba(11, 110, 153, 0.08);
    --tile-head-line: rgba(11, 110, 153, 0.16);
    --tile-foot-bg: rgba(11, 110, 153, 0.06);
    --tile-surface: rgba(255, 255, 255, 0.96);
    --tile-surface-soft: rgba(243, 248, 252, 0.98);
    --tile-border-strong: rgba(20, 36, 51, 0.08);
    --button-ghost-bg: rgba(255, 255, 255, 0.8);
    --button-ghost-border: rgba(11, 110, 153, 0.12);
}

:root[data-theme='dark'] {
    color-scheme: dark;
    --bg: #09111a;
    --panel: rgba(10, 20, 31, 0.88);
    --panel-strong: #0f1b28;
    --ink: #edf4fb;
    --muted: #8ea2b5;
    --line: rgba(173, 205, 234, 0.12);
    --brand: #69c5ee;
    --brand-deep: #c7efff;
    --accent: #f0b24a;
    --danger: #ff8d8d;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
    --tile-head-bg: rgba(105, 197, 238, 0.12);
    --tile-head-line: rgba(105, 197, 238, 0.24);
    --tile-foot-bg: rgba(105, 197, 238, 0.1);
    --tile-surface: rgba(13, 24, 36, 0.96);
    --tile-surface-soft: rgba(18, 31, 45, 0.98);
    --tile-border-strong: rgba(173, 205, 234, 0.14);
    --button-ghost-bg: rgba(18, 31, 45, 0.88);
    --button-ghost-border: rgba(105, 197, 238, 0.2);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", "Trebuchet MS", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(11, 110, 153, 0.18), transparent 28%),
        radial-gradient(circle at top right, rgba(240, 178, 74, 0.18), transparent 20%),
        linear-gradient(160deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 78%, #ffffff 22%) 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea {
    font: inherit;
}

.page-shell {
    width: min(1200px, calc(100% - 32px));
    margin: 32px auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--brand);
    font-size: 0.78rem;
    font-weight: 700;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: clamp(2rem, 4vw, 3.2rem);
    line-height: 1;
}

.subhead {
    margin: 0;
    color: var(--muted);
    max-width: 42rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 12px 18px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-button {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
    color: #fff;
    box-shadow: 0 12px 28px rgba(11, 110, 153, 0.24);
}

.ghost-button {
    background: var(--button-ghost-bg);
    border-color: var(--button-ghost-border);
    color: var(--brand-deep);
}

.danger-button {
    background: rgba(179, 58, 58, 0.1);
    color: var(--danger);
}

.theme-toggle {
    min-width: 112px;
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.tile:hover {
    transform: translateY(-1px);
}

.small-button {
    padding: 8px 12px;
    font-size: 0.9rem;
}

.flash {
    border-radius: 22px;
    padding: 14px 18px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.flash-success {
    background: rgba(26, 128, 84, 0.12);
    color: #196649;
}

.flash-error {
    background: rgba(179, 58, 58, 0.12);
    color: #7f2626;
}

.content-grid {
    display: grid;
    gap: 24px;
}

.admin-panel {
    margin-bottom: 22px;
}

.panel-card {
    background: var(--panel);
    border: 1px solid var(--tile-border-strong);
    border-radius: 28px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    padding: 24px;
}

.compact-card {
    max-width: 420px;
}

.panel-heading {
    margin-bottom: 18px;
}

.panel-heading h2 {
    margin-bottom: 8px;
}

.panel-heading p {
    margin: 0;
    color: var(--muted);
}

.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.hero-card,
.tiles-panel {
    background: var(--panel);
    border: 1px solid var(--tile-border-strong);
    border-radius: 30px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.hero-card {
    display: grid;
    grid-template-columns: 1.4fr 0.9fr;
    gap: 28px;
    padding: 30px;
    align-items: start;
}

.hero-card-admin {
    grid-template-columns: minmax(280px, 0.9fr) minmax(340px, 1.1fr);
}

.hero-card-login {
    grid-template-columns: 1.1fr 0.9fr;
}

.hero-copy {
    display: grid;
    align-content: start;
    gap: 12px;
}

.hero-copy-admin {
    padding: 10px 10px 0 0;
}

.hero-copy h2 {
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    margin-bottom: 12px;
}

.hero-copy p {
    color: var(--muted);
    max-width: 38rem;
    margin-bottom: 0;
}

.hero-badge {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(11, 110, 153, 0.1);
    color: var(--brand-deep);
    font-weight: 700;
    margin-bottom: 14px;
}

.login-card {
    background: var(--panel-strong);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 22px;
}

.stack-form {
    display: grid;
    gap: 14px;
}

.stack-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-weight: 600;
}

.stack-form input,
.stack-form textarea {
    width: 100%;
    border: 1px solid rgba(20, 36, 51, 0.12);
    border-radius: 16px;
    padding: 12px 14px;
    background: var(--panel-strong);
    color: var(--ink);
}

.stack-form textarea {
    resize: vertical;
}

.tiles-panel {
    padding: 28px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: end;
    margin-bottom: 18px;
}

.section-heading p {
    color: var(--muted);
    margin-bottom: 0;
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.tile {
    position: relative;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-radius: 24px;
    border: 1px solid var(--line);
    background:
        linear-gradient(180deg, var(--tile-surface), var(--tile-surface-soft)),
        linear-gradient(135deg, rgba(11, 110, 153, 0.08), transparent 45%),
        radial-gradient(circle at top right, rgba(240, 178, 74, 0.16), transparent 35%);
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.tile:hover {
    box-shadow: 0 16px 40px rgba(20, 36, 51, 0.14);
    border-color: rgba(11, 110, 153, 0.18);
}

.tile-link {
    padding: 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: 100%;
}

.tile-head,
.tile-body,
.tile-foot {
    padding: 18px 20px;
}

.tile-head {
    display: flex;
    align-items: center;
    min-height: 92px;
    max-height: 92px;
    background: var(--tile-head-bg);
    border-bottom: 1px solid var(--tile-head-line);
    overflow: hidden;
}

.tile-kicker {
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--brand);
    font-weight: 800;
}

.tile-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
}

.tile-title-icon {
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    border-radius: 7px;
}

.tile-head h3 {
    margin: 0;
    font-size: clamp(0.94rem, 1vw + 0.68rem, 1.2rem);
    line-height: 1.15;
    max-width: none;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    word-break: break-word;
}

.tile-body {
    display: flex;
    align-items: flex-start;
    border-bottom: 1px solid var(--line);
}

.tile-body p {
    color: var(--muted);
    line-height: 1.55;
    min-height: 72px;
    margin: 0;
}

.tile-foot {
    display: flex;
    align-items: center;
    min-height: 68px;
    max-height: 68px;
    background: var(--tile-foot-bg);
    overflow: hidden;
}

.tile-domain {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    align-items: center;
    width: 100%;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: var(--brand-deep);
    font-weight: 700;
    font-size: clamp(0.74rem, 0.7vw + 0.58rem, 0.88rem);
    line-height: 1.25;
    overflow: hidden;
    word-break: break-word;
}

.tile-tools {
    display: flex;
    gap: 10px;
    padding: 0 22px 18px;
}

.add-tile {
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 22px;
    gap: 10px;
    border-style: dashed;
}

.plus-mark {
    font-size: 3rem;
    line-height: 1;
    color: var(--brand);
}

@media (max-width: 860px) {
    .topbar,
    .section-heading,
    .hero-card {
        grid-template-columns: 1fr;
        display: grid;
    }

    .topbar-actions {
        justify-content: start;
    }
}
