/* ===== BASE ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #0047AB;
    --primary-dark: #003380;
    --primary-light: #e0f2fe;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-dark: #cbd5e1;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --radius: 0.75rem;
    --radius-sm: 0.5rem;
    --radius-full: 9999px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1rem;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== HEADER ===== */
.header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0.875rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    font-size: 1rem;
}

.logo-icon {
    font-size: 1.25rem;
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
    background: var(--card);
    padding: 0.625rem 0;
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}

.breadcrumb a { color: var(--text-secondary); }
.breadcrumb .sep { margin: 0 0.375rem; }

/* ===== MAIN ===== */
.main {
    padding: 1.5rem 0 3rem;
    min-height: calc(100vh - 180px);
}

/* ===== HERO ===== */
.hero {
    text-align: center;
    padding: 2rem 0;
}

.hero h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.hero p {
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.hero .stats {
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 1.5rem;
}

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.tab, .tab-btn {
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.tab:hover, .tab-btn:hover { color: var(--text); }
.tab.active, .tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== TOOLS SECTION ===== */
.tools-section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}

.tools-section h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.tool-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.translate-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.translate-form textarea {
    width: 100%;
    padding: 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    resize: vertical;
    font-family: inherit;
}

.translate-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

.translate-result, .builder-result {
    margin-top: 1rem;
}

.builder-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-row label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-row input,
.form-row select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
}

.form-row input:focus,
.form-row select:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

.form-row select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===== CARDS ===== */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.card-header h2, .card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.form-input, .form-textarea, .form-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    transition: all 0.2s;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--card);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
    line-height: 1.6;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.form-grid.cols-1 { grid-template-columns: 1fr; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }

.btn-secondary {
    background: var(--card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); border-color: var(--border-dark); }

.btn-success {
    background: var(--success);
    color: white;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ===== SEARCH ===== */
.search-box {
    max-width: 500px;
    margin: 0 auto 2rem;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 0.875rem 1.25rem;
    padding-left: 3rem;
    font-size: 0.9375rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--card);
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.search-box .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

#search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    margin-top: 0.5rem;
    display: none;
    max-height: 320px;
    overflow-y: auto;
    z-index: 200;
    border: 1px solid var(--border);
}

#search-results.active { display: block; }

#search-results a,
#search-results .result-item {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

#search-results a:hover,
#search-results .result-item:hover {
    background: var(--bg);
    text-decoration: none;
}

#search-results a:last-child,
#search-results .result-item:last-child { border-bottom: none; }

#search-results a strong {
    font-weight: 600;
    color: var(--text);
}

#search-results a small {
    color: var(--text-muted);
}

.result-name { font-weight: 500; }
.result-path { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.125rem; }
.result-zip {
    display: inline-block;
    font-size: 0.6875rem;
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    margin-left: 0.5rem;
}

/* ===== GRIDS ===== */
.grid {
    display: grid;
    gap: 0.75rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.level1-grid, .level2-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.625rem;
}

.level1-card, .level2-card {
    background: var(--card);
    padding: 0.875rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.level1-card:hover, .level2-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.name-local { display: block; font-weight: 600; font-size: 0.9375rem; }
.name-en { display: block; font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.125rem; }
.count { display: block; margin-top: 0.375rem; font-size: 0.75rem; color: var(--primary); }

/* ===== TABLES ===== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ===== ADDRESS DETAIL ===== */
.address-detail h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.address-detail .subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

.input-section,
.address-section,
.export-section,
.location-section,
.related-section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.input-section h2,
.address-section h2,
.export-section h2,
.location-section h2,
.related-section h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.input-form {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

@media (max-width: 640px) {
    .input-form {
        grid-template-columns: 1fr;
    }
}

.address-box {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 1rem;
    position: relative;
}

.address-box:last-child {
    margin-bottom: 0;
}

.address-box h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.address-box pre {
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    min-height: 80px;
}

.address-box .copy-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.address-box .copy-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.export-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.related-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.5rem;
}

/* ===== SECTION HEADER ===== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.view-toggle {
    display: flex;
    gap: 0.25rem;
}

.view-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.view-btn:hover {
    background: var(--card);
    border-color: var(--border-dark);
}

.view-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.view-content {
    display: none !important;
}

.view-content.active {
    display: block !important;
}

.level2-grid.view-content.active,
.level3-list.view-content.active {
    display: grid !important;
}

/* ===== LEVEL3 LIST ===== */
.level3-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
}

.level3-item {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
}

.level3-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.level3-item .name-local {
    font-weight: 600;
    font-size: 0.9375rem;
}

.level3-item .name-en {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.level3-item .postal {
    font-size: 0.75rem;
    color: var(--primary);
    margin-top: 0.25rem;
}

/* ===== DATA TABLE ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--bg);
}

.data-table a {
    color: var(--primary);
}

/* ===== LEVEL1/2 PAGE HEADERS ===== */
.main > .container > h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.main > .container > .subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

/* ===== LEVEL2/3 SECTIONS ===== */
.level2-section,
.level3-section {
    margin-top: 1rem;
}

.level2-section h2,
.level3-section h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* ===== PAGE HEADER (fallback) ===== */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.page-header .subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

.location-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

/* ===== ADDRESS OUTPUT ===== */
.address-output {
    position: relative;
}

.address-output pre, .address-output .output-text {
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 1rem;
    padding-right: 4rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin: 0;
}

.address-output .copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

/* ===== FORMAT TABS ===== */
.format-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}

.format-tab {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.format-tab:hover { background: var(--card); border-color: var(--border-dark); }
.format-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.format-info {
    margin-bottom: 1rem;
}

.format-description {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.format-usecases {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.usecase-tag {
    font-size: 0.6875rem;
    background: var(--bg);
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ===== ADDRESS CARD ===== */
.address-card-section {
    margin-bottom: 1.5rem;
}

.address-card-preview {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    margin: 0 auto 1rem;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.address-card-preview canvas {
    width: 100%;
    height: 100%;
}

.theme-toggle {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.theme-btn {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.theme-btn.light { background: #fff; color: #1e293b; }
.theme-btn.dark { background: #1e293b; color: #fff; }
.theme-btn.active { outline: 2px solid var(--primary); outline-offset: 2px; }

.card-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== INPUT FORM ===== */
.input-form-section {
    margin-bottom: 1.5rem;
}

/* ===== NOTES / ALERTS ===== */
.note {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    margin-bottom: 1rem;
}

.note-icon { flex-shrink: 0; margin-top: 0.125rem; }
.note-success { background: var(--success-light); color: #065f46; }
.note-warning { background: var(--warning-light); color: #92400e; }
.note-info { background: var(--primary-light); color: var(--primary-dark); }

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-icon { color: var(--success); }

/* ===== MODAL ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 1rem;
}

.modal.show { display: flex; }

.modal-content {
    background: var(--card);
    border-radius: var(--radius);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    position: relative;
    padding: 1.5rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1rem; font-weight: 600; }

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

.modal-body { padding: 1.25rem; }

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* ===== QR CODE ===== */
.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

#qrcode {
    background: white;
    padding: 1rem;
    border-radius: var(--radius-sm);
}

/* ===== LOCATION INFO ===== */
.location-info {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
}

.location-info dt {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.location-info dd {
    font-size: 0.875rem;
}

/* ===== FAQ ===== */
.faq-section { margin-top: 2rem; }

.faq-item {
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
}

.faq-item:last-child { border-bottom: none; }

.faq-question {
    font-weight: 600;
    font-size: 0.9375rem;
    margin-bottom: 0.5rem;
}

.faq-answer {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===== RELATED ===== */
.related-section { margin-top: 2rem; }

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
}

.related-item {
    display: block;
    padding: 0.625rem 0.875rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--text);
    text-decoration: none;
    transition: all 0.2s;
}

.related-item:hover {
    background: var(--primary-light);
    color: var(--primary);
    text-decoration: none;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--card);
    padding: 1.5rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8125rem;
    border-top: 1px solid var(--border);
}

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8125rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }

/* ===== ICONS ===== */
.icon {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: middle;
}

/* ===== RESPONSIVE ===== */
/* ===== LOCATION HEADER ===== */
.location-header {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.location-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.3;
}

.location-english {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1rem;
}

.location-meta {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.meta-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.meta-value {
    font-weight: 600;
    color: var(--primary);
}

/* ===== QUICK COPY SECTION ===== */
.quick-copy-section {
    background: var(--primary-light);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.quick-copy-label {
    font-size: 0.8125rem;
    color: var(--primary-dark);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.quick-copy-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
}

.quick-copy-text {
    flex: 1;
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 0.875rem;
    color: var(--text);
    word-break: break-word;
}

.btn-copy-small {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-copy-small:hover {
    background: var(--primary-dark);
}

.btn-copy-small svg {
    width: 14px;
    height: 14px;
}

/* ===== ADDRESS CARD SQUARE ===== */
.address-card-section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.address-card-section h2 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.address-card-section h2 svg {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

.section-desc {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    margin-top: 0.25rem;
}

.address-card-square {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1;
    margin: 1rem auto;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    position: relative;
    box-shadow: var(--shadow-md);
    transition: all 0.3s;
}

.address-card-square[data-theme="light"] {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    color: #1e293b;
    border: 1px solid var(--border);
}

.address-card-square[data-theme="dark"] {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #f1f5f9;
    border: 1px solid #334155;
}

.card-address-main {
    text-align: center;
    line-height: 1.6;
}

.address-level3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.address-level2 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.125rem;
}

.address-level1 {
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
}

.address-zipcode {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    letter-spacing: 0.05em;
}

.address-country {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    margin-top: 0.5rem;
}

.card-watermark {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    font-size: 0.625rem;
    opacity: 0.4;
    font-weight: 500;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* ===== INPUT GRID ===== */
.input-section h2 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.input-section h2 svg {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

.input-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.input-group.full {
    grid-column: span 2;
}

.input-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-field {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    transition: all 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--card);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== FORMAT SECTION ===== */
.format-section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.format-header {
    margin-bottom: 1rem;
}

.format-header h2 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.format-header h2 svg {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

.format-content {
    margin-top: 1rem;
}

.format-description {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.format-description svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--primary);
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* ===== TIPS SECTION ===== */
.tips-section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.tips-section h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.tips-section h3 svg {
    width: 20px;
    height: 20px;
    color: var(--warning);
}

.tips-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tips-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.tips-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.tips-list li svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--success);
    margin-top: 0.125rem;
}

.tips-list li strong {
    color: var(--text);
    font-weight: 600;
}

/* ===== FAQ SECTION ENHANCED ===== */
.faq-section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.faq-section h2,
.faq-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.faq-section h2 svg,
.faq-section h3 svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--primary);
}

.faq-list {
    display: flex;
    flex-direction: column;
}

/* ===== RELATED DISTRICTS ===== */
.related-districts {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.related-districts h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.related-districts h2 svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--primary);
}

.district-links {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.5rem;
}

.district-link {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
    border: 1px solid transparent;
}

.district-link:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    text-decoration: none;
}

.district-link-local {
    font-weight: 600;
    font-size: 0.9375rem;
    margin-bottom: 0.125rem;
}

.district-link-en {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.district-link:hover .district-link-en {
    color: var(--primary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .container { padding: 0 0.75rem; }

    .hero h1 { font-size: 1.375rem; }

    .tabs { overflow-x: auto; }
    .tab-btn { padding: 0.625rem 1rem; font-size: 0.8125rem; }

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

    .level1-grid, .level2-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .level1-card, .level2-card { padding: 0.75rem; }
    .name-local { font-size: 0.875rem; }

    .btn-group { flex-direction: column; }
    .btn-group .btn { width: 100%; }

    .card-header { flex-direction: column; align-items: flex-start; }

    .theme-toggle { flex-direction: column; }
    .theme-btn { width: 100%; }

    .format-tabs { gap: 0.375rem; }
    .format-tab { padding: 0.375rem 0.75rem; }

    .address-card-preview { max-width: 100%; }

    /* Level3 page responsive */
    .location-header h1 { font-size: 1.25rem; }
    .location-meta { gap: 1rem; }

    .quick-copy-box {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .btn-copy-small { justify-content: center; }

    .address-card-square {
        max-width: 280px;
        padding: 1.5rem;
    }

    .address-level3 { font-size: 1.125rem; }
    .address-level2 { font-size: 0.9375rem; }

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

    .input-group.full {
        grid-column: span 1;
    }

    .action-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .action-buttons .btn {
        flex: 0 0 auto;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .district-links {
        grid-template-columns: repeat(2, 1fr);
    }
}
