:root {
    --bg: #f7f8fb;
    --bg-warm: #fff6ec;
    --panel: #ffffff;
    --panel-soft: #fbfcff;
    --text: #18232b;
    --muted: #64727f;
    --line: #dfe6ee;
    --accent: #237c77;
    --accent-dark: #185b57;
    --accent-blue: #356db6;
    --accent-coral: #d7654f;
    --accent-gold: #c58a20;
    --success-bg: #e8f6ef;
    --danger: #9f2d2d;
    --warning: #8b5e13;
    --radius: 8px;
    --shadow: 0 16px 38px rgba(28, 47, 69, 0.10);
    --shadow-soft: 0 8px 22px rgba(28, 47, 69, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 8% 0%, rgba(255, 198, 122, 0.22), transparent 31rem),
        radial-gradient(circle at 92% 8%, rgba(92, 168, 196, 0.20), transparent 30rem),
        linear-gradient(180deg, var(--bg-warm) 0%, var(--bg) 32%, #eef5f3 100%);
    background-attachment: fixed;
    font-family: "Segoe UI Variable", "Segoe UI", "Trebuchet MS", Arial, sans-serif;
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.page {
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 48px;
    animation: pageIn 360ms ease-out both;
}

body.auth-page {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 18px;
}

body.auth-page .page {
    width: min(520px, 100%);
    margin: 0;
    padding: 0;
    animation: none;
}

body.auth-page > .flash {
    width: 100%;
}

body.auth-page .panel {
    width: 100%;
    padding: 34px;
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 252, 255, 0.98)),
        linear-gradient(135deg, rgba(35, 124, 119, 0.06), rgba(215, 101, 79, 0.05));
    border-color: rgba(223, 230, 238, 0.92);
}

body.auth-page .panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 6px;
    background: linear-gradient(90deg, var(--accent), var(--accent-blue), var(--accent-coral));
}

body.admin-auth-page {
    background:
        radial-gradient(circle at 10% 0%, rgba(255, 196, 72, 0.30), transparent 26rem),
        radial-gradient(circle at 90% 10%, rgba(186, 33, 55, 0.24), transparent 24rem),
        linear-gradient(180deg, #fff0d6 0%, #f7d7d1 34%, #eef3fb 100%);
}

body.admin-auth-page .panel {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 248, 238, 0.98)),
        linear-gradient(135deg, rgba(186, 33, 55, 0.12), rgba(196, 138, 32, 0.12));
    border: 2px solid rgba(186, 33, 55, 0.20);
    box-shadow: 0 20px 48px rgba(120, 18, 33, 0.16);
}

body.admin-auth-page .panel::before {
    height: 8px;
    background: linear-gradient(90deg, #b71f3a, #d9651f, #c58a20);
}

body.admin-auth-page .admin-badge {
    color: #b71f3a;
}

body.admin-auth-page h1 {
    color: #7e1026;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

body.admin-auth-page label {
    color: #6c2232;
}

body.admin-auth-page input:focus,
body.admin-auth-page textarea:focus,
body.admin-auth-page select:focus {
    border-color: #b71f3a;
    box-shadow: 0 0 0 4px rgba(183, 31, 58, 0.16);
}

body.admin-auth-page button {
    background: linear-gradient(135deg, #b71f3a, #d9651f);
    box-shadow: 0 10px 18px rgba(183, 31, 58, 0.22);
}

body.admin-auth-page button:hover {
    background: linear-gradient(135deg, #8f0f2a, #c84e0f);
    box-shadow: 0 14px 24px rgba(183, 31, 58, 0.28);
}

body.auth-page h1 {
    text-align: center;
    margin-bottom: 10px;
}

body.auth-page .muted {
    text-align: center;
}

body.auth-page form {
    margin-top: 20px;
}

body.auth-page label {
    text-align: left;
}

body.auth-page .panel form {
    width: 100%;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
}

body.auth-page button {
    width: 100%;
}

body.auth-page .panel > p:last-child {
    margin-top: 16px;
    margin-bottom: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.76);
    border-bottom: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
}

.brand {
    color: var(--accent-dark);
    font-weight: 700;
}

.topbar nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    color: var(--muted);
}

.topbar nav a {
    border-radius: 999px;
    padding: 6px 10px;
    transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.topbar nav a:hover {
    color: var(--accent-dark);
    background: #e9f4f2;
    text-decoration: none;
    transform: translateY(-1px);
}

.panel,
.thought,
.comment,
.table-wrap {
    background: var(--panel);
    border: 1px solid rgba(223, 230, 238, 0.92);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}

.panel,
.thought {
    padding: 24px;
    animation: cardIn 320ms ease-out both;
}

.panel:hover,
.thought:hover,
.table-wrap:hover {
    box-shadow: var(--shadow);
}

.grid {
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    gap: 20px;
}

.stack {
    display: grid;
    gap: 16px;
}

h1,
h2,
h3 {
    margin: 0 0 12px;
    line-height: 1.2;
    letter-spacing: 0;
    font-family: "Segoe UI Semibold", "Segoe UI", "Trebuchet MS", Arial, sans-serif;
}

p {
    margin: 0 0 12px;
}

.muted {
    color: var(--muted);
}

.date-line {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--muted);
    margin-bottom: 16px;
}

.date-line span {
    border-radius: 999px;
    padding: 6px 10px;
    background: #eef7f5;
}

.thought-text {
    font-size: 2rem;
    line-height: 1.28;
    margin: 0 0 16px;
    color: #17333d;
}

.thought-label {
    margin-bottom: 10px;
}

.thought .muted {
    font-size: 0.95rem;
}

.thought {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(242, 250, 248, 0.96)),
        linear-gradient(90deg, rgba(35, 124, 119, 0.12), rgba(215, 101, 79, 0.10));
}

.thought::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    background: linear-gradient(90deg, var(--accent), var(--accent-blue), var(--accent-coral), var(--accent-gold));
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent-blue);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.76rem;
    font-weight: 700;
}

form {
    display: grid;
    gap: 12px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 11px 12px;
    color: var(--text);
    background: #fff;
    font: inherit;
    transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: 0;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(35, 124, 119, 0.14);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

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

button,
.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 42px;
    border: 0;
    border-radius: 10px;
    padding: 10px 16px;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-blue));
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 18px rgba(35, 124, 119, 0.18);
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

button:hover,
.button:hover {
    background: linear-gradient(135deg, var(--accent-dark), #28598f);
    box-shadow: 0 14px 24px rgba(35, 124, 119, 0.24);
    transform: translateY(-1px);
    text-decoration: none;
}

button:active,
.button:active {
    transform: translateY(0);
}

.button-secondary {
    color: var(--text);
    background: #eaf0f5;
    box-shadow: none;
}

.button-secondary:hover {
    background: #dce6ee;
}

.comments {
    display: grid;
    gap: 12px;
}

.comments[data-comment-stream="true"] {
    min-height: 24px;
}

.private-chat {
    align-self: start;
    position: sticky;
    top: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(249, 251, 255, 0.98)),
        linear-gradient(135deg, rgba(53, 109, 182, 0.06), rgba(215, 101, 79, 0.05));
}

.private-chat::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent), var(--accent-coral));
}

.private-chat-intro {
    margin-bottom: 18px;
}

.private-chat-form {
    display: grid;
    gap: 12px;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.private-chat-form.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.private-chat.is-open .private-chat-intro {
    margin-bottom: 12px;
}

.private-chat button[type="submit"] {
    width: 100%;
}

.comment {
    padding: 14px;
    background: var(--panel-soft);
    animation: cardIn 260ms ease-out both;
    border-radius: 10px;
}

.comment-admin {
    border-left: 4px solid var(--accent);
    background: linear-gradient(90deg, #eef9f6, #ffffff);
}

.comment-user {
    border-left: 4px solid var(--accent-blue);
    background: linear-gradient(90deg, #eef4fb, #ffffff);
}

.comment-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.9rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 0.9rem;
    background: #f4f8fb;
}

tbody tr {
    transition: background-color 150ms ease;
}

tbody tr:hover {
    background: #fbf7ef;
}

.table-wrap {
    overflow-x: auto;
}

.flash {
    margin-bottom: 16px;
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--success-bg);
    color: var(--accent-dark);
    box-shadow: var(--shadow-soft);
    animation: cardIn 240ms ease-out both;
}

.flash-error {
    background: #f7e4e4;
    color: var(--danger);
}

.token-box {
    border: 1px dashed var(--warning);
    border-radius: 10px;
    padding: 12px;
    background: #fff8e8;
    color: var(--warning);
    overflow-wrap: anywhere;
    box-shadow: var(--shadow-soft);
}

.token-code {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    background: #fff3cc;
    color: #8a4d00;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.legacy-token {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    background: #f1f4f8;
    color: var(--muted);
    font-weight: 700;
}

@keyframes pageIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@media (max-width: 760px) {
    .grid,
    .topbar {
        grid-template-columns: 1fr;
        display: grid;
    }

    .topbar nav {
        justify-content: flex-start;
    }

    body.auth-page {
        padding: 12px;
    }

    body.auth-page .panel {
        padding: 28px 22px;
    }

    .private-chat {
        position: static;
    }
}
