/* ==========================================================================
   Unified Smart Driving License Print Check - Clean Civic Design System
   ========================================================================== */

:root {
    --font-primary: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    
    /* Light Civic Color Palette (Default) */
    --bg-page: #f8fafc;
    --bg-surface: #ffffff;
    --bg-subtle: #f1f5f9;
    --border-color: #e2e8f0;
    --border-strong: #cbd5e1;
    
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-subtle: #64748b;
    
    --brand-primary: #1e40af;
    --brand-hover: #1e3a8a;
    
    --status-success-bg: #ecfdf5;
    --status-success-text: #047857;
    --status-success-border: #a7f3d0;
    
    --status-warning-bg: #fffbeb;
    --status-warning-text: #b45309;
    --status-warning-border: #fde68a;
    
    --status-info-bg: #f0f9ff;
    --status-info-text: #0369a1;
    --status-info-border: #bae6fd;
    
    --status-danger-bg: #fef2f2;
    --status-danger-text: #b91c1c;
    --status-danger-border: #fecaca;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* Dark Theme Overrides */
body.dark-theme {
    --bg-page: #0f172a;
    --bg-surface: #1e293b;
    --bg-subtle: #334155;
    --border-color: #334155;
    --border-strong: #475569;
    
    --text-main: #f8fafc;
    --text-muted: #cbd5e1;
    --text-subtle: #94a3b8;
    
    --brand-primary: #3b82f6;
    --brand-hover: #60a5fa;
    
    --status-success-bg: rgba(16, 185, 129, 0.15);
    --status-success-text: #34d399;
    --status-success-border: rgba(52, 211, 153, 0.3);
    
    --status-warning-bg: rgba(245, 158, 11, 0.15);
    --status-warning-text: #fbbf24;
    --status-warning-border: rgba(251, 191, 36, 0.3);
    
    --status-info-bg: rgba(56, 189, 248, 0.15);
    --status-info-text: #38bdf8;
    --status-info-border: rgba(56, 189, 248, 0.3);
    
    --status-danger-bg: rgba(239, 68, 68, 0.15);
    --status-danger-text: #f87171;
    --status-danger-border: rgba(248, 113, 113, 0.3);
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
}

/* Reset & Global */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Prevent horizontal overflow on all screen sizes */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-page);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Container */
.container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* Header Navbar */
.navbar {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
}

.nav-container {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: var(--text-main);
    min-width: 0;
}

.brand-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--radius-sm);
    background-color: var(--brand-primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.brand-name {
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.65rem 1.2rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--brand-primary);
    color: #ffffff;
}

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

.btn-secondary {
    background-color: var(--bg-surface);
    color: var(--text-main);
    border-color: var(--border-strong);
}

.btn-secondary:hover {
    background-color: var(--bg-subtle);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.83rem;
}

.btn-outline-sm {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-main);
    padding: 0.4rem 0.65rem;
    font-size: 0.82rem;
    min-height: 36px;
    white-space: nowrap;
}

.btn-outline-sm:hover {
    background-color: var(--bg-subtle);
}

.btn-back-main span {
    display: none;
}

.btn-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-surface);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.btn-icon:hover {
    background-color: var(--bg-subtle);
}

body.dark-theme .light-icon { display: block; }
body.dark-theme .dark-icon { display: none; }
body.light-theme .light-icon { display: none; }
body.light-theme .dark-icon { display: block; }

/* Main Layout */
.main-content {
    padding-top: 2rem;
    padding-bottom: 4rem;
    flex: 1;
}

/* Hero & Search Form */
.hero-section {
    text-align: center;
    max-width: 680px;
    margin: 0 auto 2rem auto;
}

.hero-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}

.hero-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-subtle);
}

.search-input {
    width: 100%;
    padding: 0.85rem 2.5rem 0.85rem 2.5rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    outline: none;
    /* Prevent iOS zoom-in on focus (font-size must be >= 16px equivalent) */
    -webkit-appearance: none;
    appearance: none;
}

.search-input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.15);
}

.search-input.input-error {
    border-color: var(--status-danger-text) !important;
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.15) !important;
}

.validation-error-msg {
    background-color: var(--status-danger-bg);
    border: 1px solid var(--status-danger-border);
    color: var(--status-danger-text);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.clear-btn {
    position: absolute;
    right: 0.85rem;
    background: none;
    border: none;
    color: var(--text-subtle);
    cursor: pointer;
    font-size: 1rem;
}

.format-hint {
    font-size: 0.83rem;
    color: var(--text-subtle);
    margin-bottom: 0.85rem;
}

.format-hint code {
    font-family: monospace;
    font-weight: 700;
    color: var(--brand-primary);
}

/* Compact Visible Feedback Bar */
.compact-feedback-bar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.45rem 1rem;
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.compact-feedback-links {
    display: inline-flex;
    gap: 0.65rem;
}

.compact-link {
    color: var(--brand-primary);
    font-weight: 600;
    text-decoration: none;
}

.compact-link:hover {
    text-decoration: underline;
}

/* Results & Summary Banners */
.results-section {
    margin-top: 1.5rem;
}

.summary-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.summary-card.hero-case-warning {
    border-left: 5px solid var(--status-warning-text);
    background-color: var(--status-warning-bg);
}

/* GREEN THEME FOR COLLECTED STATUS */
.summary-card.hero-case-collected {
    border-left: 5px solid var(--status-success-text);
    background-color: var(--status-success-bg);
}

.summary-card.hero-case-direct {
    border-left: 5px solid var(--status-success-text);
    background-color: var(--status-success-bg);
}

.summary-card.hero-case-notfound {
    border-left: 5px solid var(--status-danger-text);
    background-color: var(--status-danger-bg);
}

.hero-card-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.hero-status-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--bg-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.hero-case-warning .hero-status-avatar { color: var(--status-warning-text); }
.hero-case-collected .hero-status-avatar { color: var(--status-success-text); }
.hero-case-direct .hero-status-avatar { color: var(--status-success-text); }
.hero-case-notfound .hero-status-avatar { color: var(--status-danger-text); }

.hero-greeting-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.hero-greeting-sub {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Box Code Banner (Matching Official Screenshot Style) */
.hero-box-code-container {
    margin-top: 1.25rem;
    background-color: var(--status-info-bg);
    border: 1.5px solid var(--status-info-border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1.25rem;
    text-align: center;
}

.hero-box-code-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--status-info-text);
    margin-bottom: 0.15rem;
}

.hero-box-code-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--brand-primary);
    letter-spacing: 0.05em;
    font-family: monospace;
}

.hero-instruction-box {
    margin-top: 1rem;
    padding: 0.9rem 1.1rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    color: var(--text-main);
    line-height: 1.5;
}

.hero-action-row {
    margin-top: 1rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.hero-action-row .btn {
    flex: 1 1 auto;
    min-width: 120px;
    text-align: center;
    justify-content: center;
}

/* Action Bar */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.results-meta {
    font-size: 0.88rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Office Cards Grid */
.office-grid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.office-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.office-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-color);
}

.office-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.office-sub {
    font-size: 0.8rem;
    color: var(--text-subtle);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-badge.success {
    background-color: var(--status-success-bg);
    color: var(--status-success-text);
    border: 1px solid var(--status-success-border);
}

.status-badge.pending {
    background-color: var(--status-warning-bg);
    color: var(--status-warning-text);
    border: 1px solid var(--status-warning-border);
}

.status-badge.info {
    background-color: var(--status-info-bg);
    color: var(--status-info-text);
    border: 1px solid var(--status-info-border);
}

.status-badge.danger {
    background-color: var(--status-danger-bg);
    color: var(--status-danger-text);
    border: 1px solid var(--status-danger-border);
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--text-subtle);
    font-weight: 600;
}

.detail-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.detail-value.highlight {
    color: var(--brand-primary);
    font-size: 1.05rem;
}

.office-instruction-banner {
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-color);
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.86rem;
    color: var(--text-main);
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.office-footer-info {
    padding-top: 0.85rem;
    border-top: 1px dashed var(--border-color);
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.office-links-group {
    display: flex;
    gap: 0.75rem;
}

.office-link {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 600;
}

.office-link:hover { text-decoration: underline; }

/* Collapsible Accordion for Checked Offices */
.checked-offices-accordion {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    margin-top: 1.25rem;
}

.checked-offices-accordion summary {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-muted);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.checked-offices-accordion summary::-webkit-details-marker { display: none; }
.checked-offices-accordion summary::after { content: "▼"; font-size: 0.75rem; color: var(--text-subtle); }
.checked-offices-accordion[open] summary::after { transform: rotate(180deg); }

.checked-offices-list {
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.checked-office-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    background-color: var(--bg-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.86rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.checked-office-title {
    font-weight: 600;
    color: var(--text-main);
}

.checked-office-links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.portal-text-link {
    color: var(--brand-primary);
    font-weight: 600;
    text-decoration: none;
    font-size: 0.82rem;
}

.portal-text-link:hover { text-decoration: underline; }

/* TMO Directory Grid */
.tmo-directory-section {
    margin-top: 3.5rem;
}

.section-title {
    margin-bottom: 1.5rem;
}

.section-title h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
}

.section-title p {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.directory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.directory-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}

.directory-title {
    font-weight: 700;
    font-size: 0.98rem;
    margin-bottom: 0.4rem;
}

.directory-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.85rem;
}

.directory-details {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-subtle);
    margin-bottom: 1rem;
}

.directory-actions {
    margin-top: auto;
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* Guide Section */
.guide-section {
    margin-top: 3.5rem;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.guide-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.guide-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.guide-card-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.guide-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.84rem;
    color: var(--text-muted);
}

.guide-list li {
    position: relative;
    padding-left: 1rem;
}

.guide-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--brand-primary);
}

/* Official Portals */
.portals-section {
    margin-top: 3rem;
}

.portals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.85rem;
}

.portal-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    text-decoration: none;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.portal-card:hover {
    border-color: var(--brand-primary);
}

.portal-card-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--brand-primary);
}

.portal-card-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.portal-card-url {
    font-size: 0.72rem;
    color: var(--text-subtle);
    font-family: monospace;
    margin-top: auto;
}

/* History Section */
.history-section {
    margin-top: 3rem;
}

.history-list {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.history-item {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-main);
}

.history-item:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

/* Placeholder */
.placeholder-section {
    margin-top: 1.5rem;
}

.placeholder-card {
    background-color: var(--bg-surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    padding: 3rem 1.5rem;
    text-align: center;
    max-width: 680px;
    margin: 0 auto;
}

.placeholder-icon {
    font-size: 2.2rem;
    color: var(--brand-primary);
    margin-bottom: 1rem;
}

.placeholder-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.4rem;
}

.placeholder-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* Footer */
.footer {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    padding: 1.5rem 0;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-subtle);
}

/* ==========================================================================
   Floating Bookmarklet Pill
   ========================================================================== */

/* Hidden by default; JS shows it after a search */
.bookmarklet-fab {
    position: fixed;
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    right: 1.5rem;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--brand-primary) 0%, #1e40af 100%);
    color: #ffffff;
    border-radius: 50px;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35), 0 2px 8px rgba(0,0,0,0.15);
    padding: 0.75rem 1.35rem;
    height: 50px;
    white-space: nowrap;
    border: 2px solid rgba(255, 255, 255, 0.2);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    user-select: none;
    cursor: grab;
    text-decoration: none;
    animation: fabPopIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

@keyframes fabPopIn {
    0% { transform: scale(0) translateY(40px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.bookmarklet-fab:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.45), 0 4px 12px rgba(0,0,0,0.2);
    color: #ffffff;
}

.bookmarklet-fab:active {
    cursor: grabbing;
    transform: scale(0.97);
}

.bookmarklet-fab-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
    animation: fabIconPulse 2s infinite ease-in-out;
}

@keyframes fabIconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.bookmarklet-fab-label {
    opacity: 1;
    max-width: none;
    font-size: 0.88rem;
    letter-spacing: 0.01em;
}

/* Mobile: full width bar at bottom */
@media (max-width: 640px) {
    .bookmarklet-fab {
        width: auto;
        bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
        right: 1rem;
        left: 1rem;
        border-radius: var(--radius-md);
        justify-content: center;
        height: 52px;
        font-size: 0.95rem;
        padding: 0 1.25rem;
        cursor: pointer;
    }

    .main-content {
        padding-bottom: calc(3rem + 54px + env(safe-area-inset-bottom, 0px));
    }
}


/* Utilities */

.hidden { display: none !important; }
.text-danger { color: var(--status-danger-text) !important; }
.btn-text { background: none; border: none; font-family: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; }

/* Skeleton Loader */
.skeleton-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    height: 200px;
}

.skeleton-line {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media print {
    .navbar, .hero-section, .action-bar, .history-section, .footer, .portals-section, .tmo-directory-section, .ai-info-section, .compact-feedback-bar {
        display: none !important;
    }
    body { background: #fff !important; color: #000 !important; }
}

/* ==========================================================================
   Mobile Responsive Styles — 480px and below (most phones)
   ========================================================================== */
@media (max-width: 640px) {
    /* Container padding tightened */
    .container {
        padding: 0 0.9rem;
    }

    /* Navbar: hide brand subtitle, shrink brand name */
    .nav-container {
        min-height: auto;
        padding-top: 0.6rem;
        padding-bottom: 0.6rem;
    }

    .brand-name {
        font-size: 0.88rem;
        max-width: 130px;
    }

    /* Hide verbose nav labels on smallest screens */
    #navSub { display: none; }
    .btn-back-main span,
    #navFeedbackText { display: none; }

    /* Nav controls: tighten gap, keep icons touch-friendly */
    .nav-controls {
        gap: 0.3rem;
    }

    .btn-outline-sm {
        padding: 0.45rem 0.55rem;
        min-height: 40px;
        min-width: 40px;
    }

    /* Hero section spacing */
    .main-content {
        padding-top: 1.25rem;
        /* padding-bottom is set dynamically by FAB media query */
    }

    .hero-section {
        margin-bottom: 1.25rem;
    }

    .hero-title {
        font-size: 1.2rem;
        line-height: 1.25;
        /* clamp: min 1rem, preferred 4.5vw, max 1.3rem */
        font-size: clamp(1rem, 4.5vw, 1.3rem);
    }

    .hero-subtitle {
        font-size: 0.88rem;
    }

    /* Search form: stack vertically */
    .search-form {
        flex-direction: column;
        gap: 0.5rem;
    }

    .search-input {
        /* 16px prevents iOS auto-zoom on focus */
        font-size: 16px;
        padding: 0.9rem 2.5rem 0.9rem 2.5rem;
    }

    .search-btn,
    button[type="submit"] {
        width: 100%;
        padding: 0.9rem 1rem;
        font-size: 1rem;
        min-height: 48px;
    }

    /* Feedback bar: stack */
    .compact-feedback-bar {
        flex-direction: column;
        text-align: center;
        gap: 0.35rem;
        padding: 0.65rem 0.85rem;
    }

    /* Summary card: tighten padding */
    .summary-card {
        padding: 1.1rem;
    }

    .hero-card-header {
        gap: 0.65rem;
    }

    .hero-status-avatar {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    .hero-greeting-title {
        font-size: 1.1rem;
    }

    .hero-greeting-sub {
        font-size: 0.88rem;
    }

    /* Box code: smaller font on tiny screens */
    .hero-box-code-value {
        font-size: 1.3rem;
    }

    /* Instructions box */
    .hero-instruction-box {
        font-size: 0.84rem;
    }

    /* Action buttons: full-width stack */
    .hero-action-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .hero-action-row .btn {
        width: 100%;
        min-height: 48px;
        font-size: 0.95rem;
    }

    /* Office cards */
    .office-card {
        padding: 1rem;
    }

    .office-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
        padding-bottom: 0.65rem;
    }

    .office-name {
        font-size: 0.98rem;
    }

    /* Details grid: single column */
    .details-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.65rem;
    }

    /* Office footer info: stack vertically */
    .office-footer-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    /* Office links: ensure min tap target */
    .office-link,
    .portal-text-link,
    .compact-link {
        min-height: 36px;
        display: inline-flex;
        align-items: center;
    }

    /* Directory grid: single column */
    .directory-grid {
        grid-template-columns: 1fr;
    }

    .directory-card {
        padding: 1rem;
    }

    /* Guide grid: single column */
    .guide-grid {
        grid-template-columns: 1fr;
    }

    /* Portals grid: 2 columns on phones, 1 below 360px */
    .portals-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.65rem;
    }

    /* Sections: tighter top margins */
    .tmo-directory-section,
    .guide-section,
    .portals-section,
    .history-section {
        margin-top: 2rem;
    }

    /* Section title */
    .section-title h2 {
        font-size: 1.15rem;
    }

    /* History chips: smaller */
    .history-item {
        font-size: 0.8rem;
        padding: 0.35rem 0.65rem;
    }

    /* Placeholder card */
    .placeholder-card {
        padding: 2rem 1rem;
    }

    .placeholder-card h3 {
        font-size: 1.05rem;
    }

    /* Footer */
    .footer {
        padding: 1.25rem 0;
        font-size: 0.78rem;
        /* Safe area inset for notched phones */
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    }

    .footer-disclaimer-box {
        font-size: 0.75rem !important;
        padding: 0.65rem 0.75rem !important;
    }

    /* Action bar: stack */
    .action-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Tiny phones: below 360px */
@media (max-width: 360px) {
    .portals-grid {
        grid-template-columns: 1fr;
    }

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

    .hero-title {
        font-size: 1.35rem;
    }

    .hero-box-code-value {
        font-size: 1.1rem;
    }
}