:root {
    --bg: #f7f8f4;
    --surface: #ffffff;
    --surface-muted: #eef3ef;
    --ink: #1e2420;
    --muted: #657169;
    --line: #d8dfd9;
    --primary: #246b58;
    --primary-strong: #174d40;
    --accent: #c7822b;
    --danger: #b42318;
    --warning: #9a6700;
    --success: #1f7a4d;
    --focus: rgba(36, 107, 88, 0.24);
    --radius: 8px;
    --shadow: 0 12px 30px rgba(31, 42, 35, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

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

a:hover {
    text-decoration: underline;
}

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

h1 {
    font-size: 2rem;
    line-height: 1.15;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.2rem;
    margin-bottom: 0;
}

h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

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

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    padding: 0.75rem 0.85rem;
    min-height: 44px;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

label {
    display: grid;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 650;
}

label span {
    color: var(--ink);
}

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

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

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

td small,
.recording-card small,
.member-item small {
    display: block;
    color: var(--muted);
    overflow-wrap: anywhere;
}

audio {
    width: 100%;
    min-height: 44px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem clamp(1rem, 2vw, 2rem);
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--ink);
    font-weight: 800;
    text-decoration: none;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.88rem;
}

.nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.nav a {
    color: var(--ink);
    font-weight: 650;
}

.nav-user {
    color: var(--muted);
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shell {
    width: min(1180px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 1.5rem 0 3rem;
}

.footer {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    color: var(--muted);
    border-top: 1px solid var(--line);
    padding: 1.2rem;
}

.auth-page .shell {
    min-height: calc(100vh - 140px);
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(460px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(1.25rem, 3vw, 2rem);
}

.page-heading,
.reading-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.page-heading p,
.reading-toolbar p {
    max-width: 720px;
}

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

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

.center {
    text-align: center;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(1rem, 2vw, 1.35rem);
    margin-bottom: 1rem;
}

.panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    padding: 0.62rem 0.95rem;
    font-weight: 750;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.button:hover {
    background: var(--primary-strong);
    color: #fff;
    text-decoration: none;
}

.button.ghost {
    background: transparent;
    color: var(--primary);
}

.button.ghost:hover {
    background: var(--surface-muted);
    color: var(--primary-strong);
}

.button.small {
    min-height: 34px;
    padding: 0.42rem 0.7rem;
    font-size: 0.88rem;
}

.button.block {
    width: 100%;
}

.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.button-row,
.toolbar-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

.stack {
    display: grid;
    gap: 0.95rem;
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    align-items: end;
    gap: 1rem;
}

.form-actions {
    display: flex;
    justify-content: flex-start;
}

.span-2 {
    grid-column: span 2;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stats-grid.compact {
    grid-template-columns: repeat(3, minmax(96px, 1fr));
    width: min(390px, 100%);
    margin-bottom: 0;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.stat strong {
    display: block;
    color: var(--primary-strong);
    font-size: 1.65rem;
    line-height: 1;
}

.stat span {
    color: var(--muted);
    font-weight: 650;
}

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

.table-form {
    min-width: 240px;
}

.check {
    display: inline-flex;
    grid-template-columns: auto auto;
    align-items: center;
    gap: 0.45rem;
}

.check input {
    width: auto;
    min-height: auto;
}

.flash {
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: var(--radius);
    background: #fff;
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    font-weight: 650;
}

.flash.success {
    border-left-color: var(--success);
}

.flash.danger {
    border-left-color: var(--danger);
}

.flash.warning {
    border-left-color: var(--warning);
}

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

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--primary-strong);
    padding: 0.2rem 0.65rem;
    font-size: 0.82rem;
    font-weight: 800;
}

.reading-page .shell {
    width: min(1600px, calc(100vw - 24px));
}

.reading-toolbar {
    align-items: center;
}

.reading-toolbar h1 {
    font-size: 1.35rem;
}

.reading-frame-wrap {
    width: 100%;
    height: calc(100vh - 190px);
    min-height: 520px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.reading-frame-wrap iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

.workspace-grid,
.peer-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.recorder {
    display: grid;
    grid-template-columns: minmax(180px, 260px) 1fr;
    gap: 1rem;
    align-items: end;
    margin-bottom: 1rem;
}

.recorder audio,
.recorder .muted {
    grid-column: span 2;
}

.file-list,
.recording-grid,
.group-grid,
.member-list {
    display: grid;
    gap: 0.75rem;
}

.file-list {
    margin-top: 1rem;
}

.file-item,
.recording-card,
.member-item,
.group-card,
.review-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    padding: 0.9rem;
}

.file-item {
    display: grid;
    gap: 0.2rem;
    color: var(--ink);
}

.file-item span,
.recording-card span,
.member-item span {
    display: block;
    color: var(--muted);
    overflow-wrap: anywhere;
}

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

.recording-card {
    display: grid;
    gap: 0.7rem;
}

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

.group-head,
.member-item,
.review-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.rating-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 0.9rem;
}

.review-card {
    margin-bottom: 1rem;
}

.review-card audio {
    margin-top: 0.75rem;
}

.review-table {
    margin-top: 1rem;
    border-top: 1px solid var(--line);
    padding-top: 1rem;
}

@media (max-width: 900px) {
    .topbar,
    .page-heading,
    .reading-toolbar,
    .group-head,
    .member-item {
        align-items: flex-start;
        flex-direction: column;
    }

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

    .stats-grid,
    .stats-grid.compact,
    .workspace-grid,
    .peer-grid,
    .group-grid,
    .recording-grid {
        grid-template-columns: 1fr;
    }

    .grid-form,
    .rating-form,
    .inline-form,
    .recorder {
        grid-template-columns: 1fr;
    }

    .span-2,
    .recorder audio,
    .recorder .muted {
        grid-column: span 1;
    }

    .reading-frame-wrap {
        height: 68vh;
        min-height: 420px;
    }
}

@media (max-width: 560px) {
    .shell {
        width: min(100% - 20px, 1180px);
        padding-top: 1rem;
    }

    .panel,
    .auth-card,
    .stat {
        padding: 0.9rem;
    }

    th,
    td {
        padding: 0.75rem 0.65rem;
    }

    .button-row,
    .toolbar-actions {
        width: 100%;
    }

    .button-row .button,
    .toolbar-actions .button {
        flex: 1 1 150px;
    }
}
