:root {
    --pink: #ef7393;
    --pink-dark: #df5f82;
    --pink-soft: #fff4f7;
    --ink: #3b2931;
    --muted: #846f78;
    --line: #efdce3;
    --paper: #fffdfd;
    --header-height: 70px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: "Tahoma", "Noto Sans Thai", system-ui, sans-serif;
    color: var(--ink);
    background: #f6f2f3;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.site-frame {
    width: 100%;
    height: 100%;
    background: var(--paper);
}

.site-header {
    height: var(--header-height);
    padding: 0 24px 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 253, 253, .96);
    position: relative;
    z-index: 1000;
}

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

.brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(145deg, #f38cac, #e65d84);
    font-size: 20px;
    box-shadow: 0 8px 20px rgba(235, 106, 144, .18);
}

.brand-copy { display: grid; line-height: 1.1; }
.brand-copy strong { font-size: 18px; letter-spacing: -.3px; }
.brand-copy small { margin-top: 5px; color: var(--muted); font-size: 11px; }

.location-button {
    border: 0;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px;
}

.app-layout {
    height: calc(100% - var(--header-height));
    display: grid;
    grid-template-columns: minmax(0, 1fr) 342px;
}

.map-panel { min-width: 0; position: relative; overflow: hidden; }
#map { width: 100%; height: 100%; background: #f4eee5; }
#map.pin-mode { cursor: crosshair; }
.leaflet-tile-pane { filter: saturate(.63) brightness(1.07) contrast(.92); }
.leaflet-control-attribution { font-size: 10px !important; }

.project-marker-wrap { background: transparent; border: 0; }
.project-marker {
    width: 42px;
    height: 42px;
    border-radius: 50% 50% 50% 10px;
    transform: rotate(-45deg);
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--pink);
    border: 3px solid #fff;
    box-shadow: 0 8px 18px rgba(101, 54, 67, .24);
}
.project-marker span { transform: rotate(45deg); font-size: 19px; font-weight: 700; }

.map-actions {
    position: absolute;
    z-index: 800;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    white-space: nowrap;
}

.action-button, .project-link, .popup-link {
    border: 0;
    border-radius: 999px;
    padding: 11px 18px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    font-weight: 700;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.action-button:hover, .project-link:hover, .popup-link:hover { transform: translateY(-1px); }
.action-button.primary, .project-link, .popup-link {
    color: #fff;
    background: var(--pink);
    box-shadow: 0 8px 18px rgba(233, 102, 139, .2);
}
.action-button.primary:hover, .project-link:hover, .popup-link:hover { background: var(--pink-dark); }
.action-button.secondary { color: #714354; background: rgba(255, 246, 249, .95); border: 1px solid #f0dbe2; }
.action-button.secondary.active { color: #fff; background: var(--pink-dark); }
.action-button.wide { width: 100%; }

.map-message {
    position: absolute;
    z-index: 850;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    padding: 9px 14px;
    border-radius: 999px;
    color: #fff;
    background: rgba(59, 41, 49, .9);
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

.project-sidebar {
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--line);
    background: rgba(255, 250, 251, .96);
}

.sidebar-heading { padding: 16px 18px 14px; border-bottom: 1px solid var(--line); }
.sidebar-heading h1 { margin: 0 0 4px; font-size: 20px; }
.sidebar-heading h1 span { color: var(--pink); }
.sidebar-heading p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.project-list {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 12px 22px;
    scrollbar-width: thin;
    scrollbar-color: #9e989b transparent;
}

.project-card {
    border: 1px solid var(--line);
    border-radius: 30px;
    background: rgba(255, 255, 255, .9);
    margin-bottom: 10px;
    overflow: hidden;
    cursor: pointer;
    outline: none;
    transition: box-shadow .2s ease, border-color .2s ease;
}
.project-card:hover, .project-card:focus-visible, .project-card.expanded {
    border-color: #eab9c8;
    box-shadow: 0 10px 24px rgba(82, 51, 61, .08);
}
.project-summary { min-height: 78px; display: flex; align-items: center; gap: 12px; padding: 10px; }
.project-thumb { width: 80px; height: 56px; flex: 0 0 auto; border-radius: 20px; background: #f3edef; overflow: hidden; display: grid; place-items: center; }
.project-thumb img { width: 100%; height: 100%; display: block; object-fit: contain; }
.project-copy { min-width: 0; flex: 1; }
.project-copy h2 { margin: 0 0 3px; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-copy p { margin: 0 0 4px; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-copy small { display: block; color: #9c7a86; font-size: 10px; }
.expand-icon { color: #a37e8b; margin-right: 5px; transition: transform .2s ease; }
.project-card.expanded .expand-icon { transform: rotate(180deg); }
.project-expanded { max-height: 0; overflow: hidden; padding: 0 14px; opacity: 0; transition: max-height .3s ease, padding .25s ease, opacity .2s ease; }
.project-card.expanded .project-expanded { max-height: 320px; padding: 0 14px 14px; opacity: 1; }
.project-expanded p { margin: 0 0 12px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.project-link { display: block; padding: 9px 14px; font-size: 13px; }
.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); }

.project-popup .leaflet-popup-content-wrapper { border-radius: 17px; padding: 0; box-shadow: 0 14px 34px rgba(54, 35, 42, .2); }
.project-popup .leaflet-popup-content { margin: 0; width: 320px !important; }
.project-popup .leaflet-popup-tip { box-shadow: 4px 4px 8px rgba(54, 35, 42, .12); }
.project-popup .leaflet-popup-close-button { width: 28px; height: 28px; color: #fff !important; z-index: 2; font-size: 22px !important; text-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.map-popup-card { padding: 10px; color: var(--ink); }
.popup-image { width: 300px; height: 169px; border-radius: 13px; overflow: hidden; display: grid; place-items: center; background: #f0e9eb; }
.popup-image img { width: 100%; height: 100%; object-fit: contain; }
.map-popup-card h3 { margin: 12px 0 6px; font-size: 15px; }
.map-popup-card p { min-height: 38px; margin: 0 0 12px; color: var(--muted); font-size: 12px; line-height: 1.55; white-space: pre-line; }
.popup-link { display: block; padding: 9px 14px; }

.pin-dialog { width: min(440px, calc(100% - 24px)); border: 0; border-radius: 24px; padding: 0; box-shadow: 0 24px 80px rgba(58, 35, 43, .25); }
.pin-dialog::backdrop { background: rgba(44, 31, 36, .35); backdrop-filter: blur(2px); }
.pin-form { display: grid; gap: 13px; padding: 20px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; }
.dialog-heading strong, .dialog-heading small { display: block; }
.dialog-heading strong { font-size: 19px; }
.dialog-heading small { margin-top: 4px; color: var(--muted); }
.icon-button { border: 0; background: #f7eef1; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 24px; color: var(--ink); }
.pin-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; }
.pin-form input, .pin-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: #fff; color: var(--ink); outline: none; }
.pin-form input:focus, .pin-form textarea:focus { border-color: var(--pink); box-shadow: 0 0 0 3px rgba(239, 115, 147, .12); }

@media (max-width: 760px) {
    :root { --header-height: 70px; }
    body { padding: 3px; }
    .site-frame { border: 1px solid #ddd6d9; border-radius: 12px; overflow: hidden; }
    .site-header { padding: 0 14px 0 16px; }
    .location-button span:last-child { display: none; }
    .app-layout { display: flex; flex-direction: column; }
    .map-panel { height: 54%; flex: 0 0 54%; }
    .project-sidebar { height: 46%; flex: 0 0 46%; border-left: 0; border-top: 1px solid var(--line); }
    .map-actions { bottom: 12px; gap: 6px; }
    .action-button { padding: 10px 13px; font-size: 13px; }
    .sidebar-heading { padding: 15px 17px 12px; }
    .sidebar-heading h1 { font-size: 19px; }
    .project-list { padding: 10px 13px 20px; }
    .project-card { border-radius: 28px; }
    .project-summary { min-height: 80px; }
    .project-thumb { width: 80px; height: 58px; }
    .project-popup .leaflet-popup-content { width: min(320px, calc(100vw - 44px)) !important; }
    .popup-image { width: 100%; height: auto; aspect-ratio: 300 / 169; }
    .leaflet-control-attribution { max-width: 230px; white-space: normal; text-align: right; }
}

@media (max-width: 380px) {
    .brand-copy strong { font-size: 17px; }
    .brand-copy small { font-size: 10px; }
    .project-marker { width: 39px; height: 39px; }
    .action-button { padding-inline: 11px; }
}
