/* MikeOS flagship visual standard (matches osmike-web / earnmoney-web): warm cream ground,
   near-black ink, Fraunces serif display + Manrope sans, orange→pink→purple gradient accent,
   editorial rounded cards. Fonts self-hosted (CSP-safe). */
@font-face { font-family: "Fraunces"; font-weight: 300 600; font-display: swap; src: url("/fonts/fraunces.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-weight: 400 700; font-display: swap; src: url("/fonts/manrope.woff2") format("woff2"); }
:root {
  --bg: #FBFAF7;          /* warm cream page */
  --surface: #FFFFFF;     /* cards, sidebar, inputs */
  --surface2: #F4EEE4;    /* raised warm tint / hover */
  --line: #ECE6DC;
  --text: #17130E;        /* ink */
  --muted: #6C6458;       /* ink-dim */
  --accent: #7C7CFF;      /* gradient's cool end — solid accents */
  --gold: #C2591F;        /* warm accent (money), readable on cream */
  --green: #1A8F5A;       /* ok / earnings */
  --g1: #FF8A5B; --g2: #FF6FA5; --g3: #7C7CFF;
  --grad: linear-gradient(100deg, var(--g1), var(--g2) 42%, var(--g3) 82%);
  --radius: 22px; --radius-sm: 14px;
  --disp: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sidebar-w: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
/* Serif display for headings + hero numbers (the MikeOS editorial voice) */
.brand-name, .view-title, .login-card h1, .earn-hero .big, .earn-stat .n, .e-stat .n { font-family: var(--disp); }

/* Login */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; }
.login-card { text-align: center; max-width: 340px; }
.login-card .logo { font-size: 56px; }
.login-card h1 { margin: 8px 0 4px; font-size: 30px; }
.login-card p { color: var(--muted); margin: 0 0 24px; }
.btn { display: inline-block; background: var(--text); color: var(--bg); text-decoration: none;
  padding: 13px 28px; border-radius: 26px; font-weight: 600; border: none; cursor: pointer;
  box-shadow: 0 10px 30px rgba(23,19,14,.18); }
.btn:hover { filter: brightness(1.12); box-shadow: 0 12px 34px rgba(23,19,14,.24); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--line);
  padding: 11px 22px; border-radius: 22px; font-weight: 600; cursor: pointer; }
.btn-outline:hover { background: var(--surface2); }

/* App shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); position: sticky; top: 0;
  height: 100vh; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; padding: 8px 10px 18px; }
.brand-logo { font-size: 24px; } .brand-name { font-weight: 700; font-size: 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: transparent; border: none; color: var(--text); padding: 11px 12px; border-radius: 10px;
  font-size: 15px; cursor: pointer; position: relative; }
.nav-item .ni { font-size: 18px; width: 22px; text-align: center; }
.nav-item:hover { background: var(--surface2); }
.nav-item.active { background: var(--surface2); font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; left: 1px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 3px; background: var(--grad); }
.nav-item.earn.active, .nav-item.earn:hover { color: var(--gold); }
.badge { margin-left: auto; background: var(--gold); color: #241a00; font-size: 12px; font-weight: 700;
  padding: 1px 8px; border-radius: 10px; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.view { display: flex; flex-direction: column; flex: 1; }

/* Top bar (per view) */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; gap: 10px; align-items: center;
  padding: 12px 16px; background: linear-gradient(var(--bg), rgba(251,250,247,.85)); backdrop-filter: blur(8px); }
.hamburger { display: none; }
.view-title { margin: 0; font-size: 20px; }
.search { flex: 1; }
.search input { width: 100%; background: var(--surface); border: 1px solid var(--line); color: var(--text);
  padding: 12px 16px; border-radius: 24px; font-size: 15px; outline: none; }
.search input:focus { border-color: var(--line-2, #DDD4C6); }
.search input::placeholder { color: var(--muted); }
.icon-btn { background: var(--surface); border: 1px solid var(--line); color: var(--text); width: 44px; height: 44px;
  border-radius: 22px; font-size: 18px; cursor: pointer; }
.icon-btn:hover { background: var(--surface2); }

/* Years jump bar */
.years { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 16px 12px; }
.years button { background: var(--surface); border: none; color: var(--text); padding: 8px 14px;
  border-radius: 16px; cursor: pointer; font-size: 14px; }
.years button:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.years button { border: 1px solid var(--line); }
.years button small { color: var(--muted); margin-left: 6px; }

.status { color: var(--muted); font-size: 13px; padding: 0 18px 6px; }

/* Filter chips (place + year, composable) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 16px 10px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--surface2);
  border: 1px solid var(--line); color: var(--text); padding: 6px 10px 6px 12px; border-radius: 16px; font-size: 14px; }
.chip b { font-weight: 600; }
.chip .x { cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 2px; }
.chip .x:hover { color: #fff; }

/* Viewer info panel (AI summary / tags / products) */
:root { --info-w: 380px; }
.v-info-btn { position: absolute; top: 16px; right: 70px; z-index: 62; width: 44px; height: 44px;
  border: none; border-radius: 50%; background: rgba(30,33,40,.6); color: #fff; font-size: 20px;
  cursor: pointer; backdrop-filter: blur(6px); }
.v-info-btn:hover { background: rgba(60,66,78,.8); }

/* Details as a RIGHT sidebar — the image is never overshadowed; it shrinks to the left. */
.v-info { position: absolute; top: 0; right: 0; bottom: 0; width: var(--info-w); z-index: 61;
  display: flex; flex-direction: column; background: var(--surface);
  border-left: 1px solid var(--line); transform: translateX(100%); transition: transform .22s ease; }
.v-info.open { transform: translateX(0); }
.v-info-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 10px;
  font-weight: 600; font-size: 15px; border-bottom: 1px solid var(--line); }
.v-info-close { background: var(--surface2); border: none; color: var(--text); width: 32px; height: 32px;
  border-radius: 16px; cursor: pointer; font-size: 15px; }
.v-info-close:hover { background: var(--line); }
#vinfoBody { overflow-y: auto; padding: 16px 20px 26px; }
/* keep the top-right buttons and the next-arrow to the LEFT of the open panel */
.viewer.info-open .v-close { right: calc(var(--info-w) + 16px); }
.viewer.info-open .v-info-btn { display: none; }
.viewer.info-open .v-next { right: calc(var(--info-w) + 12px); }
.v-info h3 { margin: 0 0 4px; font-size: 15px; }
.v-info .i-summary { font-size: 15px; line-height: 1.5; margin: 0 0 14px; }
.v-info .i-meta { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.v-info .i-sec { margin: 0 0 14px; }
.v-info .i-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin: 0 0 6px; }
.v-info .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.v-info .tag { background: var(--surface2); border: 1px solid var(--line); padding: 4px 10px; border-radius: 12px; font-size: 13px; }
.v-info .product { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.v-info .product .price { color: var(--gold); font-weight: 600; white-space: nowrap; }
.v-info .i-ocr { white-space: pre-wrap; font-size: 13px; color: var(--muted); background: var(--surface2); padding: 10px; border-radius: 8px; max-height: 160px; overflow-y: auto; }
.v-info .i-empty { color: var(--muted); font-size: 14px; }
.viewer.info-open .v-cap { right: var(--info-w); left: 0; }

/* Narrow screens: a right sidebar would be too cramped → fall back to a bottom sheet. */
@media (max-width: 640px) {
  .v-info { top: auto; left: 0; width: auto; height: 58%; border-left: none; border-top: 1px solid var(--line);
    transform: translateY(100%); }
  .v-info.open { transform: translateY(0); }
  .viewer.info-open .v-stage { right: 0; bottom: 58%; }
  .viewer.info-open .v-close { right: 16px; }
  .viewer.info-open .v-next { right: 12px; }
  .viewer.info-open .v-cap { display: none; }
}
.placeholder { color: var(--muted); padding: 48px 24px; text-align: center; }

/* Map */
.map { flex: 1 1 auto; min-height: 0; width: 100%; background: var(--surface); }
.map-count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.maplibregl-popup-content { background: var(--surface); padding: 6px; border-radius: 12px; box-shadow: 0 8px 28px rgba(23,19,14,.22); }
.maplibregl-popup-content img { width: 220px; display: block; cursor: pointer; border-radius: 8px; }
.maplibregl-popup-close-button { color: var(--muted); font-size: 18px; padding: 0 6px; }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--surface); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--surface); }
#view-map { height: 100vh; }

/* Album bar (when a sellable album is opened in the grid) */
.album-bar { display: flex; align-items: center; gap: 12px; padding: 8px 16px 12px; }
.album-bar .a-title { font-weight: 600; }
.album-bar .a-back { cursor: pointer; color: var(--accent); background: none; border: none; font-size: 14px; }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 3px; padding: 0 3px 60px; }
.grid .tile { position: relative; aspect-ratio: 1/1; background: var(--surface); overflow: hidden; cursor: pointer; }
.grid .tile img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s; }
.grid .tile img.loaded { opacity: 1; }
.grid .tile .vbadge { position: absolute; right: 6px; bottom: 6px; font-size: 15px; filter: drop-shadow(0 1px 2px #000); }
.sentinel { height: 40px; }

/* Fast-scroll date scrubber (right edge) */
.scrubber { position: fixed; top: 76px; right: 0; bottom: 22px; width: 62px; z-index: 25;
  opacity: 0; pointer-events: none; transition: opacity .18s ease; }
.scrubber.show { opacity: 1; pointer-events: auto; }
.scrub-track { position: relative; height: 100%; }
.scrub-labels { position: absolute; inset: 0; pointer-events: none; }
.scrub-year { position: absolute; right: 40px; transform: translateY(-50%); font-size: 11px;
  font-weight: 700; color: var(--muted); background: rgba(251,250,247,.7); padding: 0 4px;
  border-radius: 5px; pointer-events: auto; cursor: pointer; white-space: nowrap; }
.scrub-year:hover { color: var(--text); }
.scrub-thumb { position: absolute; right: 8px; top: 0; width: 34px; height: 34px; margin-top: -17px;
  border-radius: 17px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(23,19,14,.18); cursor: grab; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--text); touch-action: none; user-select: none; }
.scrub-thumb:active { cursor: grabbing; }
.scrub-bubble { position: fixed; right: 66px; transform: translateY(-50%); background: var(--text);
  color: var(--bg); font-family: var(--disp); font-size: 17px; padding: 8px 16px; border-radius: 14px;
  box-shadow: 0 8px 26px rgba(23,19,14,.28); white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity .12s ease; }
.scrub-bubble.show { opacity: 1; }
@media (max-width: 640px) { .scrubber { top: 68px; width: 56px; } }

/* ── Earn Money ─────────────────────────────────────────────────────── */
.earn-body { padding: 8px 20px 80px; max-width: 1100px; }
.earn-hero { background: linear-gradient(100deg, rgba(255,138,91,.16), rgba(255,111,165,.12) 45%, rgba(124,124,255,.14) 85%);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 26px; margin-bottom: 8px; }
.earn-hero .big { font-size: 32px; font-weight: 600; line-height: 1.2; }
.earn-hero .big b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.earn-hero .sub { color: var(--muted); margin-top: 8px; font-size: 15px; max-width: 64ch; }
.earn-hero .progress { margin-top: 12px; font-size: 13px; color: var(--muted); }
.earn-stats { display: flex; gap: 26px; margin: 18px 2px 22px; flex-wrap: wrap; }
.earn-stat .n { font-size: 24px; font-weight: 700; }
.earn-stat .n.gold { color: var(--gold); }
.earn-stat .l { color: var(--muted); font-size: 13px; }
.earn-section-title { font-size: 15px; color: var(--muted); margin: 6px 2px 12px; text-transform: uppercase; letter-spacing: .04em; }

.album-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.album-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.album-card .cover { aspect-ratio: 4/3; background: var(--surface2); cursor: pointer; position: relative; }
.album-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-card .cover .cnt { position: absolute; left: 10px; bottom: 10px; background: rgba(0,0,0,.55);
  padding: 3px 10px; border-radius: 12px; font-size: 13px; backdrop-filter: blur(4px); }
.album-card .body { padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.album-card .name { font-weight: 600; }
.album-card .enabled-note { color: var(--green); font-size: 12px; margin-top: 2px; }
.album-card .enabled-note.off { color: var(--muted); }

/* toggle switch */
.switch { position: relative; width: 46px; height: 26px; flex: 0 0 46px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--surface2); border: 1px solid var(--line);
  border-radius: 20px; cursor: pointer; transition: .18s; }
.switch .slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .18s; }
.switch input:checked + .slider { background: var(--green); border-color: var(--green); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* Earnings card */
.earn-earnings { margin: 14px 0 4px; }
.earnings-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.earnings-card.muted { color: var(--muted); font-size: 14px; }
.earnings-card a { color: var(--accent); }
.earnings-grid { display: flex; gap: 32px; flex-wrap: wrap; }
.e-stat .n { font-size: 22px; font-weight: 700; }
.e-stat .n.green { color: var(--green); }
.e-stat .l { color: var(--muted); font-size: 12px; }
.earnings-foot { color: var(--muted); font-size: 12px; margin-top: 12px; }

.earn-note { color: var(--muted); font-size: 13px; margin-top: 22px; line-height: 1.5; }
.earn-empty { color: var(--muted); padding: 40px 4px; }

/* Settings */
.settings { padding: 20px; display: flex; flex-direction: column; gap: 16px; align-items: flex-start; }

/* Viewer — fill the whole viewport; the image always fits inside it (contain) */
.viewer { position: fixed; inset: 0; z-index: 60; background: #000; touch-action: none; }
.v-stage { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; align-items: center;
  justify-content: center; overflow: hidden; transition: right .22s ease, bottom .22s ease; }
.v-stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
  user-select: none; -webkit-user-drag: none; transform-origin: center center; transition: transform .05s linear; }
/* When the details panel is open, the image reflows into the space left of it (never covered). */
.viewer.info-open .v-stage { right: var(--info-w); }
.v-close, .v-nav { position: absolute; z-index: 61; background: rgba(30,33,40,.6); color: #fff;
  border: none; cursor: pointer; border-radius: 50%; backdrop-filter: blur(6px); }
.v-close { top: 16px; right: 16px; width: 44px; height: 44px; font-size: 20px; }
.v-nav { top: 50%; transform: translateY(-50%); width: 52px; height: 52px; font-size: 30px; line-height: 1; }
.v-prev { left: 12px; } .v-next { right: 12px; }
.v-nav:hover, .v-close:hover { background: rgba(60,66,78,.8); }
.v-cap { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; color: #cfd4de;
  font-size: 13px; pointer-events: none; text-shadow: 0 1px 3px #000; }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 39; }

/* Drag-&-drop upload overlay */
.dropzone { position: fixed; inset: 0; z-index: 80; display: none; place-items: center;
  background: rgba(251,250,247,.82); backdrop-filter: blur(4px); }
.dropzone.show { display: grid; }
.dz-inner { pointer-events: none; text-align: center; font-family: var(--disp); font-size: 30px;
  color: var(--text); border: 3px dashed var(--g3); border-radius: var(--radius); padding: 48px 64px;
  line-height: 1.5; background: rgba(255,255,255,.6); }
/* Upload progress toast */
.upload-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 82;
  background: var(--text); color: var(--bg); padding: 12px 22px; border-radius: 22px; font-weight: 600;
  font-size: 14px; box-shadow: 0 10px 30px rgba(23,19,14,.28); }

/* ── Mobile: sidebar becomes an off-canvas drawer + hamburger ────────── */
@media (max-width: 780px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.5); }
  .shell.menu-open .sidebar { transform: translateX(0); }
  .hamburger { display: inline-flex; align-items: center; justify-content: center; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .v-nav { width: 44px; height: 44px; font-size: 24px; }
  .earn-hero .big { font-size: 24px; }
}
@media (min-width: 781px) { .scrim { display: none !important; } }
