:root {
    --ink: #211d17;
    --ink-soft: #5f584e;
    --paper: #f5f1ea;
    --card: #fffdf9;
    --line: #ded7cc;
    --gold: #c5841c;
    --gold-dark: #8e5a10;
    --green: #26835c;
    --danger: #a43232;
    --shadow: 0 12px 34px rgba(45, 34, 21, .10);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: Tahoma, "Noto Sans Thai", "Leelawadee UI", sans-serif;
    font-size: 14px;
}

button, input { font: inherit; }

a { color: inherit; }

.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 10px max(20px, calc((100vw - 1540px) / 2));
    background: #211d17;
    color: #fff;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.brand-logo {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--gold);
    font-size: 11px;
    font-weight: 800;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 2px; color: #d7cab7; font-size: 11px; }

.topbar nav { display: flex; align-items: center; gap: 22px; }
.topbar nav a { color: #f8f3ea; text-decoration: none; font-size: 13px; }
.topbar nav a:hover { color: #f2b84f; }

.shell {
    width: min(1540px, calc(100% - 32px));
    margin: 14px auto 20px;
}

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 24px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--gold-dark);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
}

.hero h1 { margin: 0; font-size: clamp(24px, 3vw, 34px); line-height: 1.2; }
.hero-copy { margin: 6px 0 0; color: var(--ink-soft); }

.live-state {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1px solid #d7e7dc;
    border-radius: 999px;
    color: var(--green);
    background: #f1faf5;
    font-size: 12px;
    font-weight: 700;
}

.state-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 4px rgba(38, 131, 92, .12);
}

.live-state[data-state="loading"] { color: #9a6816; background: #fff8e9; border-color: #efddb7; }
.live-state[data-state="error"] { color: var(--danger); background: #fff1f1; border-color: #ecc7c7; }

.coordinate-panel {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto auto auto;
    gap: 10px;
    align-items: end;
    margin-top: 12px;
    padding: 13px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.field-group label {
    display: block;
    margin: 0 0 5px 2px;
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 700;
}

.field-group input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #fff;
    outline: none;
}

.field-group input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(197, 132, 28, .12); }

.button {
    min-height: 42px;
    padding: 0 15px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}

.button-primary { color: #fff; background: var(--ink); }
.button-secondary { color: #fff; background: var(--gold); }
.button-ghost { color: var(--ink); border-color: var(--line); background: #fff; }
.button:hover { filter: brightness(.96); }
.button:disabled { cursor: not-allowed; opacity: .5; }

.coordinate-help {
    grid-column: 1 / -1;
    min-height: 17px;
    margin: 0 2px -2px;
    color: var(--ink-soft);
    font-size: 11px;
}

.coordinate-help.is-error { color: var(--danger); }
.coordinate-help.is-success { color: var(--green); }

.radar-workspace {
    margin-top: 12px;
    overflow: hidden;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.map-wrap { position: relative; }

.radar-map {
    width: 100%;
    height: clamp(470px, 64vh, 740px);
    background: #dfe6df;
}

.leaflet-container { font-family: inherit; }
.leaflet-control-attribution { font-size: 9px; }

.coordinate-popup { min-width: 205px; }
.coordinate-popup strong { display: block; margin-bottom: 5px; }
.coordinate-popup code { display: block; margin-bottom: 9px; color: #5a4c39; }
.coordinate-popup button {
    width: 100%;
    padding: 7px 10px;
    border: 0;
    border-radius: 6px;
    color: #fff;
    background: var(--ink);
    cursor: pointer;
}

.location-marker {
    width: 22px;
    height: 22px;
    border: 4px solid #fff;
    border-radius: 50%;
    background: #2574b8;
    box-shadow: 0 0 0 3px rgba(37, 116, 184, .35), 0 4px 14px rgba(0, 0, 0, .3);
}

.legend {
    position: absolute;
    z-index: 500;
    left: 14px;
    bottom: 14px;
    width: 205px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 9px;
    background: rgba(33, 29, 23, .88);
    color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
    backdrop-filter: blur(5px);
}

.legend-title, .legend-scale { display: flex; justify-content: space-between; gap: 8px; }
.legend-title { margin-bottom: 7px; font-size: 11px; }
.legend-title span { color: #d7cab7; }
.legend-bar {
    height: 8px;
    border-radius: 99px;
    background: linear-gradient(90deg, #75b8ff 0%, #1684e2 24%, #3cd18a 45%, #f2dd45 65%, #ff8536 82%, #dc2e45 100%);
}
.legend-scale { margin-top: 5px; color: #eee5da; font-size: 9px; }

.map-note {
    position: absolute;
    z-index: 500;
    right: 14px;
    bottom: 14px;
    padding: 7px 10px;
    border-radius: 7px;
    color: #fff;
    background: rgba(33, 29, 23, .82);
    font-size: 10px;
}

.timeline-card { padding: 16px 18px 14px; border-top: 1px solid var(--line); }

.timeline-heading {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 13px;
}

.timeline-heading .label, .updated-at span { display: block; color: var(--ink-soft); font-size: 10px; }
.timeline-heading strong { display: block; margin-top: 3px; font-size: 16px; }
.updated-at { text-align: right; }
.updated-at strong { font-size: 12px; }

.timeline-controls {
    display: grid;
    grid-template-columns: 38px 82px 38px minmax(170px, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.icon-button, .play-button, .button-latest {
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--ink);
    background: #fff;
    cursor: pointer;
}

.icon-button { font-size: 25px; line-height: 1; }
.play-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: var(--ink); color: #fff; font-weight: 700; }
.button-latest { min-height: 38px; padding: 0 14px; background: #fff5df; border-color: #e7c98e; color: #7b4d0b; }
.icon-button:disabled, .play-button:disabled { cursor: not-allowed; opacity: .45; }

input[type="range"] { accent-color: var(--gold); }
.timeline-range { width: 100%; }

.secondary-controls {
    display: grid;
    grid-template-columns: auto minmax(120px, 260px) 1fr;
    gap: 11px;
    align-items: center;
    margin-top: 11px;
    color: var(--ink-soft);
    font-size: 11px;
}

.secondary-controls label strong { color: var(--ink); }
.text-button { justify-self: end; padding: 4px 0; border: 0; color: var(--gold-dark); background: transparent; cursor: pointer; font-weight: 700; }

.error-panel {
    margin-top: 12px;
    padding: 11px 12px;
    border: 1px solid #e8c6c6;
    border-radius: 8px;
    color: #7f2929;
    background: #fff2f2;
}
.error-panel strong, .error-panel span { margin-right: 8px; }
.error-panel button { padding: 5px 9px; border: 1px solid #dba9a9; border-radius: 6px; color: inherit; background: #fff; cursor: pointer; }

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.info-grid article {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 15px 16px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--card);
}

.info-icon {
    flex: 0 0 auto;
    width: 31px;
    height: 31px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: #fff;
    background: var(--gold);
    font-weight: 800;
}

.info-grid strong { font-size: 13px; }
.info-grid p { margin: 4px 0 0; color: var(--ink-soft); font-size: 11px; line-height: 1.55; }

footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 22px;
    padding: 13px 18px 18px;
    color: #6f675c;
    font-size: 10px;
}
footer a { color: var(--gold-dark); }

@media (max-width: 920px) {
    .coordinate-panel { grid-template-columns: 1fr 1fr; }
    .coordinate-panel .button { width: 100%; }
    .info-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
    .topbar { align-items: flex-start; padding: 10px 14px; }
    .topbar nav { gap: 12px; padding-top: 9px; }
    .topbar nav a:nth-child(3) { display: none; }
    .brand small { display: none; }
    .shell { width: min(100% - 16px, 1540px); margin-top: 8px; }
    .hero { align-items: flex-start; padding: 15px; }
    .hero-copy { font-size: 12px; }
    .live-state { padding: 7px 9px; }
    #radarStateText { display: none; }
    .coordinate-panel { grid-template-columns: 1fr 1fr; padding: 10px; }
    .coordinate-panel .button { padding: 0 8px; font-size: 12px; }
    #resetThailand { grid-column: 1 / -1; }
    .radar-map { height: 60vh; min-height: 430px; }
    .legend { left: 9px; bottom: 9px; width: 180px; }
    .map-note { top: 9px; right: 9px; bottom: auto; max-width: 180px; text-align: right; }
    .timeline-card { padding: 13px 10px; }
    .timeline-controls { grid-template-columns: 34px 70px 34px 1fr; }
    .timeline-range { grid-column: 1 / -1; grid-row: 2; }
    .button-latest { grid-column: 4; grid-row: 1; }
    .secondary-controls { grid-template-columns: auto 1fr; }
    .text-button { grid-column: 1 / -1; justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
/* =========================================================
   CM77 LANNA BROWN THEME — WEATHER RADAR
   ========================================================= */

:root {
    --ink: #fff4df;
    --ink-soft: #d9bd96;
    --paper: #b88950;
    --card: #5a290d;
    --line: #8a5727;
    --gold: #d6a52e;
    --gold-dark: #f0c65b;
    --green: #42ad72;
    --danger: #df5353;
    --shadow: 0 12px 34px rgba(55, 24, 5, .22);
}

body {
    color: var(--ink);
    background: #b88950;
}

/* แถบหัวเว็บ */
.topbar {
    background: linear-gradient(90deg, #3e1a07, #642d0d);
    border-bottom: 2px solid #d6a52e;
    box-shadow: 0 3px 14px rgba(48, 20, 4, .28);
}

.brand-logo {
    color: #351a08;
    background: #d6a52e;
}

/* กล่องหัวเรื่อง */
.hero {
    background: linear-gradient(135deg, #512207, #71350f);
    border-color: #95602c;
}

.hero h1 {
    color: #fff4df;
}

.hero-copy {
    color: #d9bd96;
}

.eyebrow {
    color: #e2b854;
}

/* ช่องระบุพิกัด */
.coordinate-panel {
    background: #672f0d;
    border-color: #98632d;
    box-shadow: var(--shadow);
}

.field-group label,
.coordinate-help {
    color: #d9bd96;
}

.field-group input {
    color: #351a08;
    background: #fff8ea;
    border-color: #a8763c;
}

.field-group input:focus {
    border-color: #d6a52e;
    box-shadow: 0 0 0 3px rgba(214, 165, 46, .22);
}

/* ปุ่ม */
.button-primary {
    color: #fff4df;
    background: #472008;
    border-color: #805020;
}

.button-secondary {
    color: #351a08;
    background: #d6a52e;
    border-color: #ecc968;
}

.button-ghost {
    color: #351a08;
    background: #fff8ea;
    border-color: #a8763c;
}

/* พื้นที่แผนที่ */
.radar-workspace {
    background: #57260a;
    border-color: #895727;
}

/*
 ห้ามกำหนด filter หรือ opacity ให้ .radar-map
 เพื่อรักษาสีภาพเรดาร์และแผนที่เดิม
*/

/* แถบควบคุมเวลา */
.timeline-card {
    color: #fff4df;
    background: #57260a;
    border-top-color: #895727;
}

.timeline-heading .label,
.updated-at span,
.secondary-controls {
    color: #d9bd96;
}

.timeline-heading strong,
.updated-at strong,
.secondary-controls label strong {
    color: #fff4df;
}

.icon-button,
.button-latest {
    color: #351a08;
    background: #fff8ea;
    border-color: #a8763c;
}

.play-button {
    color: #fff4df;
    background: #472008;
    border-color: #805020;
}

.button-latest {
    color: #4b2d16;
    background: #e5bd73;
    border-color: #d6a52e;
}

.text-button {
    color: #f0c65b;
}

/* การ์ดข้อมูลด้านล่าง */
.info-grid article {
    color: #fff4df;
    background: linear-gradient(145deg, #59270b, #6a310e);
    border-color: #8a5727;
    box-shadow: 0 4px 13px rgba(58, 25, 5, .18);
}

.info-icon {
    color: #351a08;
    background: #d6a52e;
}

.info-grid p {
    color: #d9bd96;
}

/* Popup บนแผนที่ต้องเป็นพื้นสว่างเพื่อให้อ่านง่าย */
.coordinate-popup {
    color: #351a08;
}

.coordinate-popup code {
    color: #5a4c39;
}

.coordinate-popup button {
    color: #fff4df;
    background: #472008;
}

/* ส่วนท้าย */
footer {
    color: #543116;
}

footer a {
    color: #5a290d;
    font-weight: 700;
}