:root {
    --bg: #f6f7fb;
    --panel: #ffffff;
    --text: #18202f;
    --muted: #697386;
    --line: #dde3ee;
    --primary: #2a8b8d;
    --primary-dark: #1f6d6f;
    --secondary: #fc761b;
    --secondary-dark: #d85f0d;
    --accent: #fc761b;
    --danger: #dc2626;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --warning-bg: #fef3c7;
    --shadow: 0 18px 45px rgba(24, 32, 47, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "Roboto", Arial, sans-serif;
    display: flex;
    flex-direction: column;
}

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

button,
input,
textarea {
    font: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    width: min(1180px, calc(100% - 32px));
    margin: 16px auto 0;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    color: var(--text);
    font-size: 1.15rem;
    font-weight: 800;
}

.brand img {
    display: block;
    width: auto;
    height: 42px;
    max-width: 180px;
    object-fit: contain;
}

.nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.nav form {
    margin: 0;
}

.nav a,
.nav .link-button {
    min-height: 38px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.94rem;
    font-weight: 800;
}

.nav a:hover,
.nav .link-button:hover {
    background: rgba(42, 139, 141, 0.1);
    color: var(--primary-dark);
}

.nav a.active {
    background: var(--primary);
    color: #ffffff;
}

.nav a.active:hover {
    background: var(--primary-dark);
    color: #ffffff;
}

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

.nav .button:hover {
    background: var(--secondary-dark);
    color: #ffffff;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 32px auto 64px;
    flex: 1;
}

.site-footer {
    width: min(1180px, calc(100% - 32px));
    margin: auto auto 24px;
    padding: 18px 0;
    border-top: 1px solid var(--line);
    color: var(--muted);
    text-align: center;
}

.site-footer p {
    margin: 0;
}

.page-heading,
.auth-panel {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 24px;
}

.auth-panel {
    align-items: center;
    gap: clamp(28px, 6vw, 72px);
    min-height: 72vh;
}

.auth-copy {
    display: grid;
    gap: 12px;
    width: min(540px, 100%);
}

.auth-copy img {
    width: min(420px, 100%);
    height: auto;
    margin-bottom: 8px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

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

h1 {
    max-width: 760px;
    margin-bottom: 8px;
    font-size: clamp(1.25rem, 4vw, 1.5rem);
    line-height: 1.04;
}

h2 {
    font-size: 1.2rem;
}

.eyebrow {
    margin-bottom: 8px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

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

.button,
.link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
}

.button {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 10px 24px rgba(42, 139, 141, 0.22);
    transition: background 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.button.secondary {
    background: rgba(252, 118, 27, 0.14);
    color: var(--secondary-dark);
    box-shadow: none;
}

.button.ghost {
    background: #ffffff;
    color: var(--muted);
    box-shadow: none;
    border: 1px solid var(--line);
}

.button.ghost:hover {
    background: #f8fafc;
    color: var(--primary-dark);
}

.button-small {
    min-height: 34px;
    padding: 8px 12px;
}

.link-button {
    background: transparent;
    color: var(--primary);
    padding: 0;
    min-height: auto;
}

.danger,
.danger:hover {
    color: var(--danger);
}

.danger-button {
    background: var(--danger);
    box-shadow: 0 10px 24px rgba(220, 38, 38, 0.2);
}

.button-row,
.sticky-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.sticky-actions {
    position: sticky;
    bottom: 0;
    justify-content: flex-end;
    padding: 16px 0 0;
    background: linear-gradient(180deg, rgba(246, 247, 251, 0), var(--bg) 36%);
}

.messages {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.message {
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--warning-bg);
    color: #854d0e;
    font-weight: 700;
}

.message.success {
    background: var(--success-bg);
    color: var(--success-text);
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
}

.grid {
    display: grid;
    gap: 18px;
}

.grid.two,
.metric-grid,
.quiz-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.content-sidebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    gap: 18px;
    align-items: start;
}

.metric-grid,
.quiz-grid {
    display: grid;
    gap: 18px;
    margin-bottom: 24px;
}

.metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel,
.form-card,
.quiz-card,
.metric,
.question-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel,
.form-card,
.quiz-card,
.metric {
    padding: 22px;
}

.form-card {
    display: grid;
    gap: 16px;
    width: min(470px, 100%);
}

.form-card label,
.form-card input {
    font-weight: 400;
}

.metric span {
    display: block;
    margin-bottom: 4px;
    font-size: 2.1rem;
    font-weight: 900;
}

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

.metric.compact {
    box-shadow: none;
    padding: 18px;
}

.profile-form,
.profile-summary {
    display: grid;
    gap: 18px;
    align-content: start;
}

.profile-summary h2,
.best-score h3 {
    margin-bottom: 6px;
}

.best-score {
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.best-score strong {
    color: var(--primary-dark);
    font-size: 1.5rem;
}

.code-sample {
    overflow-x: auto;
    margin: 14px 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.panel-header h2 {
    margin: 0;
}

.tabs,
.filter-bar,
.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.search-bar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.search-bar label {
    flex: 1 1 280px;
    font-weight: 400;
}

.search-bar.compact {
    align-items: stretch;
    gap: 10px;
}

.search-bar.compact label {
    flex-basis: 100%;
}

.search-bar.compact .button {
    min-height: 36px;
    padding: 8px 12px;
}

.tabs a,
.filter-bar a,
.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--muted);
    font-weight: 800;
}

.tabs a.active,
.filter-bar a.active {
    border-color: var(--primary);
    background: rgba(42, 139, 141, 0.1);
    color: var(--primary-dark);
}

.pagination {
    justify-content: center;
    margin-top: 12px;
}

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

.section-heading h2 {
    margin-bottom: 4px;
}

.list {
    display: grid;
    gap: 10px;
}

.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcff;
}

.list-row span {
    color: var(--text);
    font-weight: 800;
}

.highlight {
    border-color: var(--primary);
    background: rgba(42, 139, 141, 0.09);
}

.empty {
    margin: 0;
    color: var(--muted);
}

.table-wrap {
    overflow-x: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

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

th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: 0;
}

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

.actions form {
    margin: 0;
}

.actions a,
.actions .link-button {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 10px;
    border: 1px solid rgba(42, 139, 141, 0.18);
    border-radius: 999px;
    background: rgba(42, 139, 141, 0.1);
    color: var(--primary-dark);
    font-size: 0.82rem;
    font-weight: 800;
}

.actions a:hover,
.actions .link-button:hover {
    background: var(--primary);
    color: #ffffff;
}

.actions a.danger,
.actions .link-button.danger {
    border-color: rgba(220, 38, 38, 0.2);
    background: #fee2e2;
    color: var(--danger);
}

.actions a.danger:hover,
.actions .link-button.danger:hover {
    background: var(--danger);
    color: #ffffff;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 10px;
    border-radius: 999px;
    background: #edf2f7;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

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

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 13px;
    background: #ffffff;
    color: var(--text);
    outline: none;
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(42, 139, 141, 0.12);
}

input:disabled {
    background: #f1f5f9;
    color: var(--muted);
    cursor: not-allowed;
}

.checkline,
.choice-input,
.answer-options label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 400;
}

.checkline {
    margin-top: 14px;
}

.builder-form,
.quiz-form {
    display: grid;
    gap: 18px;
}

.question-card {
    display: grid;
    gap: 16px;
    padding: 18px;
    margin-bottom: 16px;
}

.question-grid {
    grid-template-columns: minmax(0, 1fr) 150px;
}

.choice-grid,
.answer-options {
    display: grid;
    gap: 10px;
}

.choice-input input[type="text"] {
    flex: 1;
    font-weight: 400;
}

.quiz-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 230px;
}

.quiz-card h2 {
    margin-top: 14px;
    margin-bottom: 10px;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
}

.question-live {
    box-shadow: none;
}

.question-title {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
}

.question-title h2 {
    margin: 0;
}

.answer-options label {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcff;
    color: var(--text);
    font-weight: 400;
}

.answer-options span {
    font-weight: 400;
}

.question-review {
    padding: 16px 0;
    border-top: 1px solid var(--line);
}

.question-review:first-of-type {
    border-top: 0;
    padding-top: 0;
}

.question-review h3 {
    margin-bottom: 8px;
    font-size: 1rem;
}

.question-review ul {
    display: grid;
    gap: 8px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.question-review li {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.question-review li.correct {
    border-color: #86efac;
    background: var(--success-bg);
    color: var(--success-text);
    font-weight: 400;
}

.correct-text {
    color: var(--success-text);
}

@media (max-width: 860px) {
    .topbar,
    .page-heading,
    .auth-panel,
    .question-title {
        align-items: stretch;
        flex-direction: column;
    }

    .grid.two,
    .content-sidebar,
    .metric-grid,
    .quiz-grid {
        grid-template-columns: 1fr;
    }

    .question-grid {
        grid-template-columns: 1fr;
    }

    .auth-panel {
        min-height: auto;
    }

    .list-row,
    .card-footer {
        align-items: flex-start;
        flex-direction: column;
    }
}
