/*
 * Scanner UI stylesheet.
 * Sections follow the page flow: base, header, setup, camera, results, dialogs,
 * then responsive rules. Keep structural display/position rules in this file.
 */

:root {
    color-scheme: light;
    --ink: #172026;
    --muted: #68737d;
    --line: #d9dfe3;
    --surface: #ffffff;
    --canvas: #edf1f2;
    --primary: #087f5b;
    --primary-strong: #056247;
    --primary-soft: #e6f5ef;
    --amber: #a45b08;
    --amber-soft: #fff4df;
    --danger: #bf3b35;
    --danger-soft: #fff0ef;
    --charcoal: #1d252a;
    --shadow: 0 10px 30px rgba(23, 32, 38, 0.08);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--canvas);
    -webkit-text-size-adjust: 100%;
}

body {
    width: 100%;
    max-width: none;
    min-height: 100dvh;
    margin: 0;
    padding: 0 0 calc(24px + var(--safe-bottom));
    overflow-x: hidden;
    background: var(--canvas);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    letter-spacing: 0;
}

button,
input,
textarea {
    font: inherit;
    letter-spacing: 0;
}

button,
a,
label[for] {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(8, 127, 91, 0.22);
    outline-offset: 2px;
}

#offlineWarning {
    display: none;
    position: sticky;
    top: 0;
    z-index: 10000;
    width: 100%;
    padding: 11px 16px;
    border: 0;
    background: var(--danger);
    box-shadow: 0 4px 16px rgba(99, 30, 27, 0.2);
    color: #fff;
    font-size: 13px;
    line-height: 1.45;
    animation: none;
}

#topHeader {
    width: 100%;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.app-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(100%, 960px);
    min-height: 68px;
    margin: 0 auto;
    padding: 10px 20px;
}

.brand-button {
    display: flex;
    align-items: center;
    min-width: 0;
    padding: 4px;
    border: 0;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    text-align: left;
}

.brand-mark {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    margin-right: 11px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(23, 32, 38, 0.12);
}

.brand-copy {
    min-width: 0;
}

.brand-title {
    display: block;
    overflow: hidden;
    font-size: 17px;
    font-weight: 760;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-subtitle {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.2;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-link,
.header-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    font-size: 13px;
    font-weight: 650;
    text-decoration: none;
}

.header-link:active,
.header-icon-button:active {
    background: #f3f5f6;
}

.header-icon {
    margin-right: 6px;
    font-size: 16px;
    line-height: 1;
}

.scan-toolbar {
    width: min(100%, 960px);
    margin: 0 auto;
    padding: 0 20px 16px;
}

.mode-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    width: 100%;
    margin: 0 0 14px;
    padding: 4px;
    border-radius: 8px;
    background: #e7ebed;
}

.mode-btn {
    min-height: 44px;
    margin: 0;
    padding: 0 14px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
}

.mode-btn.active {
    background: var(--surface);
    color: var(--primary-strong);
    box-shadow: 0 2px 7px rgba(23, 32, 38, 0.1);
}

.setup-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 12px;
}

.field-group {
    position: relative;
    min-width: 0;
}

.field-label {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.remark-input {
    display: block;
    width: 100%;
    max-width: none;
    min-height: 46px;
    margin: 0;
    padding: 0 13px;
    border: 1px solid #cdd4d8;
    border-radius: 7px;
    background: var(--surface);
    color: var(--ink);
    font-size: 16px;
    text-align: left;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.remark-input::placeholder {
    color: #929ba2;
}

.remark-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(8, 127, 91, 0.11);
    outline: 0;
}

.suggestion-box {
    display: none;
    position: absolute;
    left: 0;
    z-index: 9999;
    width: 100%;
    overflow-y: auto;
    background: var(--surface);
    text-align: left;
    top: calc(100% + 6px);
    max-height: min(260px, 40vh);
    border: 1px solid var(--line);
    border-radius: 7px;
    box-shadow: var(--shadow);
}

.suggestion-item {
    min-height: 46px;
    padding: 12px 14px;
    color: var(--ink);
}

input[type="file"] {
    display: none;
}

.suggestion-item:hover,
.suggestion-item:active {
    background: var(--primary-soft);
    color: var(--primary-strong);
}

.scan-mode-container {
    position: static;
    display: flex;
    align-items: center;
    align-self: end;
    min-height: 46px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #f7f9f9;
    transform: none;
}

.switch-btn {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    margin: 0 8px 0 0;
}

.switch-btn input {
    width: 0;
    height: 0;
    opacity: 0;
}

.slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    border-radius: 24px;
    background: var(--primary);
    transition: background-color 180ms ease;
}

.slider::before {
    position: absolute;
    bottom: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    content: "";
    transition: transform 180ms ease;
}

input:checked + .slider {
    background: var(--amber);
}

input:checked + .slider::before {
    transform: translateX(18px);
}

.scan-mode-text {
    min-width: 42px;
    color: var(--ink) !important;
    font-size: 13px;
    white-space: nowrap;
}

.scanner-main {
    width: min(100%, 960px);
    margin: 0 auto;
    padding: 18px 20px 0;
}

.scan-stage {
    width: 100%;
}

.camera-box {
    position: relative;
    display: none;
    width: 100%;
    height: clamp(420px, 68dvh, 680px);
    max-height: none;
    margin: 0 0 18px;
    overflow: hidden;
    border-radius: 8px;
    background: #090d0f;
    box-shadow: var(--shadow);
}

#reader,
#reader video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

#reader > div:first-child {
    display: none !important;
}

.scan-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.16);
    box-shadow: inset 0 0 0 50vw rgba(0, 0, 0, 0.44);
}

.scan-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 6;
    width: min(72%, 420px);
    height: auto;
    aspect-ratio: 1;
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 7px;
    overflow: hidden;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 1px rgba(8, 127, 91, 0.45), 0 0 24px rgba(8, 127, 91, 0.2);
}

.camera-box.barcode-mode .scan-frame,
.camera-box.barcode-mode .cooldown-overlay {
    width: min(86%, 620px);
    height: 34%;
    aspect-ratio: auto;
}

.scan-frame::before,
.scan-frame::after {
    position: absolute;
    width: 28px;
    height: 28px;
    border-color: #4ee0a8;
    border-width: 4px;
    content: "";
}

.scan-frame::before {
    top: -2px;
    left: -2px;
    border-right: 0;
    border-bottom: 0;
}

.scan-frame::after {
    right: -2px;
    bottom: -2px;
    border-top: 0;
    border-left: 0;
}

.scan-line {
    position: absolute;
    top: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(to right, transparent, #4ee0a8 16%, #fff 50%, #4ee0a8 84%, transparent);
    box-shadow: 0 0 10px rgba(78, 224, 168, 0.85);
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0%, 100% { top: 0; }
    50% { top: 100%; }
}

.cam-mode-indicator {
    position: absolute;
    top: 16px;
    left: 50%;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 7px;
    background: rgba(17, 24, 28, 0.74);
    color: #fff !important;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transform: translateX(-50%);
    backdrop-filter: blur(10px);
}

.cam-mode-indicator:active {
    transform: translateX(-50%) scale(0.97);
}

.camera-controls {
    position: absolute;
    z-index: 10;
    display: flex;
    justify-content: center;
    width: 100%;
    bottom: calc(14px + var(--safe-bottom));
    gap: 10px;
    padding: 0 14px;
}

.camera-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 46px;
    margin: 0;
    padding: 0 16px;
    border-radius: 7px;
    background: rgba(20, 27, 31, 0.82);
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.camera-action-btn.is-danger {
    border-color: rgba(255, 255, 255, 0.24);
    background: rgba(191, 59, 53, 0.9);
}

.camera-action-btn.is-active {
    border-color: rgba(255, 255, 255, 0.46);
    background: rgba(164, 91, 8, 0.92);
}

#cloudBadge {
    position: absolute;
    z-index: 10;
    display: none;
    right: 14px;
    bottom: calc(72px + var(--safe-bottom));
    min-height: 32px;
    padding: 5px 9px;
    border-radius: 6px;
    background: rgba(8, 127, 91, 0.94);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.cooldown-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 8;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: min(72%, 420px);
    height: auto;
    aspect-ratio: 1;
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-weight: 700;
    text-align: center;
    transform: translate(-50%, -50%);
    backdrop-filter: blur(2px);
}

.cooldown-spinner {
    width: 40px;
    height: 40px;
    margin-top: 15px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #4ee0a8;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#flashBtn {
    display: none;
}

.signal-box {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 18px;
    margin-right: 8px;
}

.signal-bar {
    width: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.3);
    transition: background-color 180ms ease;
}

.signal-bar:nth-child(1) { height: 6px; }
.signal-bar:nth-child(2) { height: 9px; }
.signal-bar:nth-child(3) { height: 12px; }
.signal-bar:nth-child(4) { height: 15px; }
.signal-bar:nth-child(5) { height: 18px; }
.signal-level-1 .signal-bar:nth-child(1),
.signal-level-2 .signal-bar:nth-child(-n+2),
.signal-level-3 .signal-bar:nth-child(-n+3),
.signal-level-4 .signal-bar:nth-child(-n+4),
.signal-level-5 .signal-bar:nth-child(-n+5) {
    background: #fff;
    box-shadow: 0 0 4px #fff;
}

#startCameraWrapper,
.upload-box {
    margin: 0 0 18px;
    padding: 28px 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
}

.ready-symbol {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin: 0 auto 14px;
    border: 1px solid #b8d9cc;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-size: 26px;
}

.ready-title {
    margin: 0 0 5px;
    color: var(--ink);
    font-size: 18px;
    font-weight: 750;
}

.ready-status,
.upload-status {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 13px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    margin: 0;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: var(--primary);
    box-shadow: none;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover {
    filter: brightness(0.96);
}

.btn:active {
    transform: translateY(1px);
}

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

.btn-primary {
    background: var(--primary);
}

.btn-success {
    background: var(--primary-strong);
}

.btn-warning {
    background: var(--amber);
}

.btn-danger {
    background: var(--danger);
}

.btn-reset,
.btn-secondary {
    border-color: var(--line);
    background: #f5f7f7;
    color: #44505a;
}

.primary-action {
    width: min(100%, 360px);
    min-height: 50px;
    font-size: 16px;
}

.upload-actions {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    max-width: 620px;
    margin: 0 auto;
}

.upload-file-button,
.upload-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
}

.upload-reset {
    width: 48px;
    padding: 0;
}

#progressContainer {
    max-width: 620px;
    margin: 18px auto 0;
}

.progress-bar-bg {
    height: 8px;
    margin-bottom: 8px;
    border-radius: 4px;
    background: #dfe5e7;
    overflow: hidden;
}

#progressBar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
    transition: width 180ms ease;
}

#progressText {
    color: var(--muted);
}

.results-section {
    padding: 0 0 12px;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 2px 0 10px;
}

.results-title {
    margin: 0;
    font-size: 16px;
    font-weight: 760;
}

.results-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}

#statsInfo {
    min-height: 32px;
    margin: 0;
    padding: 7px 11px;
    border: 1px solid #c7e2d7 !important;
    border-radius: 6px;
    background: var(--primary-soft) !important;
    color: var(--primary-strong);
    font-size: 13px;
    line-height: 1.3;
    text-align: right;
}

.clear-panel-button {
    min-width: 64px;
    min-height: 40px;
    padding: 0 12px;
    border-color: #e7c6c3;
    background: var(--danger-soft);
    color: var(--danger);
    font-weight: 700;
}

.alert-panel {
    display: none;
    margin: 0 0 12px;
    padding: 13px 14px;
    border-radius: 7px;
    font-size: 13px;
    line-height: 1.55;
}

.alert-warning,
.alert-multi {
    border-color: #efd5aa;
    background: var(--amber-soft);
    color: #744309;
}

.alert-danger {
    border-color: #edc8c5;
    background: var(--danger-soft);
    color: #8b2d29;
}

#failedGallery,
#multiQRGallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

#failedGallery img,
#multiQRGallery img {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    border-radius: 6px;
    object-fit: cover;
    cursor: zoom-in;
}

#failedGallery img {
    border: 2px solid var(--danger);
}

#multiQRGallery img {
    border: 2px solid var(--amber);
}

.result-box {
    width: 100%;
    height: clamp(220px, 34dvh, 360px);
    min-height: 220px;
    margin: 0;
    padding: 14px;
    border: 1px solid #cbd3d7;
    border-radius: 7px;
    background: var(--surface);
    color: var(--ink);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 14px;
    line-height: 1.65;
    resize: vertical;
}

.result-box:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(8, 127, 91, 0.1);
    outline: none;
}

.result-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.result-actions .btn {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 0 10px;
    overflow-wrap: anywhere;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    overscroll-behavior: contain;
    padding: 28px 16px;
    background: rgba(12, 18, 21, 0.62);
    backdrop-filter: blur(3px);
}

html.modal-open,
body.modal-open {
    overflow: hidden;
    overscroll-behavior: none;
}

body.modal-open {
    position: fixed;
    right: 0;
    left: 0;
    width: 100%;
}

.modal-content {
    position: relative;
    width: min(100%, 680px);
    max-width: 680px;
    max-height: calc(100vh - 56px);
    max-height: calc(100dvh - 56px);
    margin: 0 auto;
    padding: 20px;
    overflow-y: auto;
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 22px 60px rgba(10, 16, 20, 0.25);
}

#historyModal .modal-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.modal-header-actions,
.modal-footer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.modal-close {
    width: 44px;
    min-width: 44px;
    padding: 0;
}

.filter-box {
    display: grid;
    grid-template-columns: auto minmax(150px, 1fr) auto;
    gap: 10px;
    padding: 12px;
    border-radius: 7px;
    background: #f4f6f7;
}

.date-picker {
    width: 100%;
    min-height: 42px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

#historyList {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 4px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

#historyList::-webkit-scrollbar {
    width: 8px;
}

#historyList::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 8px;
    background: #aab4b8;
    background-clip: padding-box;
}

.history-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.history-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.history-actions {
    display: flex;
    justify-content: flex-end;
    gap: 5px;
}

.history-name {
    color: var(--ink);
    font-size: 15px;
    font-weight: 750;
}

.history-meta {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.empty-state {
    margin: 0;
    padding: 42px 12px;
    color: var(--muted);
    text-align: center;
}

.history-actions .btn {
    min-height: 38px;
    padding: 0 11px;
    font-size: 12px;
}

.calc-textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 116px;
    padding: 12px;
    border-radius: 7px;
    font-size: 14px;
    line-height: 1.55;
    resize: vertical;
}

.calc-label {
    margin: 14px 0 7px;
    color: var(--ink) !important;
}

.calc-stats {
    border-radius: 7px;
    background: var(--primary-soft);
    color: var(--primary-strong);
}

.toast-msg {
    position: fixed;
    left: 50%;
    z-index: 9999;
    top: auto;
    bottom: calc(24px + var(--safe-bottom));
    width: max-content;
    max-width: calc(100vw - 32px);
    min-width: 0;
    padding: 11px 18px;
    overflow-wrap: anywhere;
    white-space: normal;
    border-radius: 7px;
    background: rgba(23, 32, 38, 0.94);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 0) scale(0.8);
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast-error {
    background: rgba(154, 42, 37, 0.96);
}

@media (max-width: 680px) {
    body.camera-active {
        height: 100dvh;
        padding: 0;
        overflow: hidden;
        background: var(--canvas);
    }

    body.camera-active .scanner-main {
        display: grid;
        grid-template-rows: minmax(0, 66fr) minmax(0, 34fr);
        height: 100dvh;
        padding: 0;
        overflow: hidden;
    }

    body.camera-active .scan-stage {
        min-height: 0;
    }

    body.camera-active .camera-box {
        width: 100%;
        height: 100%;
        min-height: 0;
        margin: 0;
    }

    body.camera-active .results-section {
        display: flex;
        flex-direction: column;
        min-height: 0;
        padding: 10px 12px calc(10px + var(--safe-bottom));
        overflow: hidden;
        border-top: 1px solid #cfd8da;
        background: var(--canvas);
    }

    body.camera-active .results-header {
        flex: 0 0 auto;
        margin: 0 0 8px;
    }

    body.camera-active .results-title {
        font-size: 15px;
    }

    body.camera-active #statsInfo {
        min-height: 36px;
        padding: 5px 8px;
        font-size: 11px;
    }

    body.camera-active .clear-panel-button {
        min-height: 36px;
    }

    body.camera-active .alert-panel,
    body.camera-active .result-actions {
        display: none !important;
    }

    body.camera-active .result-box {
        flex: 1 1 auto;
        height: auto;
        min-height: 0;
        padding: 10px 12px;
        font-size: 13px;
        line-height: 1.5;
        resize: none;
    }

    body.camera-active .toast-msg {
        bottom: calc(34dvh + 72px + var(--safe-bottom));
    }

    body {
        padding-bottom: calc(16px + var(--safe-bottom));
    }

    .app-bar {
        min-height: 62px;
        padding: 8px 12px;
    }

    .brand-mark {
        flex-basis: 36px;
        width: 36px;
        height: 36px;
        margin-right: 9px;
    }

    .brand-title {
        max-width: 148px;
        font-size: 15px;
    }

    .brand-subtitle {
        display: none;
    }

    .header-link,
    .header-icon-button {
        width: 42px;
        min-width: 42px;
        height: 42px;
        padding: 0;
    }

    .header-icon {
        margin: 0;
    }

    .header-action-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }

    .scan-toolbar {
        padding: 0 12px 13px;
    }

    .mode-switch {
        margin-bottom: 12px;
    }

    .setup-row {
        grid-template-columns: minmax(0, 1fr) 104px;
        gap: 8px;
    }

    .scan-mode-container {
        justify-content: center;
        padding: 0 8px;
    }

    .switch-btn {
        margin-right: 6px;
    }

    .scanner-main {
        padding: 12px 12px 0;
    }

    .camera-box {
        width: calc(100% + 24px);
        height: calc(100dvh - var(--safe-bottom));
        min-height: 500px;
        margin: -12px -12px 12px;
        border-radius: 0;
        box-shadow: none;
    }

    #startCameraWrapper,
    .upload-box {
        padding: 24px 16px;
    }

    .upload-actions {
        grid-template-columns: 1fr 1fr 48px;
        gap: 8px;
    }

    .upload-actions .btn,
    .upload-file-button {
        padding: 0 9px;
        font-size: 13px;
    }

    .results-header {
        align-items: center;
        gap: 8px;
    }

    .results-header-actions {
        gap: 6px;
    }

    #statsInfo {
        max-width: none;
        padding: 6px 9px;
        font-size: 12px;
    }

    .result-box {
        height: clamp(150px, 20dvh, 180px);
        min-height: 150px;
        resize: none;
    }

    .result-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .result-actions .btn {
        min-height: 44px;
        padding: 0 5px;
        font-size: 12px;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal-content {
        width: 100%;
        max-height: 92dvh;
        margin: 8dvh 0 0;
        padding: 18px 14px calc(16px + var(--safe-bottom));
        overflow-y: auto;
        border-radius: 8px 8px 0 0;
    }

    #historyModal .modal-content {
        height: 92vh;
        height: 92dvh;
        overflow: hidden;
    }

    .filter-box {
        grid-template-columns: 1fr auto;
    }

    .filter-label {
        grid-column: 1 / -1;
    }

    .modal-footer-actions .btn {
        flex: 1 1 calc(50% - 4px);
    }
}

@media (max-width: 370px) {
    .brand-title {
        max-width: 116px;
    }

    .setup-row {
        grid-template-columns: 1fr;
    }

    .scan-mode-container {
        justify-content: flex-start;
    }

    .mode-btn {
        padding: 0 7px;
        font-size: 13px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
