/* ==========================================================================
   CUEVANCE MountCalc - Master Stylesheet (Unified Viewport Architecture)
   Zero-Scroll, Zero-Jitter, Eye-Level Unified Blueprint Input
   ========================================================================== */

:root {
    --font-heading: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
    
    /* ⚡️ CUEVANCE Standard Cyber-Neon (Dark Spatial Liquid) */
    --bg-dark: #080c1a;
    --bg-page-gradient: radial-gradient(ellipse at 20% 0%, rgba(56, 189, 248, 0.10) 0%, transparent 50%),
                        radial-gradient(ellipse at 80% 10%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
                        radial-gradient(ellipse at 50% 90%, rgba(52, 211, 153, 0.06) 0%, transparent 50%);
    --bg-header: rgba(15, 23, 42, 0.78);
    --bg-canvas: #060a16;
    --bg-deck: rgba(10, 16, 32, 0.90);
    --bg-card-border: rgba(255, 255, 255, 0.15);
    --bg-chip: rgba(255, 255, 255, 0.08);
    --bg-btn-k: rgba(255, 255, 255, 0.08);
    --bg-status-bar: rgba(0, 0, 0, 0.35);

    --accent-cyan: #38bdf8;
    --accent-cyan-glow: rgba(56, 189, 248, 0.25);
    --accent-on-cyan: #020617;
    --accent-emerald: #34d399;
    --accent-emerald-glow: rgba(52, 211, 153, 0.25);
    --accent-on-emerald: #020617;
    --accent-purple: #a78bfa;
    --accent-amber: #fbbf24;
    --accent-rose: #fb7185;

    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.85);
    --text-muted: rgba(255, 255, 255, 0.60);

    --btn-primary-bg: linear-gradient(135deg, #38bdf8, #818cf8);
    --btn-primary-text: #020617;
    --card-shadow: inset 0 1px 1px 0 rgba(255, 255, 255, 0.35),
                   0 4px 16px -2px rgba(0, 0, 0, 0.40),
                   0 16px 32px -8px rgba(0, 0, 0, 0.30);

    color-scheme: dark;
}

/* CUEVANCE Standard Warm Studio (Light Organic Liquid UI) */
html[data-theme="warm-studio"],
html[data-theme="studio"],
html.theme-warm-studio,
html.theme-studio,
body.theme-warm-studio,
body.theme-studio {
    --bg-dark: #e8e2d5;
    --bg-page-gradient: radial-gradient(ellipse at 15% 10%, rgba(13, 148, 136, 0.12) 0%, transparent 45%),
                        radial-gradient(ellipse at 85% 15%, rgba(217, 119, 6, 0.10) 0%, transparent 45%),
                        radial-gradient(ellipse at 50% 85%, rgba(16, 185, 129, 0.08) 0%, transparent 50%),
                        radial-gradient(ellipse at 80% 80%, rgba(99, 102, 241, 0.06) 0%, transparent 45%);
    --bg-header: rgba(255, 255, 255, 0.90);
    --bg-canvas: #dfd9cb;
    --bg-deck: #ded8cb;
    --bg-card-border: rgba(15, 23, 42, 0.18);
    --bg-chip: rgba(255, 255, 255, 0.85);
    --bg-btn-k: #ffffff;
    --bg-status-bar: rgba(255, 255, 255, 0.92);

    --accent-cyan: #0d9488;
    --accent-cyan-glow: rgba(13, 148, 136, 0.20);
    --accent-on-cyan: #ffffff;
    --accent-emerald: #047857;
    --accent-emerald-glow: rgba(4, 120, 87, 0.20);
    --accent-on-emerald: #ffffff;
    --accent-purple: #7c3aed;
    --accent-amber: #b45309;
    --accent-rose: #be123c;

    --text-primary: #0f172a;
    --text-secondary: #1e293b;
    --text-muted: #334155;

    --btn-primary-bg: linear-gradient(135deg, #0d9488, #0f766e);
    --btn-primary-text: #ffffff;
    --card-shadow: inset 0 1.5px 2px 0 rgba(255, 255, 255, 0.95),
                   0 4px 16px -2px rgba(45, 42, 38, 0.07),
                   0 12px 32px -6px rgba(45, 42, 38, 0.10);

    color-scheme: light;
}

/* ☀️ Outdoor Super High-Contrast Mode (Sunlight AAA: Pure Black x Safety Yellow) */
html[data-theme="sunlight-aaa"],
html[data-theme="sunlight-aaa"] body,
html[data-contrast="high"],
html[data-contrast="high"] body {
    --bg-dark: #000000 !important;
    --bg-page-gradient: none !important;
    --bg-header: #000000 !important;
    --bg-canvas: #000000 !important;
    --bg-deck: #000000 !important;
    --bg-card-border: #ffffff !important;
    --bg-chip: #1a1a1a !important;
    --bg-btn-k: #111111 !important;
    --bg-status-bar: #000000 !important;

    --text-primary: #ffffff !important;
    --text-secondary: #ffffff !important;
    --text-muted: #e2e8f0 !important;
    --accent-cyan: #ffff00 !important;
    --accent-cyan-glow: rgba(255, 255, 0, 0.4) !important;
    --accent-on-cyan: #000000 !important;
    --accent-emerald: #00ff66 !important;
    --accent-emerald-glow: rgba(0, 255, 102, 0.4) !important;
    --accent-on-emerald: #000000 !important;
    --accent-amber: #ffff00 !important;
    --accent-rose: #ff3366 !important;

    --btn-primary-bg: #ffff00 !important;
    --btn-primary-text: #000000 !important;
    --card-shadow: none !important;

    color-scheme: dark;
}

/* Reset & Viewport Lock (No scroll, no jump) */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100dvh;
    overflow: hidden;
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    height: 44px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--bg-card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.75rem;
    flex-shrink: 0;
    z-index: 20;
}

.brand-area {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.brand-logo {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    display: block;
    flex-shrink: 0;
}

.brand-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.brand-sub {
    font-family: var(--font-heading);
    font-size: 0.72rem;
    font-weight: 900;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 5px;
    letter-spacing: 0.06em;
}

/* Header Preset Dropdown */
.preset-dropdown-wrap {
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 240px;
    margin: 0 8px;
}

@media (max-width: 480px) {
    .brand-title {
        font-size: 0.82rem;
    }
    .preset-dropdown-wrap {
        max-width: none;
        margin: 0 6px;
    }
}

.preset-dropdown {
    width: 100%;
    height: 32px;
    padding: 0 8px;
    background: var(--bg-chip);
    border: 1px solid var(--bg-card-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
    appearance: auto;
}

.preset-dropdown:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 2px var(--accent-cyan-glow);
}

.preset-dropdown option {
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

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

.btn-icon-mini {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid var(--bg-card-border);
    background: var(--bg-chip);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    user-select: none;
    touch-action: manipulation;
}

.btn-icon-mini:active {
    background: rgba(255, 255, 255, 0.2);
}

.btn-icon-mini.desktop-only {
    display: none;
}

@media (min-width: 769px) {
    .btn-icon-mini.desktop-only {
        display: flex;
    }
}

/* Hamburger Menu Button */
.btn-hamburger {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-chip);
    border: 1px solid var(--bg-card-border);
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    user-select: none;
    touch-action: manipulation;
}

.btn-hamburger:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.15);
}

.hamburger-box {
    width: 18px;
    height: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}

.hamburger-inner,
.hamburger-box::before,
.hamburger-box::after {
    content: '';
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text-primary);
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Main Viewport */
.app-main-viewport {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

@media (min-width: 1024px) {
    .app-main-viewport {
        flex-direction: row;
    }
}

/* Blueprint CAD Canvas Box */
.cad-canvas-box {
    flex: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-canvas);
    padding: 2px 4px;
    overflow: hidden;
    position: relative;
}

.svg-cad-element {
    width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    user-select: none;
}

.app-main-viewport.deck-collapsed .input-deck {
    display: none !important;
}

.app-main-viewport.deck-collapsed .cad-canvas-box {
    height: 100%;
    flex: 1;
    padding: 6px;
}

/* Blueprint CAD Canvas Box (Tap to Fullscreen) */
.cad-canvas-box {
    cursor: pointer;
}

/* Fullscreen Mode for Preview Canvas */
.cad-canvas-box.is-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    z-index: 9999 !important;
    background: var(--bg-canvas) !important;
    padding: max(12px, env(safe-area-inset-top, 12px)) max(12px, env(safe-area-inset-right, 12px)) max(12px, env(safe-area-inset-bottom, 12px)) max(12px, env(safe-area-inset-left, 12px)) !important;
}

/* Fullscreen Exit Floating Button */
.btn-fullscreen-close {
    display: none !important;
    position: absolute;
    top: max(12px, env(safe-area-inset-top, 12px));
    right: max(12px, env(safe-area-inset-right, 12px));
    z-index: 30;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 14px;
    background: rgba(15, 23, 42, 0.90);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1.5px solid var(--accent-cyan);
    border-radius: 8px;
    color: var(--accent-cyan);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s, background 0.15s, color 0.15s;
    user-select: none;
    touch-action: manipulation;
}

.cad-canvas-box.is-fullscreen .btn-fullscreen-close {
    display: inline-flex !important;
}

.btn-fullscreen-close:active {
    transform: scale(0.95);
    background: var(--accent-cyan);
    color: var(--accent-on-cyan);
}

/* Sunlight AAA Mode overrides */
html[data-theme="sunlight-aaa"] .cad-canvas-box.is-fullscreen .btn-fullscreen-close {
    background: #000000 !important;
    border: 1.5px solid #ffff00 !important;
    color: #ffff00 !important;
    box-shadow: none !important;
}

/* Warm Studio Mode overrides */
html[data-theme="warm-studio"] .cad-canvas-box.is-fullscreen .btn-fullscreen-close,
html[data-theme="studio"] .cad-canvas-box.is-fullscreen .btn-fullscreen-close {
    background: rgba(255, 255, 255, 0.95);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}


/* SVG Interactive Dim Badges */
.dim-badge {
    transition: filter 0.15s ease;
    cursor: pointer;
    pointer-events: all;
}

.dim-badge:hover {
    filter: brightness(1.2);
}

.dim-badge.active rect:nth-of-type(2) {
    stroke: var(--accent-cyan) !important;
    stroke-width: 3.5 !important;
    filter: drop-shadow(0 0 8px var(--accent-cyan-glow));
}

/* Unified Bottom Input Deck */
.input-deck {
    background: var(--bg-deck);
    border-top: 1px solid var(--bg-card-border);
    padding: 0.5rem 0.65rem 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    flex-shrink: 0;
}

@media (min-width: 1024px) {
    .input-deck {
        width: 380px;
        border-top: none;
        border-left: 1px solid var(--bg-card-border);
        justify-content: center;
        padding: 1.5rem;
        gap: 1rem;
    }
}

/* Editor Status Row */
.editor-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-status-bar);
    border: 1px solid var(--bg-card-border);
    border-radius: 8px;
    padding: 0.35rem 0.6rem;
    gap: 0.5rem;
}

.editor-info-left {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-cyan);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.editor-value-box {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: baseline;
    gap: 2px;
}

.editor-unit {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stepper-quick-group {
    display: flex;
    gap: 4px;
}

.btn-step {
    padding: 6px 10px;
    min-height: 36px;
    background: var(--bg-btn-k);
    border: 1px solid var(--bg-card-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    user-select: none;
    touch-action: manipulation;
}

.btn-step:active {
    background: var(--accent-cyan);
    color: var(--accent-on-cyan);
    transform: scale(0.95);
}

/* Compact Keypad Grid - Field Ergonomics (WCAG 2.2 / AAA touch target 48px+) */
.compact-keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.btn-k {
    height: 48px;
    background: var(--bg-btn-k);
    border: 1px solid var(--bg-card-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.08s, transform 0.08s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    user-select: none;
    touch-action: manipulation;
}

@media (min-width: 1024px) {
    .btn-k {
        height: 54px;
        font-size: 1.35rem;
    }
}

.btn-k:active {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(0.95);
}

.btn-k.k-action {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    font-size: 0.88rem;
    font-weight: 800;
}

.btn-k.k-clear {
    color: var(--accent-rose);
}

.btn-k.k-sign {
    font-size: 1.3rem;
    color: var(--accent-amber);
    font-weight: 800;
}

.btn-k.k-ok {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    font-size: 0.98rem;
    font-weight: 800;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    padding: 1rem;
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 100%;
    max-width: 440px;
    background: var(--bg-dark);
    border: 1px solid var(--bg-card-border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1rem;
    font-weight: 700;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
}

.modal-select {
    width: 100%;
    padding: 0.65rem;
    border-radius: 6px;
    background: var(--bg-header);
    color: var(--text-primary);
    border: 1px solid var(--bg-card-border);
    font-size: 13px;
}

.btn-primary-block {
    width: 100%;
    height: 40px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
}

/* ==========================================================================
   Slide-in Drawer Hamburger Menu
   ========================================================================== */
.drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.drawer-backdrop.open {
    display: flex !important;
    opacity: 1;
    pointer-events: auto;
}

.drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 86%;
    max-width: 340px;
    background: var(--bg-dark);
    border-left: 1px solid var(--bg-card-border);
    box-shadow: -6px 0 28px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    padding-bottom: env(safe-area-inset-bottom, 1rem);
}

.drawer-backdrop.open .drawer-panel {
    transform: translateX(0);
}

.drawer-header {
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    border-bottom: 1px solid var(--bg-card-border);
    background: var(--bg-header);
    flex-shrink: 0;
}

.drawer-title-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.drawer-logo {
    display: block;
    border-radius: 4px;
}

.drawer-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.drawer-close-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
    border-radius: 6px;
    touch-action: manipulation;
}

.drawer-close-btn:active {
    color: var(--text-primary);
    background: var(--bg-chip);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.85rem 0.65rem;
}

.drawer-menu-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.drawer-item-btn {
    width: 100%;
    min-height: 56px;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 0.9rem;
    background: var(--bg-chip);
    border: 1px solid var(--bg-card-border);
    border-radius: 10px;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.08s;
    user-select: none;
    touch-action: manipulation;
}

.drawer-item-btn:active {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-cyan);
    transform: scale(0.98);
}

.drawer-item-icon {
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
}

.drawer-item-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.drawer-item-label {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
}

.drawer-item-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Theme overrides for Drawer */
html[data-theme="sunlight-aaa"] .drawer-panel {
    background: #000000 !important;
    border-color: #ffffff !important;
}
html[data-theme="sunlight-aaa"] .drawer-header {
    background: #000000 !important;
    border-color: #ffffff !important;
}
html[data-theme="sunlight-aaa"] .drawer-item-btn {
    background: #111111 !important;
    border-color: #ffffff !important;
    color: #ffffff !important;
}
html[data-theme="sunlight-aaa"] .drawer-item-label {
    color: #ffff00 !important;
}
html[data-theme="sunlight-aaa"] .drawer-item-sub {
    color: #ffffff !important;
}
html[data-theme="sunlight-aaa"] .btn-hamburger {
    background: #111111 !important;
    border-color: #ffffff !important;
}
html[data-theme="sunlight-aaa"] .hamburger-inner,
html[data-theme="sunlight-aaa"] .hamburger-box::before,
html[data-theme="sunlight-aaa"] .hamburger-box::after {
    background-color: #ffff00 !important;
}

html[data-theme="warm-studio"] .drawer-panel,
html[data-theme="studio"] .drawer-panel {
    background: #ded8cb !important;
    border-color: rgba(15, 23, 42, 0.18) !important;
}
html[data-theme="warm-studio"] .drawer-header,
html[data-theme="studio"] .drawer-header {
    background: #ffffff !important;
}
html[data-theme="warm-studio"] .drawer-item-btn,
html[data-theme="studio"] .drawer-item-btn {
    background: #ffffff !important;
    border-color: rgba(15, 23, 42, 0.15) !important;
}


/* ==========================================================================
   Hero HUD (Head-Up Display) - 現場最重要寸法バー (★基準ビス穴 FL+ 専用スリムバー)
   ========================================================================== */
.hero-hud-bar {
    width: 100%;
    height: 38px;
    background: var(--bg-header);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--bg-card-border);
    padding: 0 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    z-index: 10;
}

.hud-item.hud-primary {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: center;
    gap: 0.6rem;
}

.hud-label {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--accent-emerald);
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.hud-value-row {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.hud-prefix {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
}

.hud-value-strong {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 800;
    color: var(--accent-emerald);
    line-height: 1;
}

.hud-unit {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
}

/* Mobile HUD & Viewport Optimization (max-width: 640px) */
@media (max-width: 640px) {
    .app-header {
        height: 36px;
        padding: 0 0.5rem;
    }
    .brand-title {
        font-size: 0.8rem;
    }
    .preset-dropdown-wrap {
        max-width: 130px;
        margin: 0 3px;
    }
    .preset-dropdown {
        height: 25px;
        font-size: 0.72rem;
        padding: 0 4px;
    }
    .btn-icon-mini {
        width: 28px;
        height: 28px;
        font-size: 0.78rem;
    }

    /* Ultra-Slim Single-Row HUD Bar for Mobile (★基準ビスのみ) */
    .hero-hud-bar {
        height: 32px;
        padding: 0 0.5rem;
        flex-direction: row;
        align-items: center;
        justify-content: center;
    }
    .hud-item.hud-primary {
        gap: 0.4rem;
        min-width: 0;
    }
    .hud-label {
        font-size: 10px;
    }
    .hud-value-strong {
        font-size: 18px;
    }
    .hud-prefix {
        font-size: 11px;
    }
    .hud-unit {
        font-size: 10px;
    }

    /* Compact Bottom Deck on Mobile: minimize vertical length, maximize canvas */
    .input-deck {
        padding: 0.2rem 0.35rem 0.3rem;
        gap: 0.2rem;
    }
    .editor-status-bar {
        padding: 0.15rem 0.35rem;
    }
    .editor-info-left {
        font-size: 0.72rem;
    }
    .editor-value-box {
        font-size: 1.05rem;
    }
    .btn-step {
        height: 22px;
        padding: 0 4px;
        font-size: 0.65rem;
    }
    .compact-keypad {
        gap: 2.5px;
    }
    .btn-k {
        height: 35px;
        font-size: 1.15rem;
        border-radius: 5px;
    }
}

/* ==========================================================================
   Real-time Safety Clearance Alert Banner
   ========================================================================== */
.safety-alert-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    font-size: 12px;
    font-weight: 700;
    animation: alertSlideDown 0.25s ease-out;
    flex-shrink: 0;
    z-index: 12;
}

@keyframes alertSlideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.safety-alert-banner.critical {
    background: #991b1b;
    color: #ffffff;
    border-bottom: 2px solid #ef4444;
}

.safety-alert-banner.warning {
    background: #92400e;
    color: #ffffff;
    border-bottom: 2px solid #f59e0b;
}

/* QR Code Modal Box */
.qr-code-box {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    background: #ffffff;
    border-radius: 8px;
    margin: 0.5rem 0;
}

.qr-code-box svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* ==========================================================================
   Print Only: A4 Landscape Construction Spec Sheet
   ========================================================================== */
.print-sheet-root {
    display: none;
}

@media print {
    @page {
        size: A4 landscape;
        margin: 6mm 8mm;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        box-shadow: none !important;
    }

    html, body {
        background: #ffffff !important;
        color: #0f172a !important;
        height: auto !important;
        overflow: visible !important;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans JP", sans-serif !important;
    }

    .no-print, header.app-header, .input-deck, .modal-backdrop, .safety-alert-banner, .hero-hud-bar, .app-main-viewport {
        display: none !important;
    }

    .print-sheet-root {
        display: flex !important;
        flex-direction: column;
        width: 100%;
        height: 100%;
        color: #0f172a;
    }

    .print-header-block {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        border-bottom: 2px solid #0f172a;
        padding-bottom: 6px;
        margin-bottom: 8px;
    }

    .print-main-title {
        font-size: 16pt;
        font-weight: 900;
        margin: 0;
        color: #0f172a;
    }

    .print-sub-desc {
        font-size: 8pt;
        color: #475569;
        margin: 2px 0 0 0;
    }

    .print-meta-grid {
        display: flex;
        align-items: center;
        gap: 12px;
        font-size: 8.5pt;
    }

    .print-stamp-box {
        display: flex;
        border: 1px solid #0f172a;
    }

    .stamp-cell {
        width: 48px;
        height: 48px;
        border-right: 1px solid #0f172a;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        padding: 2px;
    }
    .stamp-cell:last-child {
        border-right: none;
    }
    .stamp-cell span {
        font-size: 7pt;
        color: #475569;
    }

    .print-body-layout {
        display: grid;
        grid-template-columns: 1.55fr 1fr;
        gap: 12px;
        flex: 1;
    }

    .print-cad-column {
        border: 1px solid #cbd5e1;
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 4px;
        background: #ffffff;
    }

    .print-cad-column svg {
        width: 100%;
        height: auto;
        max-height: 160mm;
    }

    .print-info-column {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .print-card {
        border: 1px solid #cbd5e1;
        border-radius: 4px;
        padding: 6px 8px;
    }

    .print-card-title {
        font-size: 9pt;
        font-weight: 800;
        margin: 0 0 4px 0;
        border-bottom: 1px solid #e2e8f0;
        padding-bottom: 3px;
        color: #0f172a;
    }

    .print-dim-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 8.5pt;
    }

    .print-dim-table td {
        padding: 3px 4px;
        border-bottom: 1px solid #f1f5f9;
    }

    .print-dim-table tr.highlight-row {
        background: #ecfdf5;
        font-weight: 700;
    }
    .print-dim-table tr.highlight-row td {
        color: #047857;
        font-size: 9.5pt;
    }

    .dim-col-fl b {
        font-family: var(--font-mono);
        font-size: 10.5pt;
    }

    .dim-col-koshi {
        font-family: var(--font-mono);
        color: #b45309;
        font-weight: 700;
    }

    .print-spec-list {
        font-size: 8pt;
        display: flex;
        flex-direction: column;
        gap: 3px;
    }

    .print-spec-row {
        display: flex;
        justify-content: space-between;
    }

    .print-checklist {
        list-style: none;
        padding: 0;
        margin: 0;
        font-size: 7.5pt;
    }

    .print-checklist li {
        margin-bottom: 3px;
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .print-qr-card {
        border: 1px solid #cbd5e1;
        border-radius: 4px;
        padding: 6px;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .print-qr-box {
        width: 58px;
        height: 58px;
        flex-shrink: 0;
    }
    .print-qr-box svg {
        width: 100%;
        height: 100%;
    }

    .print-qr-text {
        display: flex;
        flex-direction: column;
        font-size: 8pt;
        font-weight: 700;
    }
    .print-qr-text small {
        font-size: 6.5pt;
        font-weight: normal;
        color: #64748b;
    }
}
