/* ============================================================
   GPS Watermark - Design System
   ------------------------------------------------------------
   Reading as: consumer photo-watermark PWA (redesign - preserve)
   Dials: DESIGN_VARIANCE 5 / MOTION_INTENSITY 4 / VISUAL_DENSITY 5
   Brand: amber (dipertahankan #FFC107) + warm ink + stone neutrals.
   Theme: light default, dark via [data-theme="dark"] (toggle pojok kanan
   atas). Pertama kali buka mengikuti sistem, lalu pilihan tersimpan di
   localStorage (gpswm-theme). Satu aksen.
   Radius scale (dokumentasi): 8px small / 10px inputs-buttons /
   16px cards-panels / 999px chips.
   Catatan: Semua hook class lama yang dipakai app.js tetap ada
   (.active, .open, .visible, .dragover, .show, .btn-outline-active,
   .offline-*, .search-suggest-item, .template-item, dst).
   ============================================================ */

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

/* ── Tokens: Light ─────────────────────────────────────────── */
:root {
    color-scheme: light;

    /* Brand amber (dipertahankan) */
    --accent:        #FFC107;
    --accent-hover:  #FFB300;
    --accent-strong: #FFA000;
    --accent-soft:   #FFEDB0;
    --accent-ink:    #241b00;   /* teks di atas amber - kontras tinggi */
    --accent-text:   #8A5A00;   /* amber terbaca di latar amber pucat */

    /* Neutral warm-amber (light mode kuning, bukan putih) */
    --bg:            #FFF6CE;
    --bg-glow:       rgba(255, 193, 7, 0.22);
    --surface:       #FFFCE8;
    --surface-2:     #FDF3CE;
    --surface-3:     #F9EBB4;
    --border:        #F0E1AB;
    --border-strong: #DDC780;

    --text:          #292418;
    --text-2:        #65583A;
    --text-3:        #7A6D44;

    /* Semantik */
    --success:       #2E7D32;
    --success-strong:#2E7D32;   /* latar tombol sukses (teks putih AA) */
    --success-soft:  #E8F5E9;
    --danger:        #C62828;
    --danger-strong: #C62828;   /* latar tombol bahaya (teks putih AA) */
    --danger-soft:   #FDECEA;
    --warn:          #E65100;
    --warn-soft:     #FFF3E0;
    --info:          #1565C0;
    --info-soft:     #E3F2FD;

    --stage:         #121110;   /* stage foto - selalu gelap */

    /* Radius scale */
    --r-sm:  8px;
    --r-md:  10px;
    --r-lg:  16px;
    --r-pill: 999px;

    /* Elevasi (shadow di-tint ke hue amber) */
    --shadow-1: 0 1px 2px rgba(122, 95, 20, 0.08), 0 4px 14px rgba(122, 95, 20, 0.08);
    --shadow-2: 0 2px 6px rgba(122, 95, 20, 0.10), 0 14px 36px rgba(122, 95, 20, 0.16);
    --shadow-accent: 0 6px 18px rgba(255, 176, 0, 0.35);

    --ease: cubic-bezier(0.16, 1, 0.3, 1);

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas,
                 "Liberation Mono", monospace;
}

/* ── Tokens: Dark ──────────────────────────────────────────── */
:root[data-theme="dark"] {
    color-scheme: dark;

    --accent:        #FFC107;
    --accent-hover:  #FFCA28;
    --accent-strong: #FFD54F;
    --accent-soft:   #332b12;
    --accent-ink:    #1d1400;
    --accent-text:   #FFD54F;

    --bg:            #151412;
    --bg-glow:       rgba(255, 193, 7, 0.07);
    --surface:       #1d1c1a;
    --surface-2:     #242321;
    --surface-3:     #2d2b28;
    --border:        #2e2c28;
    --border-strong: #423f39;

    --text:          #ece7dc;
    --text-2:        #a8a293;
    --text-3:        #8f8a7e;

    --success:       #66BB6A;
    --success-strong:#2E7D32;   /* latar tombol sukses (teks putih AA) */
    --success-soft:  #1b3320;
    --danger:        #EF5350;
    --danger-strong: #C62828;   /* latar tombol bahaya (teks putih AA) */
    --danger-soft:   #3a1f1e;
    --warn:          #FFB74D;
    --warn-soft:     #3a2c14;
    --info:          #64B5F6;
    --info-soft:     #16283c;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.30), 0 4px 14px rgba(0, 0, 0, 0.25);
    --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.35), 0 14px 36px rgba(0, 0, 0, 0.40);
    --shadow-accent: 0 6px 18px rgba(255, 193, 7, 0.18);
}

/* ── Base ──────────────────────────────────────────────────── */
html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg);
    background-image:
        radial-gradient(900px 420px at 50% -140px, var(--bg-glow), transparent 70%);
    background-repeat: no-repeat;
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input,
select { font-family: inherit; font-size: inherit; color: inherit; }

img, canvas { display: block; max-width: 100%; }

::selection { background: rgba(255, 193, 7, 0.35); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--r-sm);
    border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Layout ────────────────────────────────────────────────── */
.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 16px 48px;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.content,
.sidebar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-1);
}

.content { padding: 18px 16px; order: 1; }
.sidebar { padding: 16px 14px; order: 2; }

/* ── Header / Brand ────────────────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 0 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: var(--r-lg);
    background: linear-gradient(150deg, var(--accent), var(--accent-hover));
    color: var(--accent-ink);
    font-size: 1.15rem;
    box-shadow: var(--shadow-accent), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.brand-text h1 {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.brand-text p {
    font-size: 0.85rem;
    color: var(--text-2);
    margin-top: 2px;
}

/* Toggle tema terang/gelap */
.theme-toggle {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    color: var(--text-2);
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: var(--shadow-1);
    transition:
        color 0.2s var(--ease),
        border-color 0.2s var(--ease),
        background-color 0.2s var(--ease),
        transform 0.15s var(--ease);
}

.theme-toggle:hover {
    color: var(--accent-text);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.theme-toggle:active { transform: translateY(0) scale(0.96); }

/* Ikon: bulan saat terang (klik → gelap), matahari saat gelap (klik → terang) */
.theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    padding: 10px 14px 12px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-2);
    transition: color var(--ease) 0.2s, border-color var(--ease) 0.2s;
    white-space: nowrap;
}

.tab-btn:hover { color: var(--text); }

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

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

/* ── Upload area (hero) ────────────────────────────────────── */
.upload-area {
    position: relative;
    border: 1.5px dashed var(--accent);
    border-radius: var(--r-lg);
    background:
        linear-gradient(var(--accent-soft), var(--accent-soft)),
        var(--surface);
    padding: 34px 16px;
    text-align: center;
    cursor: pointer;
    transition: transform var(--ease) 0.2s, background-color 0.2s,
                border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 16px;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent-strong);
    box-shadow: var(--shadow-accent);
    transform: translateY(-2px);
}

.upload-area:active { transform: translateY(0) scale(0.995); }

.upload-icon {
    width: 62px;
    height: 62px;
    margin: 0 auto 12px;
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    color: var(--accent-text);
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-1), inset 0 0 0 1px var(--border);
}

.upload-placeholder p {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text);
}

.upload-placeholder small {
    font-size: 0.78rem;
    color: var(--text-2);
    letter-spacing: 0.01em;
}

/* ── Watermark controls (zoom / text scale) ────────────────── */
.wm-controls {
    display: none;
    flex-direction: column;
    gap: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px 16px;
    margin-bottom: 14px;
}

.wm-controls.visible { display: flex; }

.wm-control-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wm-control-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-2);
    white-space: nowrap;
    min-width: 96px;
}

.ctrl-icon { font-size: 0.95rem; color: var(--text-3); }

.ctrl-val {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--accent-text);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--r-pill);
    min-width: 44px;
    text-align: center;
}

.wm-control-row input[type="range"] {
    flex: 1;
    min-width: 0;
    accent-color: var(--accent);
    cursor: pointer;
    height: 5px;
}

/* ── Preview stage ─────────────────────────────────────────── */
.preview-wrap {
    position: relative;
    background: var(--stage);
    border-radius: var(--r-lg);
    overflow: hidden;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    box-shadow: var(--shadow-1);
}

#previewCanvas {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--r-lg);
}

.no-image {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #8a8578;
    text-align: center;
    padding: 24px;
}

.no-image .no-image-icon {
    font-size: 2.4rem;
    opacity: 0.7;
}

.no-image p {
    font-size: 0.92rem;
    font-weight: 600;
    color: #b3ada0;
}

.no-image small {
    font-size: 0.78rem;
    color: #6f6a5f;
}

/* ── Action bar ────────────────────────────────────────────── */
.action-bar {
    display: flex;
    gap: 10px;
}

.action-bar .btn { flex: 1; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: transform 0.18s var(--ease), background-color 0.2s,
                border-color 0.2s, color 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(0.985); }

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-primary {
    background: linear-gradient(150deg, var(--accent), var(--accent-hover));
    color: var(--accent-ink);
    box-shadow: var(--shadow-accent);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 22px rgba(255, 176, 0, 0.38); }

.btn-success {
    background: var(--success-strong);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(46, 125, 50, 0.25);
}
.btn-success:hover:not(:disabled) { box-shadow: 0 8px 22px rgba(46, 125, 50, 0.32); }

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

.btn-danger {
    background: var(--danger-strong);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(198, 40, 40, 0.22);
}
.btn-danger:hover:not(:disabled) { box-shadow: 0 8px 22px rgba(198, 40, 40, 0.30); }

.btn-outline {
    background: transparent;
    border-color: var(--accent-text);
    color: var(--accent-text);
    padding: 8px 14px;
    font-size: 0.85rem;
    margin-bottom: 6px;
}
.btn-outline:hover:not(:disabled) {
    background: var(--accent-soft);
    box-shadow: none;
}

.btn-outline-muted {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text-2);
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}
.btn-outline-muted:hover:not(:disabled) {
    border-color: var(--accent-text);
    color: var(--accent-text);
    background: var(--accent-soft);
    box-shadow: none;
}

.btn-outline-active {
    background: var(--accent-soft) !important;
    border-color: var(--accent-text) !important;
    color: var(--accent-text) !important;
}

.btn-sm { padding: 7px 12px; font-size: 0.82rem; }

/* ── Sidebar / Template ────────────────────────────────────── */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.sidebar-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.template-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.template-item {
    padding: 7px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-2);
    transition: color 0.18s, background-color 0.18s, border-color 0.18s;
    white-space: nowrap;
    -webkit-user-select: none;
    user-select: none;
}

.template-item:hover {
    border-color: var(--accent-strong);
    color: var(--text);
}

.template-item.active {
    background: var(--accent);
    border-color: var(--accent-strong);
    color: var(--accent-ink);
    font-weight: 700;
}

.template-empty {
    display: none;
    text-align: center;
    padding: 26px 12px;
    color: var(--text-2);
    font-size: 0.85rem;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--r-md);
}

.template-empty p { margin-bottom: 12px; }

.sidebar-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.sidebar-actions .btn,
.sidebar-actions label.btn {
    flex: 1;
    cursor: pointer;
    text-align: center;
}

/* ── Settings form ─────────────────────────────────────────── */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px;
    min-width: 0;
}

legend {
    padding: 0 8px;
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text);
    letter-spacing: -0.01em;
}

legend i { color: var(--accent-text); margin-right: 2px; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-2);
}

.form-group input,
.form-group select,
.select-inline,
.search-row input,
.modal-content input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    font-size: 0.9rem;
    background: var(--surface);
    transition: border-color 0.18s, box-shadow 0.18s;
}

.form-group input:hover,
.form-group select:hover,
.select-inline:hover,
.search-row input:hover,
.modal-content input:hover {
    border-color: var(--text-3);
}

.form-group input:focus,
.form-group select:focus,
.select-inline:focus,
.search-row input:focus,
.modal-content input:focus {
    outline: none;
    border-color: var(--accent-text);
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.18);
}

.form-group input::placeholder,
.search-row input::placeholder,
.modal-content input::placeholder {
    color: var(--text-3);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.select-inline {
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.coord-row {
    display: flex;
    gap: 10px;
    margin-bottom: 4px;
}

.coord-row .form-group { flex: 1; min-width: 0; }

.coord-row input { font-family: var(--font-mono); letter-spacing: -0.01em; }

/* Link "Open Map" — rata bawah dengan input koordinat */
.coord-row .form-group.coord-link {
    justify-content: flex-end;
}

.coord-row a.open-map {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--accent-text);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.18s, color 0.18s, background 0.18s, box-shadow 0.18s, transform 0.12s;
}

.coord-row a.open-map i { font-size: 0.95rem; }

.coord-row a.open-map:hover {
    border-color: var(--accent-text);
    background: var(--accent-soft);
    box-shadow: var(--shadow-1);
}

.coord-row a.open-map:active { transform: translateY(1px); }

.coord-row a.open-map:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.35);
}

.coord-row a.open-map.disabled {
    color: var(--text-3);
    background: var(--surface-2);
    border-style: dashed;
    cursor: not-allowed;
    pointer-events: none;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin-bottom: 14px;
    font-size: 0.9rem;
    font-weight: 500;
}

.toggle-row input[type="checkbox"] {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--accent-strong);
}

.toggle-row:hover { color: var(--text); }

.info-badge {
    margin-top: 4px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 0.82rem;
    color: var(--text-2);
    min-height: 38px;
    line-height: 1.45;
    word-break: break-word;
}

.source-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
    margin-bottom: 10px;
}

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-picker-row input[type="color"] {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    padding: 3px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    cursor: pointer;
    background: var(--surface);
}

.color-picker-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker-row input[type="color"]::-webkit-color-swatch { border: none; border-radius: var(--r-sm); }

.color-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.color-preset {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.18s var(--ease), border-color 0.18s;
    padding: 0;
}

.color-preset:hover { transform: scale(1.14); border-color: var(--text); }
.color-preset:active { transform: scale(0.94); }

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Search + suggestions ──────────────────────────────────── */
.search-row-wrap {
    position: relative;
    margin-bottom: 8px;
}

.search-row {
    display: flex;
    gap: 8px;
}

.search-row input { flex: 1; min-width: 0; }

.search-suggest {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 1100;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-2);
    max-height: 240px;
    overflow-y: auto;
    display: none;
}

.search-suggest.open { display: block; }

.search-suggest-item {
    padding: 11px 14px;
    cursor: pointer;
    font-size: 0.84rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    line-height: 1.45;
    transition: background-color 0.15s;
}

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

.search-suggest-item:hover,
.search-suggest-item.active { background: var(--accent-soft); }

.search-suggest-item .suggest-primary {
    font-weight: 600;
    display: block;
    margin-bottom: 3px;
}

.search-suggest-item .suggest-secondary {
    font-size: 0.74rem;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Map ───────────────────────────────────────────────────── */
.map-wrapper { position: relative; }

.map-container {
    height: 220px;
    border-radius: var(--r-md);
    overflow: hidden;
    border: 1px solid var(--border);
}

.btn-map-center {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    color: var(--text-2);
    box-shadow: var(--shadow-1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: transform 0.18s var(--ease), color 0.18s;
}

.btn-map-center:hover {
    transform: scale(1.1);
    color: var(--accent-text);
    border-color: var(--accent-text);
}

.btn-map-apply {
    position: absolute;
    top: 54px;
    right: 10px;
    z-index: 1000;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    color: var(--accent-text);
    box-shadow: var(--shadow-1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: transform 0.18s var(--ease), color 0.18s;
}

.btn-map-apply:hover {
    transform: scale(1.1);
    color: var(--success);
    border-color: var(--success);
}

/* ── Manual wraps ──────────────────────────────────────────── */
.manual-wrap {
    margin-top: 10px;
    padding: 14px;
    background: var(--accent-soft);
    border: 1.5px dashed var(--accent-strong);
    border-radius: var(--r-md);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.manual-wrap .form-group label { color: var(--text-2); }

.weather-manual-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.time-hms-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    max-width: 100%;
}

.time-hms-row .form-group { flex: 1; min-width: 0; }
.time-hms-row .form-group label { display: block; text-align: center; }
.time-hms-row .form-group input {
    text-align: center;
    padding-left: 4px;
    padding-right: 4px;
    font-family: var(--font-mono);
}

.time-sep {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-text);
    padding-bottom: 9px;
    line-height: 1;
    flex-shrink: 0;
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 18, 14, 0.55);
    z-index: 999;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.active {
    display: flex;
    animation: modal-in 0.24s var(--ease);
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 26px 22px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-2);
}

.modal-content h2 {
    font-size: 1.08rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin-bottom: 14px;
}

.modal-desc {
    font-size: 0.9rem;
    color: var(--text-2);
    margin-bottom: 16px;
    line-height: 1.5;
}

.modal-content input { margin-bottom: 16px; }

.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

.import-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.import-options .btn {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 12px 16px;
    text-align: left;
}

.import-options .btn small {
    font-size: 0.78rem;
    font-weight: 400;
    opacity: 0.85;
}

/* ── PWA install toast ─────────────────────────────────────── */
.pwa-toast {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    justify-content: center;
    padding: 0 12px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-110%);
    transition: transform 0.45s var(--ease), opacity 0.4s ease;
}

.pwa-toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.pwa-toast-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: var(--r-lg);
    padding: 10px 14px;
    box-shadow: var(--shadow-2);
    width: 100%;
    max-width: 420px;
    margin-top: 12px;
}

.pwa-toast-inner > i:first-child {
    font-size: 1.25rem;
    color: var(--accent-text);
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    border-radius: var(--r-md);
}

.pwa-toast-text { flex: 1; min-width: 0; }

.pwa-toast-text strong {
    display: block;
    font-size: 0.86rem;
    color: var(--text);
    line-height: 1.3;
}

.pwa-toast-text span {
    font-size: 0.74rem;
    color: var(--text-2);
    line-height: 1.3;
}

.pwa-toast .btn-primary {
    border-radius: var(--r-pill);
    padding: 7px 16px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.pwa-toast-close {
    background: none;
    border: none;
    font-size: 0.85rem;
    color: var(--text-3);
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
    line-height: 1;
    transition: color 0.2s, transform 0.2s var(--ease);
}

.pwa-toast-close:hover { color: var(--text); transform: rotate(90deg); }

/* ── Offline notification ──────────────────────────────────── */
.offline-notification {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    max-width: 380px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-2);
    padding: 13px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 9999;
    transform: translateY(120px);
    opacity: 0;
    transition: transform 0.3s var(--ease), opacity 0.3s ease;
    animation: slideIn 0.3s var(--ease) forwards;
}

.offline-notification.show {
    transform: translateY(0);
    opacity: 1;
}

.offline-notification i { font-size: 1.2rem; flex-shrink: 0; }

.offline-notification.offline-warning {
    background: var(--warn-soft);
    border-left: 4px solid var(--warn);
    color: var(--warn);
}
.offline-notification.offline-warning i { color: var(--warn); }

.offline-notification.offline-success {
    background: var(--success-soft);
    border-left: 4px solid var(--success);
    color: var(--success);
}
.offline-notification.offline-success i { color: var(--success); }

.offline-notification.offline-info {
    background: var(--info-soft);
    border-left: 4px solid var(--info);
    color: var(--info);
}
.offline-notification.offline-info i { color: var(--info); }

.offline-notification.offline-info {
    animation: slideIn 0.3s var(--ease) forwards, fadeOut 3.5s ease-in-out forwards;
}

/* ── Util states (dipakai offline-handler / legacy) ────────── */
.offline-mode button:disabled,
.offline-mode input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.cached-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-2);
    padding: 2px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    margin-left: 8px;
    opacity: 0.75;
}

.cached-indicator i { font-size: 0.85rem; }

.loading-subtle { opacity: 0.7; cursor: progress; }

/* ── Keyframes ─────────────────────────────────────────────── */
@keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideIn {
    from { transform: translateY(120px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

@keyframes fadeOut {
    0%   { opacity: 1; transform: translateY(0); }
    90%  { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(120px); }
}

/* ── Bottom nav (mobile): liquid-glass floating pill ──────────
   Approximasi Liquid Glass (bukan Apple official): backdrop-filter
   + lapisan border + highlight. Fallback solid untuk
   prefers-reduced-transparency. Hook JS lama (.bottom-nav-item
   [data-tab], .bottom-nav-cam) tetap dipakai app.js. */
.bottom-nav {
    display: none;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 950;
    width: min(340px, calc(100% - 32px));
    border-radius: var(--r-pill);
    border: 1px solid rgba(255, 255, 255, 0.38);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.40), rgba(255, 255, 255, 0.16)),
        rgba(255, 252, 232, 0.55);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.50),
        inset 0 -1px 0 rgba(255, 255, 255, 0.12),
        0 18px 44px rgba(122, 95, 20, 0.22);
}

.bottom-nav::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.55), transparent 46%);
    pointer-events: none;
}

.bottom-nav-inner {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    height: 62px;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--text-2);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s var(--ease), transform 0.15s var(--ease);
}

.bottom-nav-item i { font-size: 1.05rem; }

.bottom-nav-item.active { color: var(--accent-text); }

.bottom-nav-item:active { transform: scale(0.94); }

/* Tombol kamera tengah (FAB amber, sedikit naik di atas pill) */
.bottom-nav-cam {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transform: translateY(-8px);
    transition: transform 0.15s var(--ease);
}

.bottom-nav-cam::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(150deg, var(--accent), var(--accent-hover));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.45),
        0 10px 24px rgba(255, 168, 0, 0.50);
}

.bottom-nav-cam i {
    position: relative;
    z-index: 1;
    font-size: 1.35rem;
    color: var(--accent-ink);
}

.bottom-nav-cam:active { transform: translateY(-8px) scale(0.94); }

/* Dark: glass gelap dengan highlight tipis */
:root[data-theme="dark"] .bottom-nav {
    border-color: rgba(255, 255, 255, 0.14);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.04)),
        rgba(29, 28, 26, 0.55);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.14),
        inset 0 -1px 0 rgba(255, 255, 255, 0.05),
        0 18px 44px rgba(0, 0, 0, 0.50);
}

:root[data-theme="dark"] .bottom-nav::before {
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.16), transparent 46%);
}

/* Fallback solid: tanpa blur, tetap terbaca */
@media (prefers-reduced-transparency: reduce) {
    .bottom-nav {
        background: var(--surface);
        border-color: var(--border-strong);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .bottom-nav::before { display: none; }
}

/* ── Camera bottom sheet (mobile) ───────────────────────────── */
.camera-sheet {
    position: fixed;
    inset: 0;
    z-index: 960;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.25s var(--ease), visibility 0.25s;
}

.camera-sheet.show {
    visibility: visible;
    opacity: 1;
}

.camera-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 18, 14, 0.55);
    -webkit-tap-highlight-color: transparent;
}

.camera-sheet-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top-left-radius: var(--r-lg);
    border-top-right-radius: var(--r-lg);
    box-shadow: var(--shadow-2);
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.3s var(--ease);
}

.camera-sheet.show .camera-sheet-panel {
    transform: translateY(0);
}

.camera-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.camera-sheet-head h2 {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.camera-sheet-close {
    background: none;
    border: none;
    color: var(--text-3);
    font-size: 1rem;
    cursor: pointer;
    padding: 6px;
    line-height: 1;
}

.camera-sheet-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.camera-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
    text-align: center;
    transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.15s var(--ease);
}

.camera-opt:active { transform: scale(0.96); }

.camera-opt-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 1.3rem;
}

.camera-opt-text strong { display: block; font-size: 0.85rem; color: var(--text); }

.camera-opt-text small {
    display: block;
    font-size: 0.7rem;
    color: var(--text-3);
    margin-top: 2px;
    line-height: 1.35;
}

/* ── Responsive: >=480px ───────────────────────────────────── */
@media (min-width: 480px) {
    .wm-controls {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
    }
    .wm-control-row { flex: 1; min-width: 180px; }
}

/* ── Responsive: <=767px (mobile bottom nav) ───────────────── */
@media (max-width: 767.98px) {
    .bottom-nav { display: block; }

    .tabs { display: none; }

    .container { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

    .offline-notification { bottom: calc(104px + env(safe-area-inset-bottom)); }

    .pwa-toast { padding-bottom: 0; }
}

/* ── Responsive: >=768px ───────────────────────────────────── */
@media (min-width: 768px) {
    .container { padding: 0 24px 56px; }

    .app-header { padding: 30px 0 26px; }
    .brand-text h1 { font-size: 1.55rem; }
    .brand-mark { width: 52px; height: 52px; font-size: 1.3rem; border-radius: var(--r-lg); }

    .main-content {
        flex-direction: row;
        align-items: flex-start;
    }

    .content { flex: 1; order: 1; padding: 22px 20px; }
    .sidebar {
        width: 250px;
        flex-shrink: 0;
        order: 2;
        position: sticky;
        top: 20px;
    }

    .template-list { flex-direction: column; flex-wrap: nowrap; }
    .template-item { border-radius: var(--r-sm); white-space: normal; }

    .settings-form {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .settings-form .form-group:first-child { grid-column: 1 / -1; }
    .settings-form fieldset:last-of-type { grid-column: 1 / -1; }
    .form-actions { grid-column: 1 / -1; flex-direction: row; }
    .weather-manual-grid { grid-template-columns: 1fr 1fr; }

    .action-bar .btn { flex: none; min-width: 150px; }

    .upload-area { padding: 40px 24px; }
    .upload-icon { width: 68px; height: 68px; }

    .map-container { height: 240px; }
}

/* ── Reduced motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
