:root {
    --paper: #f3f5f8;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --ink: #172033;
    --muted: #5d6878;
    --line: #d8dee8;
    --line-strong: #bcc6d4;
    --primary: #1f5ca9;
    --primary-dark: #16467f;
    --primary-soft: #eaf2fc;
    --teal: #147d77;
    --teal-soft: #e8f6f4;
    --success: #167348;
    --success-soft: #e8f5ee;
    --danger: #ad2f2f;
    --danger-soft: #fbecec;
    --shadow: 0 12px 32px rgba(32, 50, 76, 0.08);
    --radius: 6px;
}

* {
    box-sizing: border-box;
    letter-spacing: 0;
}

[hidden] {
    display: none !important;
}

html {
    min-width: 320px;
    background: var(--paper);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    font-size: 18px;
    line-height: 1.5;
}

button,
input {
    font: inherit;
}

button,
a,
label {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(31, 92, 169, 0.24);
    outline-offset: 2px;
}

a {
    color: inherit;
    text-decoration: none;
}

svg {
    display: block;
    width: 20px;
    height: 20px;
    stroke-width: 1.8;
}

.mono {
    font-family: Consolas, "SFMono-Regular", monospace;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 76px;
    background: rgba(255, 255, 255, 0.97);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.header-inner {
    display: grid;
    grid-template-columns: minmax(360px, auto) 1fr auto;
    align-items: center;
    gap: 28px;
    width: min(calc(100% - 64px), 1680px);
    height: 100%;
    margin: 0 auto;
}

.brand {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 11px;
}

.brand-mark {
    display: grid;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    place-items: center;
    color: #fff;
    background: var(--primary);
    border-radius: 5px;
}

.brand-mark svg {
    width: 22px;
    height: 22px;
}

.brand-name {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 24px;
    font-weight: 700;
}

.brand-divider {
    width: 1px;
    height: 24px;
    background: var(--line);
}

.brand-description {
    overflow: hidden;
    color: var(--muted);
    font-size: 17px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.primary-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.primary-nav a {
    display: inline-flex;
    height: 46px;
    padding: 0 17px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--muted);
    border: 1px solid transparent;
    border-radius: 5px;
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
}

.primary-nav a:hover {
    color: var(--ink);
    background: var(--surface-soft);
}

.primary-nav a.active {
    color: var(--primary-dark);
    background: var(--primary-soft);
    border-color: #c9dbf2;
}

.service-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 16px;
    font-weight: 650;
    white-space: nowrap;
}

.service-pill .status-dot {
    width: 9px;
    height: 9px;
    flex: 0 0 9px;
    background: #8a94a3;
    border-radius: 50%;
}

.service-pill.online {
    color: var(--success);
}

.service-pill.online .status-dot {
    background: var(--success);
}

.service-pill.offline {
    color: var(--danger);
}

.service-pill.offline .status-dot {
    background: var(--danger);
}

.app-main {
    min-height: calc(100vh - 76px);
}

.page-shell {
    width: min(calc(100% - 64px), 1680px);
    margin: 0 auto;
    padding: 26px 0 38px;
}

.home-shell {
    padding-top: 30px;
}

.home-intro,
.page-intro {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px;
    margin-bottom: 22px;
}

.section-label {
    margin: 0 0 7px;
    color: var(--primary);
    font-size: 16px;
    font-weight: 750;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

.home-intro h1,
.page-intro h1 {
    margin-bottom: 8px;
    font-family: Georgia, "Times New Roman", "Microsoft YaHei", serif;
    font-size: 42px;
    line-height: 1.16;
}

.home-intro p:last-child,
.page-intro p:last-child {
    max-width: 720px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 20px;
}

.home-workflows {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid var(--line-strong);
    border-bottom: 1px solid var(--line-strong);
}

.home-workflow {
    display: grid;
    min-width: 0;
    min-height: 164px;
    padding: 24px 26px;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    align-items: center;
    gap: 20px;
    transition: background 150ms ease;
}

.home-workflow:first-child {
    border-right: 1px solid var(--line-strong);
}

.home-workflow:hover {
    background: var(--primary-soft);
}

.workflow-icon {
    display: grid;
    width: 52px;
    height: 52px;
    place-items: center;
    color: var(--primary-dark);
    background: var(--primary-soft);
    border: 1px solid #c9dbf2;
    border-radius: 5px;
}

.workflow-icon svg {
    width: 27px;
    height: 27px;
}

.workflow-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 7px;
}

.workflow-copy small {
    color: var(--primary);
    font-size: 14px;
    font-weight: 750;
}

.workflow-copy strong {
    font-family: Georgia, "Times New Roman", "Microsoft YaHei", serif;
    font-size: 30px;
}

.workflow-copy > span {
    max-width: 520px;
    color: var(--muted);
    font-size: 18px;
}

.workflow-action {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    color: var(--primary-dark);
    font-size: 18px;
    font-weight: 700;
}

.home-history {
    margin-top: 30px;
    background: transparent;
    box-shadow: none;
}

.home-history-heading {
    display: flex;
    margin-bottom: 10px;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.home-history-heading .section-label {
    margin-bottom: 2px;
}

.home-history-heading h2 {
    margin: 0;
    font-family: Georgia, "Times New Roman", "Microsoft YaHei", serif;
    font-size: 30px;
}

.home-history-heading > a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--primary-dark);
    font-size: 17px;
    font-weight: 700;
}

.home-history-list {
    background: transparent;
    border-top: 1px solid var(--line-strong);
    box-shadow: none;
}

.home-history-row {
    display: grid;
    min-height: 112px;
    padding: 12px 0;
    grid-template-columns: minmax(205px, 0.72fr) minmax(330px, 1.15fr) 120px max-content;
    align-items: center;
    gap: 26px;
    border-bottom: 1px solid var(--line);
}

.home-record-name,
.home-record-result,
.home-record-duration {
    min-width: 0;
}

.home-record-name time {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: 15px;
}

.home-record-result {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: baseline;
    gap: 4px 12px;
}

.home-record-result .history-status {
    grid-row: 1 / 3;
    padding-left: 0;
    border-left: 0;
}

.home-record-result strong {
    overflow: hidden;
    font-size: 21px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-record-result small {
    overflow: hidden;
    color: var(--muted);
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-record-duration span,
.home-record-duration strong {
    display: block;
}

.home-record-duration span {
    color: var(--muted);
    font-size: 14px;
}

.home-record-duration strong {
    margin-top: 4px;
    font-family: Consolas, monospace;
    font-size: 19px;
}

.home-record-thumb {
    position: relative;
    display: block;
    width: min(180px, calc(96px * var(--thumb-ratio, 1.5)));
    height: min(96px, calc(180px / var(--thumb-ratio, 1.5)));
    overflow: hidden;
    border-radius: 4px;
}

.home-record-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.home-record-thumb span {
    position: absolute;
    right: 5px;
    bottom: 5px;
    padding: 2px 6px;
    color: #fff;
    background: rgba(23, 32, 51, 0.78);
    border-radius: 3px;
    font-size: 12px;
}

.home-history-empty {
    display: flex;
    min-height: 100px;
    align-items: center;
    gap: 14px;
    color: var(--muted);
    border-top: 1px solid var(--line-strong);
    border-bottom: 1px solid var(--line);
}

.home-history-empty svg {
    color: var(--primary);
}

.button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 5px;
    cursor: pointer;
}

.button {
    min-width: 0;
    height: 48px;
    padding: 0 18px;
    gap: 9px;
    font-size: 17px;
    font-weight: 700;
    white-space: nowrap;
}

.button.primary {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.button.primary:hover:not(:disabled) {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.button.secondary {
    color: #34445a;
    background: #fff;
    border-color: var(--line-strong);
}

.button.secondary:hover:not(:disabled) {
    color: var(--primary-dark);
    border-color: #8aa8ce;
}

.button.light {
    color: var(--ink);
    background: #fff;
    border-color: #fff;
}

.button:disabled,
.icon-button:disabled {
    cursor: default;
    opacity: 0.58;
}

.button.loading svg {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.icon-button {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    padding: 0;
    color: var(--primary-dark);
    background: var(--primary-soft);
    border-color: #c9dbf2;
}

.page-next {
    flex: 0 0 auto;
}

.compact-button {
    height: 42px;
    padding: 0 14px;
    font-size: 15px;
}

.demo-workspace {
    display: grid;
    grid-template-columns: 390px minmax(0, 1fr);
    align-items: stretch;
    gap: 20px;
}

.demo-workspace.encoder-workspace,
.demo-workspace.decoder-workspace {
    display: block;
}

.demo-controls,
.demo-output {
    min-width: 0;
}

.demo-controls {
    display: flex;
    min-height: 500px;
    padding: 4px 28px 4px 0;
    flex-direction: column;
    border-right: 1px solid var(--line);
}

.encoder-workspace .demo-controls,
.decoder-workspace .demo-controls {
    display: grid;
    min-height: 0;
    padding: 0 0 16px;
    grid-template-columns: minmax(250px, 0.58fr) minmax(360px, 1.42fr) auto;
    align-items: end;
    gap: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line-strong);
}

.demo-output {
    min-height: 500px;
    padding: 4px 0 4px 8px;
}

.encoder-workspace .demo-output,
.decoder-workspace .demo-output {
    min-height: 0;
    padding: 18px 0 0;
}

.control-heading,
.output-heading,
.output-heading > div {
    display: flex;
    align-items: center;
    gap: 12px;
}

.control-heading,
.output-heading {
    min-height: 46px;
    margin-bottom: 18px;
}

.encoder-workspace .control-heading {
    min-height: 48px;
    margin-bottom: 0;
}

.encoder-workspace .control-heading h2 {
    font-size: 21px;
}

.output-heading {
    justify-content: space-between;
}

.control-heading h2,
.output-heading h2 {
    margin: 0;
    font-size: 24px;
    line-height: 1.25;
}

.upload-box {
    display: flex;
    min-height: 160px;
    padding: 20px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: var(--muted);
    background: var(--surface-soft);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: center;
    transition: border-color 150ms ease, background 150ms ease;
}

.encoder-workspace .upload-box,
.decoder-workspace .upload-box {
    min-height: 76px;
    padding: 12px 16px;
    flex-direction: row;
    gap: 12px;
    text-align: left;
}

.encoder-workspace .upload-icon,
.decoder-workspace .upload-icon {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    margin: 0;
}

.encoder-workspace .upload-copy,
.decoder-workspace .upload-copy {
    align-items: flex-start;
}

.encoder-workspace .file-selection,
.decoder-workspace .file-selection {
    margin-top: 4px;
}

.upload-box:hover,
.upload-box.dragover {
    background: var(--primary-soft);
    border-color: var(--primary);
}

.upload-box:focus-within {
    outline: 3px solid var(--primary);
    outline-offset: 3px;
}

.upload-box.disabled {
    cursor: wait;
    opacity: 0.64;
    pointer-events: none;
}

.upload-box input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
}

.upload-icon {
    display: grid;
    width: 46px;
    height: 46px;
    margin-bottom: 10px;
    place-items: center;
    color: var(--primary);
    background: #fff;
    border: 1px solid #c9dbf2;
    border-radius: 5px;
}

.upload-icon svg {
    width: 24px;
    height: 24px;
}

.upload-box strong {
    color: var(--ink);
    font-size: 18px;
}

.upload-copy {
    display: flex;
    min-width: 0;
    align-items: center;
    flex-direction: column;
}

.upload-change {
    display: none;
}

.file-selection {
    display: block;
    max-width: 100%;
    margin-top: 9px;
    overflow: hidden;
    color: var(--primary-dark);
    font-size: 16px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-box.has-file {
    min-height: 48px;
    padding: 0;
    align-items: center;
    justify-content: flex-start;
    flex-direction: row;
    gap: 10px;
    background: transparent;
    border: 0;
    text-align: left;
}

.upload-box.has-file:hover {
    background: transparent;
}

.upload-box.has-file .upload-icon {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    margin: 0;
    background: var(--primary-soft);
}

.upload-box.has-file .upload-copy {
    flex: 1;
    align-items: flex-start;
}

.upload-box.has-file .upload-prompt {
    display: none;
}

.upload-box.has-file .upload-change {
    display: block;
    color: var(--primary-dark);
    font-size: 14px;
}

.upload-box.has-file .file-selection {
    width: 100%;
    margin-top: 0;
    color: var(--muted);
    font-size: 13px;
}

.field-group {
    min-width: 0;
    margin-top: 20px;
}

.encoder-workspace .field-group,
.decoder-workspace .field-group {
    margin-top: 0;
}

.field-label-row {
    display: flex;
    margin-bottom: 8px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #344154;
    font-size: 17px;
    font-weight: 700;
}

.field-label-row span {
    color: var(--muted);
    font-size: 15px;
    font-weight: 500;
}

.input-action-row {
    display: flex;
    gap: 9px;
}

.text-input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    outline: none;
    font-size: 18px;
}

.text-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.button-row {
    display: grid;
    grid-template-columns: 1fr 1.45fr;
    gap: 10px;
    margin-top: 22px;
}

.encoder-workspace .button-row,
.decoder-workspace .button-row {
    grid-template-columns: 1fr;
    margin-top: 0;
}

.encoder-workspace .button-row .button,
.decoder-workspace .button-row .button {
    min-width: 142px;
}

.decoder-workspace .button-row {
    grid-template-columns: auto minmax(150px, 1fr);
}

.image-comparison {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
}

.encoder-workspace .image-canvas {
    aspect-ratio: 16 / 9;
}

.comparison-empty {
    display: flex;
    min-height: 390px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 14px;
    color: var(--muted);
    text-align: center;
}

.comparison-empty svg {
    width: 40px;
    height: 40px;
    color: #7892b3;
}

.comparison-empty strong {
    color: #4b5c73;
    font-size: 18px;
}

.comparison-arrow {
    display: grid;
    place-items: center;
    color: #7a8697;
}

.comparison-arrow svg {
    width: 26px;
    height: 26px;
}

.image-frame {
    display: grid;
    width: 100%;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    grid-template-rows: 44px minmax(0, 1fr) 42px;
    color: var(--ink);
    background: var(--surface-soft);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    cursor: zoom-in;
    text-align: left;
}

.image-frame:disabled {
    cursor: default;
    opacity: 1;
}

.image-frame:hover:not(:disabled) {
    border-color: #7f9fc7;
}

.image-frame-label {
    display: flex;
    padding: 0 15px;
    align-items: center;
    color: #334158;
    background: #fff;
    border-bottom: 1px solid var(--line);
    font-size: 18px;
    font-weight: 750;
}

.image-canvas {
    position: relative;
    display: grid;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    place-items: center;
    background: #edf0f4;
}

.image-canvas img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.image-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 9px;
    color: #7a8697;
    font-size: 17px;
}

.image-empty svg {
    width: 28px;
    height: 28px;
}

.image-meta {
    display: flex;
    min-width: 0;
    padding: 0 14px;
    align-items: center;
    overflow: hidden;
    color: var(--muted);
    background: #fff;
    border-top: 1px solid var(--line);
    font-size: 16px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric-strip {
    display: grid;
    margin-top: 18px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: hidden;
    background: #f7fafc;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.metric-strip > div {
    display: flex;
    min-width: 0;
    padding: 13px 18px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-right: 1px solid var(--line);
}

.metric-strip > div:last-child {
    border-right: 0;
}

.metric-strip span,
.result-metrics span {
    color: var(--muted);
    font-size: 17px;
}

.metric-strip strong {
    color: var(--primary-dark);
    font-family: Consolas, monospace;
    font-size: 23px;
}

.decoder-result-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    align-items: stretch;
    gap: 18px;
}

.decoder-result-layout.is-preview-only {
    grid-template-columns: minmax(0, 1fr);
}

.decoder-result-layout.is-preview-only::after {
    display: none;
}

.decoder-workspace .image-canvas {
    height: clamp(300px, calc(100vh - 438px), 440px);
    aspect-ratio: auto;
}

.decoder-photo,
.decoder-photo .image-frame {
    min-width: 0;
    height: 100%;
}

.watermark-result,
.result-placeholder {
    min-height: 340px;
    padding: 26px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.watermark-result {
    display: flex;
}

.watermark-result > span:first-child {
    color: var(--muted);
    font-size: 18px;
}

.watermark-result > strong {
    max-width: 100%;
    margin: 18px 0 24px;
    overflow-wrap: anywhere;
    color: var(--primary-dark);
    font-size: 40px;
    line-height: 1.2;
}

.result-metrics {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.result-metrics > div {
    display: flex;
    min-width: 0;
    padding: 13px;
    align-items: center;
    flex-direction: column;
    gap: 5px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 5px;
}

.result-metrics strong {
    color: var(--ink);
    font-size: 25px;
}

.match-state {
    margin-top: 18px;
    color: var(--muted);
    font-size: 17px;
    font-weight: 650;
}

.match-state.pass {
    color: var(--success);
}

.match-state.fail {
    color: var(--danger);
}

.result-placeholder {
    display: flex;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-left: 1px solid var(--line-strong);
    border-radius: 0;
}

.result-placeholder > svg {
    width: 34px;
    height: 34px;
    margin-bottom: 12px;
    color: var(--primary);
}

.result-placeholder strong {
    margin-bottom: 6px;
    color: var(--ink);
    font-size: 23px;
}

.result-placeholder span {
    font-size: 17px;
}

.restored-note,
.history-count {
    display: inline-flex;
    min-height: 30px;
    padding: 0 10px;
    align-items: center;
    color: var(--primary-dark);
    background: var(--primary-soft);
    border: 1px solid #c9dbf2;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 650;
}

.history-list {
    background: transparent;
    border-top: 1px solid var(--line-strong);
    box-shadow: none;
}

.history-run {
    display: grid;
    padding: 26px 0;
    grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.28fr);
    gap: 32px;
    background: transparent;
    border-bottom: 1px solid var(--line);
    box-shadow: none;
}

.history-summary {
    min-width: 0;
}

.history-heading {
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-kind,
.history-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 18px;
    font-weight: 750;
}

.history-kind.decode {
    color: var(--teal);
}

.history-status {
    padding-left: 10px;
    border-left: 1px solid var(--line-strong);
    font-size: 16px;
}

.history-status.success {
    color: var(--success);
}

.history-status.error {
    color: var(--danger);
}

.history-summary time {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: 16px;
}

.history-facts {
    display: grid;
    margin: 18px 0 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 16px;
}

.history-facts div {
    min-width: 0;
}

.history-facts dt {
    color: var(--muted);
    font-size: 15px;
}

.history-facts dd {
    margin: 2px 0 0;
    overflow-wrap: anywhere;
    color: var(--ink);
    font-size: 18px;
    font-weight: 700;
}

.history-error {
    margin: 18px 0 0;
    padding: 10px 12px;
    color: var(--danger);
    background: var(--danger-soft);
    border-left: 3px solid var(--danger);
    font-size: 16px;
}

.history-artifacts {
    display: grid;
    min-width: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.history-artifacts:has(.history-artifact:only-child) {
    grid-template-columns: minmax(0, 1fr);
}

.history-artifact {
    display: grid;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    grid-template-rows: minmax(150px, 1fr) auto;
    color: var(--ink);
    background: transparent;
    border: 0;
    cursor: zoom-in;
    text-align: left;
}

.history-thumb {
    display: grid;
    min-height: 150px;
    overflow: hidden;
    place-items: center;
    background: #e9edf2;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
}

.history-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 260px;
    object-fit: contain;
}

.history-artifact:hover .history-thumb {
    border-color: #7f9fc7;
}

.history-artifact-copy {
    display: flex;
    min-width: 0;
    padding-top: 9px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.history-artifact-copy strong {
    font-size: 18px;
}

.history-artifact-copy span {
    overflow: hidden;
    color: var(--muted);
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-empty {
    display: flex;
    min-height: 420px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    color: var(--muted);
    border-top: 1px solid var(--line);
}

.history-empty > svg {
    width: 42px;
    height: 42px;
    color: var(--primary);
}

.history-empty strong {
    color: var(--ink);
    font-size: 21px;
}

.history-empty .button {
    margin-top: 10px;
}

.toast-region {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 90;
    width: min(380px, calc(100vw - 32px));
}

.toast {
    display: flex;
    padding: 15px 17px;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-left: 4px solid var(--primary);
    border-radius: 5px;
    box-shadow: var(--shadow);
    font-size: 15px;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

.image-dialog {
    width: 100vw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 24px;
    color: #fff;
    background: #080b10;
    border: 0;
}

.image-dialog[open] {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.image-dialog::backdrop {
    background: #080b10;
}

.dialog-stage {
    position: fixed;
    top: 22px;
    right: 22px;
    bottom: 82px;
    left: 22px;
    display: grid;
    overflow: auto;
    place-items: center;
}

.dialog-stage img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform-origin: center;
}

.dialog-close {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 2;
    display: grid;
    width: 44px;
    height: 44px;
    padding: 0;
    place-items: center;
    color: #fff;
    background: rgba(0, 0, 0, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.36);
    border-radius: 5px;
    cursor: pointer;
}

.dialog-toolbar {
    position: fixed;
    right: 24px;
    bottom: 20px;
    left: 24px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
}

.dialog-toolbar > span {
    max-width: min(50vw, 560px);
    overflow: hidden;
    color: #d7dce4;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dialog-zoom {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.dialog-zoom > span {
    min-width: 56px;
    color: #fff;
    text-align: center;
}

.icon-button.dark {
    color: #fff;
    background: rgba(20, 25, 33, 0.88);
    border-color: rgba(255, 255, 255, 0.32);
}

@media (min-width: 821px) and (max-height: 800px) {
    .page-shell {
        padding-top: 18px;
        padding-bottom: 18px;
    }

    .page-intro {
        margin-bottom: 14px;
    }

    .page-intro h1 {
        margin-bottom: 5px;
        font-size: 34px;
    }

    .page-intro p:last-child {
        font-size: 16px;
    }

    .home-shell {
        padding-top: 18px;
    }

    .home-intro {
        margin-bottom: 14px;
    }

    .home-workflow {
        min-height: 132px;
        padding-top: 16px;
        padding-bottom: 16px;
    }

    .home-history {
        margin-top: 14px;
    }

    .home-history-heading {
        margin-bottom: 6px;
    }

    .home-history-heading .section-label {
        display: none;
    }

    .home-history-row {
        min-height: 84px;
        padding-top: 6px;
        padding-bottom: 6px;
    }

    .home-record-thumb {
        width: min(150px, calc(82px * var(--thumb-ratio, 1.5)));
        height: min(82px, calc(150px / var(--thumb-ratio, 1.5)));
    }

    .demo-controls,
    .demo-output {
        min-height: 0;
        padding: 18px;
    }

    .encoder-workspace .demo-controls,
    .decoder-workspace .demo-controls {
        padding: 0 0 12px;
    }

    .control-heading,
    .output-heading {
        margin-bottom: 8px;
    }

    .encoder-workspace .demo-output,
    .decoder-workspace .demo-output {
        padding-top: 12px;
    }

    .decoder-workspace .image-canvas {
        height: clamp(230px, calc(100vh - 473px), 420px);
    }

    .upload-box {
        min-height: 130px;
        padding: 14px;
    }

    .field-group {
        margin-top: 14px;
    }

    .button-row {
        margin-top: 16px;
    }

    .encoder-workspace .image-canvas {
        aspect-ratio: 16 / 9;
    }

    .decoder-workspace .image-canvas {
        aspect-ratio: 16 / 9;
    }

    .metric-strip {
        margin-top: 12px;
    }

    .metric-strip > div {
        padding: 10px 14px;
    }
}

@media (max-width: 1080px) {
    .header-inner {
        grid-template-columns: auto 1fr auto;
    }

    .brand-divider,
    .brand-description {
        display: none;
    }

    .demo-workspace {
        grid-template-columns: 310px minmax(0, 1fr);
    }

    .demo-workspace.encoder-workspace,
    .demo-workspace.decoder-workspace {
        display: block;
    }

    .image-comparison {
        grid-template-columns: 1fr 32px 1fr;
        gap: 8px;
    }

    .decoder-result-layout {
        grid-template-columns: 1fr 0.8fr;
    }

    .home-workflow {
        grid-template-columns: 48px minmax(0, 1fr);
    }

    .workflow-action {
        grid-column: 2;
    }

    .home-history-row {
        grid-template-columns: minmax(180px, 0.72fr) minmax(240px, 1.1fr) 110px max-content;
        gap: 16px;
    }
}

@media (max-width: 1008px) {
    .encoder-workspace .demo-controls,
    .decoder-workspace .demo-controls {
        grid-template-columns: minmax(250px, 0.8fr) minmax(360px, 1.2fr);
        gap: 14px;
    }

    .encoder-workspace .button-row,
    .decoder-workspace .button-row {
        grid-column: 1 / -1;
    }
}

@media (max-width: 820px) {
    .app-header {
        height: auto;
    }

    .header-inner {
        display: flex;
        width: calc(100% - 28px);
        min-height: 64px;
        flex-wrap: wrap;
        gap: 8px 14px;
    }

    .brand {
        flex: 1 1 auto;
    }

    .service-pill {
        order: 2;
    }

    .primary-nav {
        width: 100%;
        padding-bottom: 9px;
        order: 3;
    }

    .primary-nav a {
        flex: 1;
    }

    .page-shell {
        width: calc(100% - 28px);
        padding-top: 24px;
    }

    .home-shell {
        padding-top: 30px;
    }

    .home-intro,
    .page-intro {
        align-items: flex-start;
        flex-direction: column;
    }

    .home-workflows,
    .demo-workspace {
        grid-template-columns: 1fr;
    }

    .home-workflow {
        min-height: 132px;
        grid-template-columns: 48px minmax(0, 1fr) auto;
    }

    .home-workflow:first-child {
        border-right: 0;
        border-bottom: 1px solid var(--line-strong);
    }

    .workflow-action {
        grid-column: auto;
    }

    .home-history-row {
        padding: 16px 0;
        grid-template-columns: minmax(0, 1fr) 170px;
        gap: 12px 18px;
    }

    .home-record-duration {
        grid-column: 1;
    }

    .home-record-thumb {
        width: min(150px, calc(82px * var(--thumb-ratio, 1.5)));
        height: min(82px, calc(150px / var(--thumb-ratio, 1.5)));
        grid-column: 2;
        grid-row: 1 / 3;
    }

    .demo-controls,
    .demo-output {
        min-height: auto;
    }

    .demo-controls {
        padding: 0 0 24px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .encoder-workspace .demo-controls,
    .decoder-workspace .demo-controls {
        display: grid;
        padding: 0 0 20px;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: end;
        gap: 14px;
    }

    .encoder-workspace .upload-box,
    .decoder-workspace .upload-box {
        min-height: 76px;
    }

    .encoder-workspace .button-row,
    .decoder-workspace .button-row {
        grid-column: 1 / -1;
    }

    .demo-output {
        padding: 0;
    }

    .encoder-workspace .demo-output,
    .decoder-workspace .demo-output {
        padding-top: 22px;
    }

    .decoder-result-layout {
        grid-template-columns: 1fr;
    }

    .decoder-result-layout.is-preview-only {
        grid-template-columns: 1fr;
    }

    .decoder-result-layout.is-preview-only::after {
        display: none;
    }

    .result-placeholder {
        border-left: 0;
        border-top: 1px solid var(--line-strong);
    }

    .watermark-result,
    .result-placeholder {
        min-height: 250px;
    }

    .history-run {
        grid-template-columns: 1fr;
        gap: 22px;
    }
}

@media (max-width: 560px) {
    body {
        font-size: 15px;
    }

    .brand-name {
        font-size: 20px;
    }

    .primary-nav a {
        padding: 0 8px;
        font-size: 14px;
    }

    .primary-nav a svg {
        display: none;
    }

    .home-intro h1,
    .page-intro h1 {
        font-size: 31px;
    }

    .home-intro p:last-child,
    .page-intro p:last-child {
        font-size: 16px;
    }

    .home-workflow {
        min-height: 0;
        padding: 20px 4px;
        grid-template-columns: 44px minmax(0, 1fr);
        gap: 14px;
    }

    .workflow-icon {
        width: 44px;
        height: 44px;
    }

    .workflow-copy strong {
        font-size: 27px;
    }

    .workflow-copy > span {
        font-size: 16px;
    }

    .workflow-action {
        grid-column: 2;
        font-size: 16px;
    }

    .home-history-heading {
        align-items: flex-start;
    }

    .home-history-heading h2 {
        font-size: 27px;
    }

    .home-history-row {
        grid-template-columns: 1fr;
    }

    .home-record-thumb,
    .home-record-duration {
        grid-column: 1;
        grid-row: auto;
    }

    .image-comparison {
        grid-template-columns: 1fr;
    }

    .encoder-workspace .demo-controls,
    .decoder-workspace .demo-controls {
        display: flex;
        align-items: stretch;
        gap: 14px;
    }

    .encoder-workspace .field-group,
    .encoder-workspace .button-row,
    .decoder-workspace .field-group,
    .decoder-workspace .button-row {
        width: 100%;
    }

    .comparison-arrow {
        height: 28px;
        transform: rotate(90deg);
    }

    .metric-strip {
        grid-template-columns: 1fr;
    }

    .metric-strip > div {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .metric-strip > div:last-child {
        border-bottom: 0;
    }

    .history-artifacts,
    .history-facts {
        grid-template-columns: 1fr;
    }

    .dialog-toolbar > span {
        display: none;
    }

    .dialog-toolbar {
        right: 12px;
        left: 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    #dialogDownload {
        width: 48px;
        padding: 0;
    }

    #dialogDownload span {
        display: none;
    }
}

/* Small visual adjustments for the compact evaluator layout. */
.page-title-row {
    display: flex;
    min-width: 0;
    align-items: baseline;
    gap: 12px;
}

.page-title-row .section-label {
    flex: 0 0 auto;
    margin-bottom: 8px;
}

.page-title-row h1 {
    min-width: 0;
    margin-bottom: 8px;
}

.encoder-workspace .field-group,
.decoder-workspace .field-group {
    width: min(560px, 100%);
    justify-self: center;
}

.encoder-workspace .image-frame,
.decoder-workspace .image-frame {
    position: relative;
    grid-template-rows: 44px minmax(0, 1fr);
}

.image-meta-overlay {
    position: absolute;
    top: 7px;
    right: 9px;
    z-index: 2;
    width: auto;
    max-width: calc(100% - 110px);
    min-height: 30px;
    padding: 0 9px;
    background: rgba(255, 255, 255, 0.92);
    border: 0;
    border-radius: 4px;
    font-size: 14px;
}

/* Decoder keeps the large-image + right-result composition and may scroll. */
.decoder-workspace .image-frame {
    grid-template-rows: 44px minmax(0, 1fr);
}

.decoder-workspace .decoder-result-layout,
.decoder-workspace .decoder-result-layout.is-preview-only {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    align-items: start;
}

.decoder-workspace .image-canvas {
    height: clamp(420px, 42vw, 620px);
}

.decoder-workspace .result-placeholder {
    display: flex;
    min-height: 300px;
}

.decoder-workspace .watermark-result,
.decoder-workspace .result-placeholder {
    align-self: start;
    min-height: clamp(300px, 30vw, 390px);
}

.decoder-workspace .watermark-result > strong {
    margin-top: 12px;
    margin-bottom: 18px;
}

@media (max-width: 560px) {
    .page-title-row {
        align-items: center;
        gap: 9px;
    }

    .page-title-row .section-label {
        margin-bottom: 0;
    }
}
