/* PinHere.me — base styles */
:root {
    --bg: #FAFAF8;
    --surface: #FFFFFF;
    --surface-alt: #F3F2EE;
    --text: #1A1A18;
    --text-secondary: #6B6B65;
    --accent: #E8553D;
    --accent-hover: #D14530;
    --accent-light: #FFF0ED;
    --border: #E5E4E0;
    --border-light: #EEEDE9;
    --green: #2D8A56;
    --red: #DC3545;
    --radius: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.03);
    --shadow-md: 0 4px 16px rgba(0,0,0,.06), 0 1px 4px rgba(0,0,0,.04);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Instrument Sans', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, textarea, select {
    font: inherit;
    color: inherit;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    width: 100%;
    outline: none;
    transition: border-color .15s;
}
input:focus, textarea:focus { border-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; margin-top: 12px; font-weight: 500; }
textarea { resize: vertical; min-height: 80px; }
.hidden { display: none !important; }
.muted { color: var(--text-secondary); }
.small { font-size: 13px; }
.accent { color: var(--accent); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px; padding: 10px 18px; border-radius: 100px;
    font-size: 14px; font-weight: 600; transition: all .15s;
    border: 1px solid transparent; white-space: nowrap;
}
.btn-primary { background: var(--text); color: #fff; }
.btn-primary:hover { background: var(--accent); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(232,85,61,.3); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-alt); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b8293a; }
.btn-lg { padding: 14px 28px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.error-box { background: #FFF0F0; color: var(--red); padding: 10px 14px; border-radius: 10px; font-size: 13px; margin: 12px 0; }
.dev-box { background: #FFFAE6; border: 1px dashed #D4A017; padding: 10px; border-radius: 8px; font-size: 12px; word-break: break-all; margin: 12px 0; }

/* Topbar */
.topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 500;
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px;
    background: rgba(250,250,248,.88);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-light);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-pin { width: 28px; height: 28px; background: var(--accent); border-radius: 8px; position: relative; }
.brand-pin::after { content: ''; position: absolute; inset: 50% auto auto 50%; transform: translate(-50%,-50%); width: 9px; height: 9px; background: #fff; border-radius: 50%; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -.3px; }
.brand-name b { color: var(--accent); font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.avatar-link { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 100px; background: var(--surface-alt); font-size: 13px; font-weight: 500; }
.avatar-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }

/* Full-screen map */
#map { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 1; }
.app-body { overflow: hidden; }

/* Hero overlay */
.hero-overlay {
    position: fixed; top: 80px; left: 20px;
    width: 380px; max-width: calc(100vw - 40px);
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 28px;
    z-index: 400;
    transition: transform .3s, opacity .3s;
}
.hero-overlay.collapsed { transform: translateX(calc(-100% - 30px)); opacity: 0; pointer-events: none; }
.hero-overlay h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.5px; margin-bottom: 12px; }
.hero-overlay p { font-size: 15px; color: var(--text-secondary); margin-bottom: 20px; }
.hero-overlay .close-hero { position: absolute; top: 12px; right: 14px; width: 30px; height: 30px; border-radius: 50%; font-size: 22px; color: var(--text-secondary); }
.hero-overlay .close-hero:hover { background: var(--surface-alt); }
.hero-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 20px; }
.hero-stats > div { background: var(--surface-alt); border-radius: 10px; padding: 10px; text-align: center; }
.hero-stats b { display: block; font-size: 18px; font-weight: 700; }
.hero-stats span { display: block; font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .5px; }
.hero-tip { font-size: 12px; color: var(--text-secondary); margin-top: 10px; text-align: center; }

/* Modal */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    animation: fadeIn .2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 480px;
    padding: 28px;
    max-height: 90vh; overflow-y: auto;
}
.modal-pin { max-width: 520px; }
.modal-pin-detail { max-width: 560px; padding: 0; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; padding: 0; }
.modal-pin-detail .modal-head { padding: 20px 24px; border-bottom: 1px solid var(--border-light); }
.modal h2 { font-size: 22px; letter-spacing: -.3px; }
.close-btn { width: 32px; height: 32px; border-radius: 50%; font-size: 22px; color: var(--text-secondary); }
.close-btn:hover { background: var(--surface-alt); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.input-prefix { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.input-prefix:focus-within { border-color: var(--accent); }
.input-prefix span { padding: 10px 12px; background: var(--surface-alt); color: var(--text-secondary); font-size: 13px; border-right: 1px solid var(--border); }
.input-prefix input { border: 0; border-radius: 0; }

/* Pin modal specific */
.pin-location { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--accent-light); border-radius: 10px; margin-bottom: 14px; font-size: 13px; }
.pin-location .loc-dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; flex-shrink: 0; }
.link-btn { color: var(--accent); font-weight: 600; font-size: 13px; margin-left: auto; }
.link-btn:hover { text-decoration: underline; }
.pin-type-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.pin-type-tabs .tab { flex: 1; padding: 10px; border-radius: 10px; background: var(--surface-alt); font-size: 13px; font-weight: 500; transition: all .15s; }
.pin-type-tabs .tab:hover { background: var(--border-light); }
.pin-type-tabs .tab.active { background: var(--text); color: #fff; }
.file-row { margin-top: 10px; display: flex; align-items: center; gap: 10px; }

.visibility-picker { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.vis-opt { display: flex; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: all .15s; }
.vis-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-light); }
.vis-opt input { width: auto; margin-top: 3px; flex-shrink: 0; accent-color: var(--accent); }
.vis-opt b { display: block; font-size: 14px; font-weight: 600; }
.vis-opt span { display: block; font-size: 12px; color: var(--text-secondary); }

/* Pin detail modal body */
#pinDetailBody { padding: 20px 24px; }
#pinDetailBody img { width: 100%; border-radius: 10px; margin-bottom: 12px; max-height: 400px; object-fit: cover; }
#pinDetailBody h3 { font-size: 20px; margin-bottom: 10px; letter-spacing: -.2px; }
#pinDetailBody .detail-body { white-space: pre-wrap; word-wrap: break-word; margin-bottom: 12px; color: var(--text); }
#pinDetailBody .detail-link { display: block; padding: 10px 14px; background: var(--surface-alt); border-radius: 10px; font-size: 13px; word-break: break-all; color: var(--accent); }
#pinDetailBody .locked-info { text-align: center; padding: 20px; }
#pinDetailBody .locked-info .lock-icon { font-size: 48px; margin-bottom: 10px; }
.detail-actions { display: flex; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--border-light); background: var(--surface-alt); }
.detail-author { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.handle-sm { color: var(--text-secondary); }

/* Leaflet popup tweaks */
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: var(--shadow-md); }
.leaflet-popup-content { margin: 14px 16px; font-family: inherit; font-size: 13px; }
.popup-title { font-weight: 600; margin-bottom: 4px; font-size: 14px; }
.popup-meta { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.popup-btn { display: inline-block; margin-top: 6px; padding: 6px 12px; background: var(--text); color: #fff; border-radius: 100px; font-size: 12px; font-weight: 600; }
.popup-btn:hover { background: var(--accent); }
.popup-sealed { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; background: var(--accent-light); color: var(--accent); border-radius: 100px; font-size: 11px; font-weight: 600; }

/* Custom pin icon */
.ph-pin-icon {
    width: 32px; height: 40px;
    background: var(--accent);
    border: 2px solid #fff;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: var(--shadow-md);
    display: flex; align-items: center; justify-content: center;
}
.ph-pin-icon.sealed { background: #555; }
.ph-pin-icon.photo { background: #3B6EC9; }
.ph-pin-icon.link  { background: #7C5CBF; }
.ph-pin-icon.private { background: #D4A017; }
.ph-pin-icon span { transform: rotate(45deg); font-size: 14px; }

/* Auth pages */
.auth-body { background: var(--surface-alt); display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 36px; max-width: 400px; width: 100%; }
.auth-card .brand { margin-bottom: 24px; }
.auth-card h1 { font-size: 24px; letter-spacing: -.3px; margin-bottom: 8px; }
.auth-card > p.muted { margin-bottom: 18px; font-size: 14px; }
.auth-form button { width: 100%; margin-top: 14px; }
.fineprint { font-size: 12px; color: var(--text-secondary); margin-top: 16px; text-align: center; }

/* Profile page */
.profile-body { background: var(--bg); }
.profile-wrap { max-width: 960px; margin: 80px auto 40px; padding: 0 20px; }
.profile-header { text-align: center; padding: 30px 0 20px; }
.profile-avatar {
    width: 80px; height: 80px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #FFA07A);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 26px; letter-spacing: .5px;
    margin: 0 auto 16px;
}
.profile-header h1 { font-size: 28px; letter-spacing: -.3px; }
.profile-header .handle { color: var(--text-secondary); margin: 4px 0 10px; }
.profile-header .bio { max-width: 500px; margin: 10px auto; color: var(--text); font-size: 14px; }
.profile-stats { display: inline-flex; gap: 20px; margin: 10px 0 14px; font-size: 13px; color: var(--text-secondary); }
.profile-stats b { color: var(--text); font-weight: 700; }

#profileMap, #pinMap { width: 100%; height: 320px; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); margin-bottom: 24px; }

.profile-pins h2 { font-size: 18px; margin: 20px 0 12px; }
.pins-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.pin-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; transition: all .15s; display: block; }
.pin-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-light); }
.pin-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.pin-type-badge { font-size: 18px; }
.pin-card-time { font-size: 12px; color: var(--text-secondary); }
.pin-card h3 { font-size: 15px; margin: 6px 0; line-height: 1.3; }
.pin-card p { font-size: 13px; color: var(--text-secondary); line-height: 1.45; }
.pin-card img { width: 100%; border-radius: 8px; margin-bottom: 8px; aspect-ratio: 16/10; object-fit: cover; }
.pin-card-footer { margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.pin-card-sealed { text-align: center; padding: 22px 10px; color: var(--text-secondary); font-size: 13px; background: var(--surface-alt); border-radius: 8px; }

/* Single pin page */
.pin-page-body { background: var(--bg); }
.pin-page { max-width: 1100px; margin: 90px auto 40px; padding: 0 20px; display: grid; grid-template-columns: 1fr 380px; gap: 30px; }
.pin-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 14px; }
.pin-author { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.pin-time { color: var(--text-secondary); }
.pin-article { background: var(--surface); border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-sm); }
.pin-article h1 { font-size: 26px; letter-spacing: -.3px; margin-bottom: 14px; line-height: 1.2; }
.pin-hero-img { width: 100%; border-radius: 12px; margin-bottom: 18px; max-height: 500px; object-fit: cover; }
.pin-body { font-size: 16px; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; margin-bottom: 16px; }
.pin-link { display: inline-block; padding: 10px 16px; background: var(--accent-light); color: var(--accent); border-radius: 10px; font-size: 13px; word-break: break-all; }
.pin-actions { display: flex; gap: 10px; margin-top: 20px; }

.sealed-card { background: var(--surface); border-radius: var(--radius-lg); padding: 40px 28px; text-align: center; box-shadow: var(--shadow-sm); }
.sealed-icon { font-size: 56px; margin-bottom: 14px; }
.sealed-card h1 { font-size: 24px; margin-bottom: 10px; }
.sealed-card p { color: var(--text-secondary); margin-bottom: 18px; }

.pin-page-right .coords { margin-top: 8px; font-family: monospace; text-align: center; }

/* Mobile */
@media (max-width: 760px) {
    .topbar { padding: 10px 14px; }
    .topbar-right .btn-ghost:nth-child(3) { display: none; }
    .hero-overlay { left: 10px; right: 10px; top: 72px; width: auto; padding: 20px; }
    .hero-overlay h1 { font-size: 22px; }
    .pin-page { grid-template-columns: 1fr; }
    .profile-avatar { width: 64px; height: 64px; font-size: 20px; }
    .modal { padding: 20px; }
}
