:root {
  color-scheme: dark;
  --bg: #070b08;
  --panel: rgba(13, 20, 15, 0.96);
  --panel-soft: rgba(255,255,255,.035);
  --line: rgba(255,255,255,.08);
  --text: #f1f5f1;
  --muted: #89968d;
  --accent: #a7e279;
  --accent-2: #78c79b;
  --exterior: #f4b963;
  --interior: #94dc70;
  --danger: #f08079;
  --shadow: 0 22px 65px rgba(0,0,0,.36);
  --radius: 18px;
}

.theme-control { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; flex-wrap: wrap; }
.theme-control .label { margin: 0; }
.theme-toggle { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text); cursor: pointer; flex-shrink: 0; }
.theme-toggle:hover { background: var(--panel-soft); }

/* Light palette keeps map imagery and marker colors unchanged. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6ef;
  --panel: #ffffff;
  --panel-soft: #f8faf6;
  --line: #ccd6c8;
  --text: #1b2c20;
  --muted: #526451;
  --accent: #286537;
  --accent-2: #32794c;
  --danger: #a32c27;
  --shadow: 0 10px 35px rgba(28, 50, 24, .08);
}
html[data-theme="light"] :is(.sidebar, .details-panel, .topbar, .map-card, .dialog-card, .mobile-nav) { background: var(--panel); }
html[data-theme="light"] :is(.label, .section-subtitle, .counter-name span, .toolbar-hint, .sidebar-footer, .privacy-link, .map-placeholder-copy p, .login-benefits, .pill) { color: var(--muted); }
html[data-theme="light"] :is(.toggle-row, .empty-state h3) { color: var(--text); }
html[data-theme="light"] :is(.control, .counter-value) { background: #fff; border-color: var(--line); color: var(--text); }
html[data-theme="light"] :is(input, textarea)::placeholder { color: #62745f; }
html[data-theme="light"] :is(.control:focus, .counter-value:focus-visible) { border-color: var(--accent); }
html[data-theme="light"] :is(button, a, select, input, textarea):focus-visible { outline-color: var(--accent); }
html[data-theme="light"] .counter-row { background: #fff; }
html[data-theme="light"] .counter-row.featured { background: #eaf3e3; border-color: #a9c69d; }
html[data-theme="light"] :is(.stepper button, .icon-button, .button, .segmented, .pill) { background: #edf2e9; border-color: var(--line); color: var(--text); }
html[data-theme="light"] .button.secondary { background: #e6f0e0; border-color: #b8d0ad; color: #25572c; }
html[data-theme="light"] :is(.button.primary, .mobile-map-controls [aria-pressed="true"]) { background: var(--accent); color: #fff; }
html[data-theme="light"] .button.danger { background: #fff0ee; border-color: #e8b9b5; color: #962820; }
html[data-theme="light"] .stepper button:hover { background: #dcead5; border-color: #8fab83; }
html[data-theme="light"] .segment { color: var(--muted); }
html[data-theme="light"] .segment.active { background: #dcebd4; color: #214b28; }
html[data-theme="light"] :is(.status-badge, .map-badge-label) { background: #e5f0dd; border-color: #bad0ae; color: #30572b; }
html[data-theme="light"] .switch { background: #d0d8cc; }
html[data-theme="light"] .toggle-row { border-color: var(--line); }
html[data-theme="light"] .map-viewport { background: radial-gradient(circle at 50% 35%, #f3f6ef, #dce6d5 82%); }
html[data-theme="light"] .map-surface { background: #e8eee3; }
html[data-theme="light"] .map-placeholder { background: linear-gradient(#ccd8c5 1px, transparent 1px), linear-gradient(90deg, #ccd8c5 1px, transparent 1px), #eaf0e4; background-size: 42px 42px; }
html[data-theme="light"] .google-button { background: #fff; color: #202124; }
html[data-theme="light"] .sidebar-scroll::-webkit-scrollbar-thumb { background: #bac8b3; }

* { box-sizing: border-box; }
/* Let long pages size the background to the document, not one viewport. */
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 70% -15%, rgba(128, 189, 99, .12), transparent 35%),
    radial-gradient(circle at -10% 110%, rgba(52, 119, 87, .10), transparent 38%),
    var(--bg);
  background-repeat: no-repeat;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}
button, select, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid rgba(167,226,121,.75); outline-offset: 2px; }

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 310px;
  gap: 12px;
  padding: 12px;
}

.sidebar, .details-panel {
  min-width: 0;
  background: linear-gradient(180deg, rgba(17, 26, 19, .98), rgba(9, 14, 11, .98));
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.sidebar { display: flex; flex-direction: column; overflow: hidden; }
.workspace { min-width: 0; display: grid; grid-template-rows: auto minmax(0,1fr); gap: 12px; }

.brand { display: flex; gap: 12px; align-items: center; padding: 19px 18px 15px; border-bottom: 1px solid var(--line); }
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  overflow: hidden;
  flex: 0 0 44px;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 18px; letter-spacing: -.025em; }
h2 { font-size: 16px; letter-spacing: -.02em; }
h3 { font-size: 15px; }
.brand-description { margin-top: 4px; font-size: 10px; line-height: 1.5; color: var(--muted); }
.eyebrow { color: var(--muted); font-size: 9px; letter-spacing: .15em; text-transform: uppercase; font-weight: 850; }

.sidebar-scroll { overflow: auto; padding: 12px; }
.sidebar-scroll::-webkit-scrollbar { width: 7px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 20px; }
.panel { padding: 14px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.label { display: block; color: #abb6ae; font-size: 11px; font-weight: 760; margin-bottom: 6px; }
.top-gap { margin-top: 12px; }
.control {
  width: 100%; color: var(--text); background: #09100c; border: 1px solid rgba(255,255,255,.09);
  border-radius: 12px; padding: 10px 11px; outline: none; transition: .16s ease;
}
.control:focus { border-color: rgba(167,226,121,.55); box-shadow: 0 0 0 3px rgba(167,226,121,.07); }
select.control { cursor: pointer; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-heading h2 { margin-top: 3px; font-size: 14px; }
.section-subtitle { color: #66736b; font-size: 9px; margin-top: 4px; }

.toggle-row {
  position: relative; min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  color: #c6cec8; font-size: 12px; cursor: pointer; border-top: 1px solid rgba(255,255,255,.045);
}
.toggle-row:first-of-type { border-top: 0; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 36px; height: 20px; border-radius: 999px; background: #273029; position: relative; transition: .16s ease; flex: none; }
.switch::after { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: #7d8880; transition: .16s ease; }
.toggle-row input:checked + .switch { background: rgba(148,220,112,.25); }
.toggle-row input:checked + .switch::after { transform: translateX(16px); background: var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.exterior-dot { background: var(--exterior); box-shadow: 0 0 0 3px color-mix(in srgb, var(--exterior) 12%, transparent); }
.interior-dot { background: var(--interior); box-shadow: 0 0 0 3px color-mix(in srgb, var(--interior) 12%, transparent); }

.counter-list { display: grid; gap: 7px; }
.counter-row {
  display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; align-items: center;
  min-height: 55px; padding: 8px 9px 8px 11px; border: 1px solid var(--line); border-radius: 13px;
  background: linear-gradient(180deg, rgba(255,255,255,.028), rgba(255,255,255,.012));
}
.counter-row.featured { border-color: rgba(167,226,121,.13); background: linear-gradient(155deg, rgba(167,226,121,.09), rgba(255,255,255,.012)); }
.counter-name { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.counter-name span { color: #aab6ae; font-size: 11px; font-weight: 720; }
.counter-value { width: 120px; min-width: 0; max-width: 55%; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: rgba(0,0,0,.15); color: inherit; font: inherit; font-size: 22px; font-weight: 700; text-align: right; }
.counter-value:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.counter-value { -moz-appearance: textfield; appearance: textfield; }
.counter-value::-webkit-inner-spin-button,
.counter-value::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper { display: inline-grid; grid-template-columns: 30px 30px; gap: 4px; }
.stepper button {
  width: 30px; height: 32px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255,255,255,.035);
  color: #dce5df; cursor: pointer; font-size: 17px; line-height: 1; transition: .14s ease;
}
.stepper button:hover { background: rgba(167,226,121,.1); border-color: rgba(167,226,121,.22); transform: translateY(-1px); }

.button-stack { display: grid; gap: 8px; margin-top: 10px; }
.button {
  border: 1px solid transparent; border-radius: 12px; min-height: 38px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; text-decoration: none;
  color: var(--text); cursor: pointer; background: #151d17; transition: .15s ease; font-weight: 720; font-size: 11px;
}
.button:hover { transform: translateY(-1px); }
.button.primary { color: #10180f; background: var(--accent); }
.button.secondary { background: rgba(167,226,121,.08); border-color: rgba(167,226,121,.16); color: #cef0bc; }
.button.ghost { background: rgba(255,255,255,.032); border-color: var(--line); }
.button.danger { background: rgba(240,128,121,.07); border-color: rgba(240,128,121,.16); color: #ffc2bd; }
.button.disabled { opacity: .35; pointer-events: none; }
.icon-button { width: 30px; height: 30px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.03); color: var(--muted); cursor: pointer; }
.small-button { min-height: 34px; }
.muted { color: var(--muted); }
.small { font-size: 10px; line-height: 1.5; }
.status-badge { display: inline-flex; align-items: center; min-height: 21px; padding: 0 7px; border-radius: 999px; border: 1px solid rgba(167,226,121,.14); background: rgba(167,226,121,.07); color: #c6e9b5; font-size: 8px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.status-badge.custom { border-color: rgba(120,199,155,.18); background: rgba(120,199,155,.08); color: #a9dfc3; }
.sidebar-footer { color: #626f67; font-size: 9px; line-height: 1.5; padding: 12px 18px 15px; border-top: 1px solid var(--line); }
.support-contact { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; color: var(--text); font-size: 11px; }
.support-contact a { color: var(--accent); text-underline-offset: 3px; }
.support-contact a:hover { text-decoration-thickness: 2px; }
.privacy-link { margin-top: 8px; padding: 0; border: 0; background: transparent; color: #89968d; font-size: 9px; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.companion-intro h2 { font-size: 13px; }
.companion-intro p { margin-top: 8px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.companion-intro a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); font-size: 12px; text-underline-offset: 3px; }

/* Public getting-started guide */
body.guide-page { height: auto; min-height: 100%; overflow: auto; }
.guide-shell { width: min(920px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 40px; }
.guide-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
.guide-brand { display: flex; align-items: center; gap: 12px; color: var(--text); font-size: 18px; font-weight: 750; text-decoration: none; }
.guide-brand img { width: 44px; height: 44px; border-radius: 14px; }
.guide-brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 500; }
.guide-actions { display: flex; align-items: center; gap: 10px; }
.guide-breadcrumb { margin-bottom: 16px; color: var(--muted); font-size: 12px; }
.guide-page a:not(.button, .guide-brand) { color: var(--accent); text-underline-offset: 3px; }
.guide-article { padding: clamp(20px, 5vw, 44px); border: 1px solid var(--line); border-radius: 22px; background: var(--panel); }
.guide-article h1 { font-size: clamp(28px, 5vw, 40px); line-height: 1.2; }
.guide-article h2 { margin-top: 32px; font-size: 21px; line-height: 1.4; }
.guide-article h3 { margin-top: 22px; font-size: 16px; }
.guide-article p, .guide-article li { margin-top: 12px; font-size: 15px; line-height: 1.75; }
.guide-article .guide-lead { font-size: 17px; color: var(--muted); }
.guide-article ul { padding-left: 22px; }
.guide-article .guide-cta { margin-top: 28px; font-size: 14px; min-height: 44px; }
.guide-footer { margin-top: 24px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.guide-footer .privacy-link { color: var(--muted); font-size: 11px; min-height: 44px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 18px; border: 1px solid var(--line); border-radius: 20px;
  background: rgba(12,18,14,.78); backdrop-filter: blur(18px);
}
.topbar h2 { margin-top: 4px; font-size: 22px; }
.subline { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 11px; margin-top: 4px; }
.topbar-actions { display: flex; gap: 8px; }

.map-card {
  min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr); overflow: hidden;
  border: 1px solid var(--line); border-radius: 22px; background: rgba(10,16,12,.82); box-shadow: var(--shadow);
}
.map-toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.segmented { display: inline-flex; gap: 3px; padding: 3px; border-radius: 12px; background: rgba(255,255,255,.028); border: 1px solid rgba(255,255,255,.05); }
.segment { border: 0; border-radius: 9px; background: transparent; color: #7e8c83; padding: 7px 9px; font-size: 10px; font-weight: 820; cursor: pointer; }
.segment.active { color: var(--text); background: #1b2920; box-shadow: inset 0 0 0 1px rgba(255,255,255,.045); }
.toolbar-hint { color: #65736a; font-size: 9px; margin-left: auto; }

.map-viewport {
  position: relative; overflow: hidden; min-height: 0; cursor: crosshair;
  background: radial-gradient(circle at 50% 35%, #121a14, #060a07 82%);
}
.map-viewport.dragging { cursor: grabbing; }
.map-transform { position: absolute; inset: 0; display: grid; place-items: center; transform-origin: center center; }
.map-surface {
  position: relative; width: min(91%, 1120px); height: auto; aspect-ratio: 1 / 1; overflow: hidden;
  border-radius: 16px; background: #111711; box-shadow: 0 28px 90px rgba(0,0,0,.38), inset 0 0 0 1px rgba(255,255,255,.07);
}
.map-placeholder, .map-image, .marker-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-placeholder {
  background:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px),
    radial-gradient(circle at 40% 35%, rgba(167,226,121,.08), transparent 36%),
    #111811;
  background-size: 42px 42px, 42px 42px, auto, auto;
}
.map-placeholder-copy { position: absolute; left: 50%; top: 50%; width: min(430px, 74%); transform: translate(-50%,-50%); text-align: center; }
.map-placeholder-copy h3 { font-size: clamp(19px, 3vw, 32px); letter-spacing: -.04em; }
.map-placeholder-copy p { margin-top: 8px; color: #8d9b91; font-size: 11px; line-height: 1.6; }
.map-badge-label { display: inline-grid; place-items: center; min-width: 48px; height: 23px; padding: 0 9px; border-radius: 999px; background: rgba(167,226,121,.09); color: #c6eab4; border: 1px solid rgba(167,226,121,.14); font-size: 8px; font-weight: 900; letter-spacing: .16em; margin-bottom: 11px; }
.map-image { object-fit: contain; display: none; user-select: none; pointer-events: none; }
.map-image.visible { display: block; }
.marker-layer { z-index: 5; }
.zone-marker {
  --marker: var(--exterior);

  position: absolute;
  transform:
    translate(-50%, -50%)
    scale(var(--marker-scale, 1));

  transform-origin: center;

  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(8,12,9,.92);
  background: var(--marker);
  outline: 1px solid rgba(255,255,255,.35);
  cursor: pointer;
}
.zone-marker.interior { --marker: var(--interior); }
.zone-marker.active { width: 28px; height: 28px; box-shadow: 0 5px 18px rgba(0,0,0,.45), 0 0 0 5px color-mix(in srgb, var(--marker) 24%, transparent); }
.zone-marker::after { content: attr(data-type); position: absolute; left: 50%; top: 27px; transform: translateX(-50%); text-transform: uppercase; letter-spacing: .09em; font-size: 7px; font-weight: 900; color: #fff; background: rgba(5,8,6,.8); padding: 3px 5px; border-radius: 5px; opacity: 0; pointer-events: none; transition: .14s ease; white-space: nowrap; }
.zone-marker:hover::after, .zone-marker.active::after { opacity: 1; }
.zoom-readout { position: absolute; right: 12px; bottom: 12px; z-index: 10; padding: 6px 9px; border-radius: 10px; font-size: 9px; color: #b7c1ba; background: rgba(5,8,6,.8); border: 1px solid var(--line); }

.details-panel { padding: 16px; overflow: auto; }
.details-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.details-header h2 { margin-top: 4px; }
.empty-state { min-height: 68vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--muted); }
.empty-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: rgba(167,226,121,.07); color: var(--accent); border: 1px solid rgba(167,226,121,.12); font-size: 22px; margin-bottom: 14px; }
.empty-state h3 { color: #d8e0da; font-size: 14px; }
.empty-state p { font-size: 10px; line-height: 1.6; margin-top: 7px; max-width: 220px; }
.zone-form { margin-top: 20px; }
.hidden { display: none !important; }
.textarea { resize: vertical; min-height: 110px; line-height: 1.45; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.pill { border: 1px solid var(--line); background: rgba(255,255,255,.03); color: #cad2cc; padding: 9px 10px; border-radius: 10px; text-transform: capitalize; font-size: 10px; }
.form-actions { margin-top: 20px; }
.form-actions .button { width: 100%; }

.dialog { width: min(500px, calc(100% - 28px)); border: 0; padding: 0; color: var(--text); background: transparent; }
.dialog::backdrop { background: rgba(0,0,0,.62); backdrop-filter: blur(7px); }
.dialog-card { padding: 18px; border-radius: 20px; background: #101711; border: 1px solid var(--line); box-shadow: var(--shadow); }
.dialog-card p { margin: 14px 0; font-size: 10px; line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.mobile-nav, .mobile-map-controls, .mobile-map-hint { display: none; }
@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 270px minmax(0,1fr); }
  .details-panel { display: none; }
}
@media (max-width: 820px) {
  html, body { height: auto; min-height: 100%; }
  body { overflow: auto; }
  .mobile-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: #101711; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); gap: 6px; border-top: 1px solid var(--line); }
  .mobile-nav :is(a, button) { border: 0; cursor: pointer; flex: 1; display: grid; place-items: center; min-height: 44px; border-radius: 10px; color: var(--text); background: var(--panel-soft); text-decoration: none; font-size: 14px; font-weight: 700; }
  html { scroll-padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  #grindTotals, #mapWorkspace, .details-panel { scroll-margin-top: 12px; }
  .app-shell { height: auto; min-height: 100vh; grid-template-columns: 1fr; padding: 8px; padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .sidebar-scroll { display: flex; flex-direction: column; overflow: visible; padding: 10px; }
  .account-panel { order: -3; }
  .grind-selectors { order: -2; }
  #grindTotals { order: -1; }
  .workspace { min-height: 0; grid-template-rows: auto auto; }
  .map-card { grid-template-rows: auto minmax(320px, 58svh); }
  .topbar { align-items: flex-start; flex-wrap: wrap; padding: 12px; }
  .topbar-actions { flex-direction: row; flex-wrap: wrap; }
  .control, .textarea { font-size: 16px; min-height: 44px; }
  .button, .icon-button, .segment { min-height: 44px; min-width: 44px; }
  .button, .segment, .counter-name span, .label { font-size: 13px; }
  .counter-row { gap: 8px; padding: 10px; }
  .counter-name { align-items: center; min-width: 0; gap: 6px; }
  .counter-value { min-height: 44px; width: 100%; max-width: 60%; }
  .stepper { grid-template-columns: 44px 44px; gap: 6px; }
  .stepper button { width: 44px; height: 44px; font-size: 22px; touch-action: manipulation; }
  .toggle-row { min-height: 44px; }
  .mobile-map-controls { display: flex; gap: 8px; width: 100%; }
  .mobile-map-controls [aria-pressed="true"] { background: var(--accent); color: var(--bg); }
  .desktop-map-hint { display: none; }
  .mobile-map-hint { display: block; font-size: 12px; }
  .map-viewport.move-mode { touch-action: none; cursor: grab; }
  .details-panel:has(.zone-form:not(.hidden)) { display: block; }
  .zone-marker { width: 32px; height: 32px; }
  .zone-marker.active { width: 36px; height: 36px; }
  .toolbar-hint { width: 100%; margin-left: 0; }
}

/* Settings window */
.sidebar-settings { padding: 12px 12px 0; }
.sidebar-settings .button { width: 100%; }
.settings-dialog { width: min(560px, calc(100% - 28px)); max-height: calc(100dvh - 28px); overflow: hidden; border-radius: 20px; }
.settings-card { display: flex; flex-direction: column; max-height: calc(100dvh - 28px); padding: 0; }
.settings-header { flex-shrink: 0; padding: 18px; border-bottom: 1px solid var(--line); }
.settings-header h2 { font-size: 22px; }
.settings-content { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px; }
.settings-content .panel:last-child { margin-bottom: 0; }
.appearance-panel .theme-control { padding: 0; flex-wrap: nowrap; }
.appearance-panel h2 { font-size: 14px; }
.settings-card .appearance-panel p { margin: 6px 0 0; }
.settings-card .small { font-size: 11px; }
body:has(#settingsDialog[open]) { overflow: hidden; }

.marker-colors { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.marker-colors h3 { font-size: 13px; }
.marker-color-row { margin-top: 16px; }
.marker-color-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.marker-color-heading label { font-size: 12px; font-weight: 700; }
.marker-color-custom { display: flex; align-items: center; gap: 8px; }
.marker-color-custom output { color: var(--muted); font-size: 10px; font-family: ui-monospace, monospace; }
.marker-color-input { width: 36px; height: 36px; padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-soft); cursor: pointer; }
.marker-color-input::-webkit-color-swatch-wrapper { padding: 0; }
.marker-color-input::-webkit-color-swatch { border: 0; border-radius: 5px; }
.marker-color-input::-moz-color-swatch { border: 0; border-radius: 5px; }
.marker-color-palette { display: grid; grid-template-columns: repeat(6, 36px); gap: 4px; margin-top: 4px; }
.marker-color-swatch { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text); cursor: pointer; }
.marker-color-swatch::before { content: ""; width: 20px; height: 20px; grid-area: 1 / 1; border-radius: 50%; background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.marker-color-swatch:hover { background: var(--panel-soft); }
.marker-color-swatch[aria-pressed="true"] { border-color: var(--accent); background: var(--panel-soft); }
.marker-color-swatch[aria-pressed="true"]::after { content: "✓"; grid-area: 1 / 1; color: #09100c; font-size: 12px; font-weight: 900; }
.marker-color-preview { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 28px; margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.marker-color-preview > span { display: inline-flex; align-items: center; gap: 9px; font-size: 11px; color: var(--muted); }
.marker-preview-dot { width: 22px; height: 22px; border: 3px solid #080c09; border-radius: 50%; background: var(--marker); box-shadow: 0 0 0 1px #89968d, 0 0 0 5px color-mix(in srgb, var(--marker) 18%, transparent); }
.exterior-preview { --marker: var(--exterior); }
.interior-preview { --marker: var(--interior); }
.marker-color-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.marker-color-footer .small { flex: 1; min-width: 100px; }
@media (max-width: 820px) {
  .marker-color-input, .marker-color-swatch { width: 44px; height: 44px; }
  .marker-color-heading label { font-size: 13px; }
  .marker-color-palette { grid-template-columns: repeat(6, 44px); gap: 0; }
  .marker-color-preview { gap: 20px; }
}
@media (max-width: 380px) {
  .marker-color-palette { grid-template-columns: repeat(3, 44px); gap: 4px; }
}


/* Account and sign-in */
.harvest-dev-dialog { width: min(700px, calc(100% - 28px)); }
.dev-section { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; }
.dev-section h3 { margin: 0 0 12px; }
.dev-section summary, .dev-preview summary { cursor: pointer; padding: 10px 0; font-weight: 600; }
.dev-mode { border-left: 3px solid var(--accent); padding: 10px; background: var(--panel, #172019); }
.dev-mode.live { border-color: #e6a33d; font-weight: 700; }
.dev-counter { display: grid; grid-template-columns: minmax(90px, 1fr) auto auto minmax(65px, 95px) auto; align-items: center; gap: 6px; padding: 8px 0; }
.dev-counter input { width: 100%; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); color: var(--text); font: inherit; }
.dev-counter .button { padding: 8px 10px; min-height: 36px; }
.history-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.history-filters label, #historyFields label { display: block; font-size: 12px; }
.history-list { list-style: none; padding: 0; max-height: 500px; overflow: auto; }
.history-list li { border-top: 1px solid var(--line); padding: 12px 0; overflow-wrap: anywhere; }
.history-list button { margin: 4px 6px 0 0; }
#historyFields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
@media (max-width: 480px) { .history-filters, #historyFields { grid-template-columns: 1fr; } }
.harvest-dev-dialog .button-stack { display: flex; gap: 8px; }
.harvest-dev-dialog .button-stack > button { flex: 1; }
@media (max-width: 480px) { .dev-counter { grid-template-columns: 1fr auto auto; } .dev-counter label { grid-column: 1 / -1; } }
.harvest-dev-dialog .dialog-card p { font-size: 13px; line-height: 1.7; }
#harvestPreview { width: 100%; max-height: 260px; object-fit: contain; background: #000; border-radius: 10px; }
#harvestPreview[hidden] { display: none; }
.harvest-log { max-height: 220px; overflow: auto; padding-left: 24px; font-size: 12px; }
.harvest-log li { padding: 8px 0; }
.harvest-log button { margin: 6px; }
:is(#harvestApply, #harvestSounds):focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 3px; }
#harvestApply:disabled + .switch { opacity: .5; }
#installApp[hidden] { display: none; }
#installApp { width: 100%; min-height: 44px; margin-top: 8px; }
.install-card { position: relative; padding-top: 28px; }
.install-close { position: absolute; top: 10px; right: 10px; }
.install-logo { border-radius: 16px; margin-bottom: 16px; }
.install-card h2 { margin-top: 8px; }
.install-card p, .install-card li { font-size: 14px; line-height: 1.7; }
.install-card .small { font-size: 12px; }
.install-card ol { padding-left: 24px; }
.install-card li { padding: 6px 0 6px 4px; }

.account-panel .section-heading { margin-bottom: 8px; }
.account-panel h2 { line-height: 1.4; overflow-wrap: anywhere; }
button:disabled { opacity: .55; cursor: wait; transform: none; }
.login-card { position: relative; text-align: center; padding: 34px 28px 20px; }
.login-close { position: absolute; top: 12px; right: 12px; }
.login-logo { width: 70px; height: 70px; object-fit: cover; border-radius: 20px; margin-bottom: 18px; }
.login-card h2 { font-size: 28px; margin-top: 8px; letter-spacing: -.04em; }
.login-card p { font-size: 12px; line-height: 1.7; }
.login-benefits { padding: 0; list-style: none; text-align: left; margin: 22px 0; color: #c6cec8; font-size: 12px; }
.login-benefits li { padding: 7px 0; }
.login-benefits li::before { content: "✓"; color: var(--accent); margin-right: 10px; }
.google-button { background: #fff; color: #202124; width: 100%; min-height: 46px; font-size: 14px; gap: 12px; }
.google-button:hover { background: #edf2ed; }
.login-card #continueLocal { width: 100%; }
.login-card .login-footnote { font-size: 10px; color: var(--muted); }
#loginStatus[data-error="true"] { color: var(--danger); }
#syncConflict h2 { margin-top: 8px; }
@media (max-width: 480px) { .login-card { padding: 30px 20px 16px; } .login-card h2 { font-size: 25px; } }


/* Admin experiment only: readable, keyboard-visible controls in short windows. */
.harvest-dev-dialog { max-height:calc(100dvh - 24px); overflow-y:auto; overscroll-behavior:contain; scrollbar-gutter:stable; border-radius:20px; }
.harvest-dev-dialog .dev-toolbar { position:sticky; top:0; z-index:2; background:#101711; padding:10px 0 12px; border-bottom:1px solid var(--line); }
html[data-theme="light"] .harvest-dev-dialog .dev-toolbar { background:var(--panel); }
.harvest-dev-dialog .dev-toolbar .section-heading { margin-bottom:6px; }
.harvest-dev-dialog .dev-toolbar .dev-mode { margin:6px 0 10px; padding:6px 10px; }
.harvest-dev-dialog .small, .harvest-dev-dialog .toggle-row, #historyEditor .dialog-card p { font-size:13px; line-height:1.6; }
.harvest-dev-dialog :is(.button,.icon-button) { min-height:44px; font-size:13px; }
.harvest-dev-dialog .icon-button { min-width:44px; flex-shrink:0; }
.harvest-dev-dialog :is(p,li,.toggle-row > span:first-child) { overflow-wrap:anywhere; }
.harvest-dev-dialog :is(summary,button,a,input,select,textarea):focus-visible, #historyEditor :is(button,input,select):focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
.harvest-dev-dialog .toggle-row input:focus-visible + .switch { outline:2px solid var(--accent); outline-offset:3px; }
.harvest-dev-dialog .toggle-row { min-height:48px; padding:8px 0; }
.harvest-dev-dialog .toggle-row input:disabled + .switch { opacity:.45; }
.harvest-dev-dialog .toggle-row:has(input:disabled) { cursor:default; }
.harvest-dev-dialog .dev-help { font-size:13px; line-height:1.65; }
.harvest-dev-dialog .dev-help h3 { margin:18px 0 6px; font-size:15px; }
.harvest-dev-dialog .dev-help :is(ol,ul) { padding-left:22px; }
.harvest-dev-dialog .dev-help li { margin:8px 0; }
.harvest-dev-dialog .dev-counter { grid-template-columns:minmax(90px,1fr) auto auto minmax(72px,110px) auto; }
.harvest-dev-dialog .dev-counter :is(input,.button) { min-height:44px; font-size:14px; }
#historyEditor .dialog-card p { line-height:1.6; }
#historyEditor :is(.button,.control) { min-height:44px; }
#historyEditor .dialog-card { font-size:14px; }
#historyEditor #historyFields label { font-size:13px; }
@media(max-width:560px) {
  .harvest-dev-dialog .dev-counter { grid-template-columns:auto auto minmax(72px,1fr) auto; }
  .harvest-dev-dialog .dev-counter label { grid-column:1 / -1; }
  .harvest-dev-dialog .history-filters { grid-template-columns:1fr; }
}
#historyEditor { max-height:calc(100dvh - 24px); overflow-y:auto; overscroll-behavior:contain; border-radius:20px; scroll-padding-block:12px; }
#historyEditor .history-editor-actions { position:sticky; bottom:0; display:flex; flex-wrap:wrap; gap:8px; padding:12px 0; background:#101711; }
html[data-theme="light"] #historyEditor .history-editor-actions { background:var(--panel); }
/* Keep keyboard-focused fields above the editor's sticky action row. */
#historyEditor { scroll-padding-bottom:100px; }
#historyEditor .control { scroll-margin-bottom:80px; }
.harvest-dev-dialog [tabindex="0"]:focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
