:root {
    --ink: #17202a;
    --muted: #667085;
    --line: #d7dee8;
    --paper: #f8fafc;
    --panel: #ffffff;
    --teal: #0f766e;
    --teal-dark: #115e59;
    --coral: #d85140;
    --gold: #b7791f;
    --green: #198754;
    --red: #b42318;
    --shadow: 0 18px 60px rgba(22, 34, 51, 0.13);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--paper);
}

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

a:hover {
    text-decoration: underline;
}

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

h1 {
    font-size: clamp(1.7rem, 2.4vw, 2.45rem);
    line-height: 1.05;
    letter-spacing: 0;
}

h2 {
    font-size: 1rem;
    letter-spacing: 0;
}

input,
select,
button {
    font: inherit;
}

input,
select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.68rem 0.78rem;
    color: var(--ink);
    background: #fff;
}

button {
    border: 0;
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

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

.tight {
    margin-bottom: 0.6rem;
}

[hidden],
.hidden {
    display: none !important;
}

.notice:empty {
    display: none !important;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--teal), #1c8f98 52%, var(--coral));
    color: white;
    font-weight: 800;
    box-shadow: 0 12px 36px rgba(15, 118, 110, 0.24);
}

.brand-mark.small {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 0.8rem;
}

.version-badge {
    display: inline-flex;
    align-items: center;
    width: max-content;
    min-height: 26px;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    color: var(--muted);
    background: #e9eef5;
    font-size: 0.8rem;
    font-weight: 800;
}

.version-badge.small {
    min-height: 24px;
    padding: 0.2rem 0.46rem;
    font-size: 0.74rem;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 2rem;
    background:
        radial-gradient(circle at 18% 22%, rgba(15, 118, 110, 0.13), transparent 28rem),
        linear-gradient(135deg, #f8fbfb 0%, #eef4f6 52%, #fff8f4 100%);
}

.login-shell {
    width: min(520px, 100%);
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
}

.login-panel,
.login-aside,
.admin-panel,
.metric-card,
.caption-box {
    background: rgba(255, 255, 255, 0.93);
    border: 1px solid rgba(215, 222, 232, 0.9);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-panel {
    padding: clamp(1.4rem, 5vw, 3.2rem);
}

.login-panel h1 {
    margin: 1.2rem 0 0.45rem;
}

.login-aside {
    padding: clamp(1.2rem, 3vw, 2rem);
    align-self: stretch;
}

.demo-grid {
    display: grid;
    gap: 0.8rem;
}

.demo-grid div,
.credential-list {
    display: grid;
    gap: 0.22rem;
    padding: 0.85rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.demo-grid strong,
.credential-list strong {
    color: var(--ink);
}

.stacked-form,
.admin-form {
    display: grid;
    gap: 0.9rem;
}

.stacked-form label,
.admin-form label {
    display: grid;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.primary-button,
.control-button,
.danger-button {
    min-height: 42px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    padding: 0.7rem 1rem;
    font-weight: 700;
    text-align: center;
}

.primary-button {
    background: var(--teal);
    color: white;
}

.primary-button:hover {
    background: var(--teal-dark);
    text-decoration: none;
}

.control-button {
    color: var(--ink);
    background: #e9eef5;
}

.danger-button {
    color: white;
    background: var(--coral);
}

.compact {
    min-height: 36px;
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
}

.notice {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    margin-bottom: 1rem;
}

.notice.error {
    border-color: rgba(180, 35, 24, 0.35);
    color: var(--red);
    background: #fff6f5;
}

.notice.success {
    border-color: rgba(25, 135, 84, 0.25);
    color: var(--green);
    background: #f2fbf6;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    min-height: 70px;
    padding: 0.9rem clamp(1rem, 3vw, 2.2rem);
    border-bottom: 1px solid var(--line);
    background: rgba(248, 250, 252, 0.94);
    backdrop-filter: blur(14px);
}

.wordmark {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--ink);
    font-weight: 800;
}

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

.topnav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.85rem;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.95rem;
}

.call-layout {
    width: min(1240px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.3rem 0 2.4rem;
}

.local-layout {
    width: min(980px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.3rem 0 2.4rem;
}

.call-header,
.local-header,
.admin-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.call-header h1,
.local-header h1,
.admin-heading h1 {
    margin-bottom: 0.32rem;
}

.status-strip {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    max-width: 220px;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    color: var(--muted);
    background: #e9eef5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-pill[data-tone="good"] {
    color: #0f5132;
    background: #dff4e8;
}

.status-pill[data-tone="bad"] {
    color: var(--red);
    background: #fde8e5;
}

.stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 0.32fr);
    gap: 1rem;
    align-items: stretch;
}

.video-tile {
    position: relative;
    min-height: 250px;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid #101828;
    background:
        linear-gradient(135deg, rgba(23, 32, 42, 0.96), rgba(23, 32, 42, 0.88)),
        repeating-linear-gradient(45deg, transparent 0 16px, rgba(255,255,255,0.04) 16px 32px);
    box-shadow: var(--shadow);
}

.local-tile {
    align-self: start;
    min-height: 180px;
}

.video-tile video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    background: #111827;
}

.tile-label {
    position: absolute;
    left: 0.8rem;
    bottom: 0.8rem;
    max-width: calc(100% - 1.6rem);
    display: inline-grid;
    gap: 0.1rem;
    padding: 0.48rem 0.65rem;
    border-radius: 8px;
    color: white;
    background: rgba(12, 18, 28, 0.68);
    backdrop-filter: blur(10px);
}

.tile-label span {
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.84rem;
}

.caption-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.caption-box {
    padding: 1rem;
    min-height: 118px;
}

.caption-box span {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--gold);
    font-weight: 800;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.caption-box.accent span {
    color: var(--teal);
}

.caption-box p {
    margin-bottom: 0;
    color: var(--ink);
    font-size: 1.05rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.call-controls {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 1rem;
}

.visual-transcript {
    margin-top: 1rem;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.transcript-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--line);
    background: #f6f8fb;
}

.transcript-head h2 {
    margin: 0;
    font-size: 1rem;
}

.transcript-head span {
    color: var(--muted);
    font-size: 0.86rem;
}

.transcript-log {
    display: grid;
    gap: 0.7rem;
    max-height: 260px;
    overflow-y: auto;
    padding: 1rem;
}

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

.transcript-line {
    display: grid;
    gap: 0.25rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--line);
    border-left: 4px solid var(--gold);
    border-radius: 8px;
    background: #fff;
}

.transcript-line.translated {
    border-left-color: var(--teal);
    background: #f6fbfb;
}

.transcript-line.draft {
    opacity: 0.78;
}

.transcript-line span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.transcript-line p {
    margin: 0;
    color: var(--ink);
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.room-choice-grid {
    display: grid;
    gap: 0.8rem;
    margin-top: 1rem;
}

.room-choice {
    display: grid;
    gap: 0.6rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7fafc;
}

.room-choice span {
    color: var(--muted);
}

.room-choice-actions,
.empty-actions {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.local-console {
    display: grid;
    grid-template-columns: minmax(220px, 0.42fr) minmax(280px, 0.58fr);
    gap: 1rem;
    align-items: stretch;
    margin-bottom: 1rem;
}

.local-meter,
.mode-panel,
.language-panel {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(215, 222, 232, 0.9);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.local-meter {
    min-height: 240px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(23, 32, 42, 0.96), rgba(30, 57, 65, 0.93));
}

.local-meter span {
    width: 118px;
    height: 118px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--teal), #23a094 55%, var(--coral));
    box-shadow: 0 0 0 22px rgba(255, 255, 255, 0.06), 0 24px 70px rgba(0, 0, 0, 0.28);
    transition: transform 90ms linear;
}

.mode-panel {
    display: grid;
    align-content: center;
    gap: 1rem;
    padding: clamp(1rem, 3vw, 1.4rem);
}

.segmented-control {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
    padding: 0.35rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f6f8fb;
}

.segment {
    min-height: 42px;
    border-radius: 8px;
    color: var(--muted);
    background: transparent;
    font-weight: 800;
    white-space: nowrap;
}

.segment.active {
    color: #fff;
    background: var(--teal);
}

.local-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
}

.local-output-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.language-panel {
    min-height: 220px;
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
}

.language-panel-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.65rem;
    align-items: center;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--line);
    background: #f6f8fb;
}

.language-panel-head span {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    color: #fff;
    background: var(--teal);
    font-size: 0.78rem;
    font-weight: 900;
}

.language-panel[data-language="ja"] .language-panel-head span {
    background: var(--coral);
}

.language-panel-head strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.language-panel-head em {
    color: var(--muted);
    font-style: normal;
    font-size: 0.84rem;
}

.language-panel p {
    margin: 0;
    padding: 1rem;
    font-size: clamp(1.1rem, 2vw, 1.45rem);
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.empty-state {
    max-width: 680px;
    margin: 2rem auto;
    padding: 2rem;
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.admin-shell {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.4rem 0 2.4rem;
}

.admin-shell.narrow,
.admin-panel.narrow {
    max-width: 720px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.metric-card {
    padding: 1rem;
    display: grid;
    gap: 0.4rem;
}

.metric-card span {
    color: var(--muted);
}

.metric-card strong {
    font-size: 2rem;
}

.panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.admin-panel {
    padding: 1rem;
    margin-bottom: 1rem;
}

.admin-panel h2 {
    margin-bottom: 0.8rem;
}

.setting-status {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7fafc;
}

.setting-status span,
.setting-status em {
    color: var(--muted);
}

.setting-status strong {
    color: var(--ink);
}

.key-value {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--line);
}

.key-value:last-child {
    border-bottom: 0;
}

.key-value span {
    color: var(--muted);
}

.grid-form {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    align-items: end;
}

.check-row {
    min-height: 42px;
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: 0.55rem !important;
}

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

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
    font-size: 0.92rem;
}

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

th {
    color: var(--muted);
    font-weight: 800;
    background: #f6f8fb;
}

td input,
td select {
    min-width: 130px;
}

@media (max-width: 900px) {
    .login-shell,
    .stage,
    .caption-row,
    .local-console,
    .local-output-grid,
    .panel-grid,
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .call-header,
    .local-header,
    .admin-heading,
    .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .status-strip,
    .topnav {
        justify-content: flex-start;
    }

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

@media (max-width: 560px) {
    .login-page {
        padding: 1rem;
    }

    .call-layout,
    .local-layout,
    .admin-shell {
        width: min(100% - 1rem, 1180px);
    }

    .call-controls > *,
    .local-actions > * {
        flex: 1 1 45%;
    }

    .segmented-control,
    .local-actions {
        grid-template-columns: 1fr;
    }

    .primary-button,
    .control-button,
    .danger-button {
        padding-left: 0.72rem;
        padding-right: 0.72rem;
    }
}
