:root {
    color-scheme: light;
    --portal-blue: #1769e8;
    --portal-blue-dark: #0b3f91;
    --portal-navy: #10244a;
    --portal-text: #31425f;
    --portal-muted: #6a7890;
    --portal-border: #dce7f5;
    --portal-border-strong: #bcd4f5;
    --portal-surface: #ffffff;
    --portal-page: #f5f9ff;
    --portal-ice: #edf5ff;
    --portal-green: #1ca36b;
    --portal-danger: #cf4553;
    --portal-shadow: 0 18px 54px rgba(31, 71, 124, 0.1);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body.portal {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--portal-text);
    background: var(--portal-page);
    font-family: "Heebo", "Segoe UI", Arial, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body.portal a {
    color: inherit;
}

body.portal button,
body.portal input {
    font: inherit;
}

body.portal button {
    cursor: pointer;
}

[hidden] {
    display: none !important;
}

.portal-shell {
    width: min(1360px, calc(100% - 40px));
    margin-inline: auto;
}

.workspace-topbar {
    border-bottom: 1px solid var(--portal-border);
    background: #fff;
}

.workspace-topbar-inner {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--portal-blue) !important;
    text-decoration: none;
}

.brand-mark {
    height: 28px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    direction: ltr;
}

.brand-mark i {
    width: 2px;
    border-radius: 4px;
    background: currentColor;
}

.brand-mark i:nth-child(1),
.brand-mark i:nth-child(6) { height: 8px; }
.brand-mark i:nth-child(2),
.brand-mark i:nth-child(5) { height: 15px; }
.brand-mark i:nth-child(3) { height: 26px; }
.brand-mark i:nth-child(4) { height: 19px; }

.brand-copy {
    display: grid;
    line-height: 1;
}

.brand-name {
    font-size: 22px;
    font-weight: 850;
    letter-spacing: -0.045em;
}

.brand-note {
    margin-top: 6px;
    color: #7890ad;
    font-size: 8px;
    font-weight: 750;
    letter-spacing: 0.14em;
}

.workspace-topbar-center,
.user-actions,
.service-state {
    display: flex;
    align-items: center;
}

.workspace-topbar-center {
    gap: 14px;
}

.service-state {
    gap: 8px;
    border-radius: 999px;
    padding: 7px 11px;
    color: #287151;
    background: #effaf5;
    font-size: 11px;
    font-weight: 750;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--portal-green);
    box-shadow: 0 0 0 4px rgba(28, 163, 107, 0.09);
}

.service-state.error {
    color: #a64651;
    background: #fff1f3;
}

.service-state.error .status-dot {
    background: var(--portal-danger);
}

.workspace-security {
    color: var(--portal-muted);
    font-size: 11px;
}

.user-actions {
    gap: 12px;
}

.user-chip {
    display: grid;
    text-align: end;
}

.user-chip b {
    max-width: 150px;
    overflow: hidden;
    color: var(--portal-navy);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chip span {
    color: var(--portal-muted);
    font-size: 10px;
}

.button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--portal-border);
    border-radius: 11px;
    padding: 0 16px;
    color: var(--portal-navy);
    background: #fff;
    text-decoration: none;
    font-weight: 780;
    transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.button:hover {
    border-color: var(--portal-border-strong);
    transform: translateY(-1px);
}

.button.primary {
    color: #fff;
    border-color: var(--portal-blue);
    background: var(--portal-blue);
    box-shadow: 0 8px 20px rgba(23, 105, 232, 0.18);
}

.button.primary:hover {
    background: #0f5fd8;
}

.button.ghost {
    background: #fff;
}

.button.danger {
    color: var(--portal-danger);
    border-color: #f0c9cf;
    background: #fff;
}

.button.small {
    min-height: 36px;
    padding-inline: 12px;
    font-size: 11px;
}

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

.workspace-main {
    padding-block: 28px 54px;
}

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

.workspace-kicker {
    color: var(--portal-blue);
    font-size: 9px;
    font-weight: 850;
    letter-spacing: 0.14em;
}

.workspace-heading h1 {
    margin: 3px 0 2px;
    color: var(--portal-navy);
    font-size: 30px;
    line-height: 1.15;
    letter-spacing: -0.04em;
}

.workspace-heading p {
    margin: 0;
    color: var(--portal-muted);
    font-size: 13px;
}

.workspace-app {
    min-height: 610px;
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr) 300px;
    overflow: hidden;
    border: 1px solid var(--portal-border);
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--portal-shadow);
}

.workspace-nav {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 18px 14px;
    border-inline-end: 1px solid var(--portal-border);
    background: #fbfdff;
}

.workspace-nav > a,
.workspace-nav > button {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 11px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0 12px;
    color: #536984;
    background: transparent;
    text-decoration: none;
    text-align: start;
    font-size: 12px;
}

.workspace-nav > a span,
.workspace-nav > button span {
    width: 24px;
    color: var(--portal-blue);
    text-align: center;
    font-size: 15px;
}

.workspace-nav > a.active,
.workspace-nav > a:hover,
.workspace-nav > button:hover {
    color: var(--portal-blue-dark);
    border-color: #d5e6fb;
    background: var(--portal-ice);
}

.workspace-help {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: auto;
    border: 1px solid var(--portal-border);
    border-radius: 12px;
    padding: 13px;
    background: #fff;
}

.workspace-help > span {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--portal-blue);
    background: var(--portal-ice);
    font-weight: 850;
}

.workspace-help b,
.workspace-help small {
    display: block;
}

.workspace-help b {
    color: var(--portal-navy);
    font-size: 10px;
}

.workspace-help small {
    margin-top: 3px;
    color: var(--portal-muted);
    font-size: 9px;
    line-height: 1.45;
}

.workspace-editor {
    min-width: 0;
    padding: 18px;
    background: #fff;
}

.workspace-mode-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-bottom: 15px;
    border-radius: 12px;
    padding: 5px;
    background: #f3f7fc;
}

.workspace-mode-tabs button {
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: #60718b;
    background: transparent;
    font-weight: 780;
}

.workspace-mode-tabs button.active {
    color: var(--portal-blue);
    border-color: #aecaef;
    background: #fff;
    box-shadow: 0 3px 10px rgba(37, 78, 133, 0.07);
}

.workspace-source-panel {
    min-height: 245px;
}

.drop-zone {
    min-height: 245px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 10px;
    border: 1.5px dashed #a9c8ef;
    border-radius: 15px;
    padding: 24px;
    color: var(--portal-text);
    background: #f8fbff;
    text-align: center;
    cursor: pointer;
    transition: border-color 150ms ease, background 150ms ease;
}

.drop-zone.dragging,
.drop-zone:hover {
    border-color: var(--portal-blue);
    background: #f2f7ff;
}

.drop-zone input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
}

.drop-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    color: var(--portal-blue);
    background: var(--portal-ice);
    font-size: 24px;
    font-weight: 800;
}

.drop-copy b,
.drop-copy small {
    display: block;
}

.drop-copy b {
    color: var(--portal-navy);
    font-size: 16px;
}

.drop-copy small {
    margin-top: 5px;
    color: var(--portal-muted);
    font-size: 10px;
}

.selected-file {
    min-height: 16px;
    color: var(--portal-blue-dark);
    font-size: 10px;
    font-weight: 700;
}

.live-recorder {
    display: grid;
    align-content: center;
    border: 1px solid var(--portal-border);
    border-radius: 15px;
    padding: 22px;
    background: #f9fbff;
}

.recorder-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.recorder-state {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #526681;
    font-size: 12px;
}

.recorder-state i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9aabc0;
}

.live-recorder.recording .recorder-state {
    color: #24704f;
}

.live-recorder.recording .recorder-state i {
    background: var(--portal-green);
    box-shadow: 0 0 0 5px rgba(28, 163, 107, 0.09);
}

.recorder-status-row time {
    direction: ltr;
    color: var(--portal-navy);
    font-size: 24px;
    font-weight: 850;
}

.recorder-wave {
    height: 74px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-block: 15px 8px;
}

.recorder-wave i {
    width: 3px;
    height: 15px;
    border-radius: 9px;
    background: var(--portal-blue);
}

.recorder-wave i:nth-child(2n) { height: 35px; }
.recorder-wave i:nth-child(3n) { height: 52px; }
.live-recorder.recording .recorder-wave i { animation: portal-wave 800ms ease-in-out infinite alternate; }
.live-recorder.recording .recorder-wave i:nth-child(2n) { animation-delay: -250ms; }
.live-recorder.recording .recorder-wave i:nth-child(3n) { animation-delay: -500ms; }

@keyframes portal-wave {
    from { transform: scaleY(0.45); opacity: 0.55; }
    to { transform: scaleY(1); opacity: 1; }
}

.live-recorder > p {
    margin: 0;
    color: var(--portal-muted);
    text-align: center;
    font-size: 11px;
}

.recorder-actions {
    display: flex;
    justify-content: center;
    gap: 9px;
    margin-top: 16px;
}

.upload-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 14px;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--portal-text);
    cursor: pointer;
}

.toggle input {
    width: 34px;
    height: 19px;
    accent-color: var(--portal-blue);
}

.toggle span,
.toggle b,
.toggle small {
    display: block;
}

.toggle b {
    color: var(--portal-navy);
    font-size: 11px;
}

.toggle small {
    color: var(--portal-muted);
    font-size: 9px;
}

.submit-transcription {
    min-width: 180px;
}

.result-panel {
    display: none;
    margin-top: 14px;
    border: 1px solid var(--portal-border);
    border-radius: 14px;
    padding: 17px;
    background: #fff;
}

.result-panel.visible {
    display: block;
}

.result-panel.error {
    border-color: #edc4ca;
    background: #fff8f9;
}

.result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.result-head span,
.result-head b {
    display: block;
}

.result-head span {
    color: var(--portal-blue);
    font-size: 9px;
    font-weight: 850;
}

.result-head b {
    color: var(--portal-navy);
    font-size: 14px;
}

.result-text {
    min-height: 72px;
    color: var(--portal-text);
    white-space: pre-wrap;
    font-size: 13px;
    line-height: 1.75;
}

.workspace-history {
    min-width: 0;
    border-inline-start: 1px solid var(--portal-border);
    background: #fbfdff;
}

.history-head {
    min-height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px;
    border-bottom: 1px solid var(--portal-border);
}

.history-head span {
    color: var(--portal-blue);
    font-size: 9px;
    font-weight: 850;
}

.history-head h2 {
    margin: 2px 0 0;
    color: var(--portal-navy);
    font-size: 15px;
}

.history-list {
    max-height: 525px;
    display: grid;
    gap: 8px;
    overflow: auto;
    padding: 12px;
}

.history-item {
    border: 1px solid var(--portal-border);
    border-radius: 12px;
    padding: 12px;
    background: #fff;
}

.history-item-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.history-file {
    max-width: 170px;
    overflow: hidden;
    color: var(--portal-navy);
    font-size: 11px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-date {
    margin-top: 3px;
    color: var(--portal-muted);
    font-size: 9px;
}

.history-text {
    display: -webkit-box;
    overflow: hidden;
    color: #576985;
    font-size: 10px;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.empty-state {
    min-height: 180px;
    display: grid;
    place-items: center;
    border: 1px dashed var(--portal-border-strong);
    border-radius: 12px;
    padding: 24px;
    color: var(--portal-muted);
    background: #fff;
    text-align: center;
    font-size: 11px;
}

.auth-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(440px, 1.05fr);
    background: #fff;
}

.auth-story {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 52px clamp(34px, 7vw, 100px);
    border-inline-end: 1px solid var(--portal-border);
    background: linear-gradient(145deg, #f8fbff, #edf5ff);
}

.auth-story-main {
    max-width: 560px;
    margin-block: auto;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--portal-blue);
    font-size: 12px;
    font-weight: 800;
}

.eyebrow-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--portal-green);
}

.auth-story h1 {
    margin: 20px 0;
    color: var(--portal-navy);
    font-size: clamp(44px, 5vw, 66px);
    line-height: 1.03;
    letter-spacing: -0.055em;
}

.gradient-text {
    color: var(--portal-blue-dark);
}

.auth-story p {
    margin: 0;
    color: var(--portal-muted);
    font-size: 17px;
}

.auth-points {
    display: grid;
    gap: 11px;
    margin-top: 30px;
}

.auth-point {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--portal-text);
    font-size: 13px;
}

.auth-point i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--portal-blue);
}

.auth-form-side {
    display: grid;
    place-items: center;
    padding: 32px;
    background: #fff;
}

.auth-card {
    width: min(440px, 100%);
    border: 1px solid var(--portal-border);
    border-radius: 20px;
    padding: 34px;
    background: #fff;
    box-shadow: var(--portal-shadow);
}

.auth-card .nav-link {
    color: var(--portal-blue);
    text-decoration: none;
    font-size: 12px;
    font-weight: 750;
}

.auth-card h2 {
    margin: 26px 0 5px;
    color: var(--portal-navy);
    font-size: 28px;
}

.auth-card > p {
    margin: 0 0 24px;
    color: var(--portal-muted);
    font-size: 13px;
}

.field {
    display: grid;
    gap: 7px;
    margin-bottom: 15px;
}

.field label {
    color: var(--portal-text);
    font-size: 12px;
    font-weight: 750;
}

.field input {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--portal-border);
    border-radius: 11px;
    padding: 0 13px;
    color: var(--portal-navy);
    outline: none;
    background: #fff;
}

.field input:focus {
    border-color: var(--portal-blue);
    box-shadow: 0 0 0 3px rgba(23, 105, 232, 0.08);
}

.form-error {
    margin-bottom: 15px;
    border: 1px solid #efc8cd;
    border-radius: 11px;
    padding: 10px 12px;
    color: #a6404c;
    background: #fff3f4;
    font-size: 12px;
}

.form-note {
    margin-top: 17px;
    color: var(--portal-muted);
    font-size: 11px;
}

.form-note a {
    color: var(--portal-blue);
    text-decoration: none;
}

@media (max-width: 1050px) {
    .workspace-app { grid-template-columns: 165px minmax(0, 1fr); }
    .workspace-history { grid-column: 1 / -1; border-inline-start: 0; border-top: 1px solid var(--portal-border); }
    .history-list { max-height: none; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .portal-shell { width: min(100% - 24px, 1360px); }
    .workspace-topbar-inner { min-height: 66px; }
    .workspace-topbar-center, .user-chip { display: none; }
    .workspace-heading { align-items: flex-start; flex-direction: column; }
    .workspace-app { grid-template-columns: 1fr; }
    .workspace-nav { flex-direction: row; overflow-x: auto; border-inline-end: 0; border-bottom: 1px solid var(--portal-border); }
    .workspace-nav > a, .workspace-nav > button { min-width: max-content; }
    .workspace-nav > a.active, .workspace-help { display: none; }
    .workspace-editor { padding: 14px; }
    .history-list { grid-template-columns: 1fr; }
    .upload-options { align-items: stretch; flex-direction: column; }
    .submit-transcription { width: 100%; }
    .auth-layout { grid-template-columns: 1fr; }
    .auth-story { min-height: 390px; padding: 28px; border-inline-end: 0; border-bottom: 1px solid var(--portal-border); }
    .auth-form-side { padding: 40px 14px; }
}

@media (max-width: 480px) {
    .workspace-heading h1 { font-size: 27px; }
    .workspace-mode-tabs button { font-size: 11px; }
    .drop-zone { min-height: 220px; padding: 18px; }
    .recorder-actions { align-items: stretch; flex-direction: column; }
    .auth-story h1 { font-size: 42px; }
    .auth-card { padding: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .button { transition: none; }
    .live-recorder.recording .recorder-wave i { animation: none; }
}
