:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f0efe9;
  --border: #e2e0d8;
  --text: #1c1c1a;
  --text-secondary: #6b6a63;
  /* Brand indigo everywhere — the landing and app already used it;
     the old #185fa5 blue made the directory pages look like a
     different product. Night indigo IS the accent, by design. */
  --accent: #4C55A8;
  --accent-bg: #EBEDF8;
  --danger: #a32d2d;
  --radius: 14px;
  --morning: #D9A62E; --midday: #4E93C4; --evening: #C96F3B; --night: #4C55A8;
  --display: "Avenir Next", "Futura", "Helvetica Neue", sans-serif;
}
h1 { font-family: var(--display); letter-spacing: -0.5px; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden { display: none !important; }

.screen {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
}

#authScreen { align-items: center; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(28,28,26,0.04), 0 12px 32px -24px rgba(28,28,26,0.28);
  padding: 1.5rem;
  max-width: 420px;
  width: 100%;
}

h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.muted { color: var(--text-secondary); }
.small { font-size: 13px; }
.label { font-size: 13px; color: var(--text-secondary); margin: 0 0 8px; font-weight: 500; }

.tabs { display: flex; gap: 4px; margin: 1rem 0; border-bottom: 1px solid var(--border); }
.tab {
  flex: 1; background: none; border: none; padding: 8px; cursor: pointer;
  color: var(--text-secondary); border-bottom: 2px solid transparent;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }

form { display: flex; flex-direction: column; gap: 4px; }
label { font-size: 13px; color: var(--text-secondary); margin-top: 8px; }
input, select, textarea {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; background: var(--surface); color: var(--text);
  font-family: inherit;
}
/* One button language everywhere: the brand indigo pill the landing
   established. Grid-shaped controls (calendar cells, tabs, stories)
   keep their own class-level shapes, which win over this base. */
button {
  padding: 9px 16px; border-radius: 999px; border: none;
  background: var(--accent);
  background-image: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(0,0,0,0.04));
  color: #fff; font-size: 14px;
  cursor: pointer; margin-top: 12px; font-family: inherit;
}
button.ghost { background-image: none; }
button.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
button:hover { filter: brightness(0.94); }
a { color: var(--accent); }
.error { color: var(--danger); font-size: 13px; min-height: 1em; margin: 4px 0 0; }

header {
  max-width: 640px; margin: 0 auto; padding: 1.5rem 1rem 0.5rem;
  display: flex; justify-content: space-between; align-items: center;
}
.header-right { display: flex; align-items: center; gap: 10px; }

main { max-width: 640px; margin: 0 auto; padding: 1rem; display: flex; flex-direction: column; gap: 1rem; }

.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.switch-row { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }

.timeline { display: flex; gap: 3px; margin-bottom: 6px; }
.timeline > div { flex: 1; height: 10px; border-radius: 4px; cursor: pointer; background: var(--border); position: relative; }
.timeline > div.active { background: var(--accent); }
.timeline > div:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The segment the clock says it is RIGHT NOW — independent of which
   segment is selected. A small dot beneath the bar, so "now" stays
   visible even when you've deliberately selected a different segment. */
.timeline > div.now::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-secondary); }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

.suggestion { background: var(--surface-2); border-radius: var(--radius); padding: 1rem; margin-top: 1rem; }
.suggestion p { margin: 0 0 12px; font-weight: 500; }

.metric { background: var(--surface-2); border-radius: var(--radius); padding: 1rem; }
.metric-value { font-size: 22px; font-weight: 600; margin: 4px 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 20px; background: var(--accent-bg); color: var(--accent); }

.log-entry {
  display: flex; justify-content: space-between; align-items: center; padding: 8px 0;
  border-top: 1px solid var(--border); font-size: 14px; gap: 8px;
}
.log-entry .entry-text { flex: 1; }
.log-entry .entry-right {
  color: var(--text-secondary); white-space: nowrap; margin-left: 12px;
  display: flex; align-items: center; gap: 8px;
}
.log-entry .deleteEntry, .log-entry .shareWorld { margin: 0; padding: 3px 8px; font-size: 11px; }
.log-entry .shareWorld.active-share { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }

.star-rating { display: flex; gap: 2px; }
.star-rating button {
  margin: 0; padding: 0; border: none; background: none; cursor: pointer;
  font-size: 15px; line-height: 1; color: var(--border);
}
.star-rating button.filled { color: var(--accent); }

.summary-text {
  font-size: 12px; color: var(--text); white-space: pre-wrap; margin: 8px 0 0;
  font-family: inherit; background: var(--surface-2); border-radius: 6px; padding: 10px;
}

.wide { max-width: 520px; }

.option-row {
  display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px; margin-top: 8px; font-size: 14px;
}
.option-row input { margin-top: 2px; }

.check-row {
  display: flex; gap: 8px; align-items: flex-start; cursor: pointer;
  font-size: 14px; margin-top: 8px;
}
.check-row input { margin-top: 3px; }

.banner {
  background: var(--accent-bg); color: var(--accent);
  border-radius: var(--radius); padding: 10px 14px; font-size: 13px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
}

.event-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; font-size: 13px; border-top: 1px solid var(--border);
}
.event-row button { margin: 0; padding: 4px 8px; font-size: 11px; }

.timer-display {
  font-size: 40px; font-weight: 600; margin: 8px 0 4px;
  font-variant-numeric: tabular-nums; letter-spacing: 1px;
}

.link-button {
  text-decoration: none; display: inline-flex; align-items: center;
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; color: var(--text);
}

.chat-panel { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 8px; }
.chat-messages {
  max-height: 180px; overflow-y: auto; margin: 8px 0;
  display: flex; flex-direction: column; gap: 6px;
}
.chat-message { font-size: 13px; display: flex; align-items: flex-start; gap: 6px; }
.chat-message .zip { color: var(--text-secondary); font-size: 11px; white-space: nowrap; margin-top: 2px; }
.chat-message .msg-text { flex: 1; }
.chat-message.is-plan { background: var(--accent-bg); border-radius: 6px; padding: 4px 8px; }
.chat-message .msg-actions { display: flex; gap: 4px; }
.chat-message .msg-actions button {
  margin: 0; padding: 1px 6px; font-size: 10px; border: none; background: none;
  color: var(--text-secondary); cursor: pointer;
}
.small-switch { font-size: 12px !important; margin-top: 0 !important; }

.avatar-preview {
  width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2);
  background-size: cover; background-position: center; flex-shrink: 0;
  border: 1px solid var(--border);
}

.match-tag {
  font-size: 10px; color: var(--accent); display: block; margin-top: 2px;
}
.match-tag.availability-free { color: #2f9e44; }
.match-tag.availability-busy { color: var(--text-secondary); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
.modal-card {
  background: var(--surface); border-radius: var(--radius); padding: 1.25rem;
  max-width: 340px; width: 90%;
}


/* ---- Shared site search (mounted via #siteSearchMount) ---- */
.banner-search { position: relative; display: flex; gap: 6px; flex: 0 1 330px; min-width: 200px; margin-left: auto; }
.banner-search input {
  flex: 1; height: 38px; border: none; border-radius: 999px;
  background: var(--accent-bg, #EBEDF8); padding: 0 16px; font-size: 14px; color: var(--text);
}
.banner-search input::placeholder { color: var(--accent, #4C55A8); opacity: 0.7; }
.banner-search #searchBtn {
  border-radius: 999px; height: 38px; padding: 0 16px;
  background: var(--accent, #4C55A8); color: #fff; border: none; margin: 0;
}
#searchPanel {
  position: absolute; top: 44px; left: 0; right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; box-shadow: 0 10px 26px rgba(0,0,0,0.14);
  max-height: 60vh; overflow-y: auto;
}
header.with-search { flex-wrap: wrap; }
header.with-search > p { flex-basis: 100%; }
@media (max-width: 560px) {
  .banner-search { flex-basis: 100%; margin-left: 0; }
}


/* ---- Full-width top bar (brand + site search), every page ---- */
.site-topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  width: 100%; max-width: none; margin: 0; padding: 8px 20px;
  box-sizing: border-box;
}
.site-topbar .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 18px; color: var(--text);
  text-decoration: none; white-space: nowrap;
}

/* ---- Shared identity: the segment band edges every top bar, and
   card labels carry the accent — one product across every page. ---- */
.site-topbar {
  border-bottom: 3px solid;
  border-image: linear-gradient(90deg, #4C55A8 0 18%, #D9A62E 18% 42%, #4E93C4 42% 62%, #C96F3B 62% 82%, #4C55A8 82% 100%) 1;
}
.label {
  color: var(--accent, #4C55A8);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600;
}

/* ---- Accessibility: a visible keyboard focus ring everywhere ---- */
:focus-visible { outline: 2px solid var(--accent, #4C55A8); outline-offset: 2px; }


/* ---- The last ten percent: motion, elevation, and focus — the
   layer big teams sweat. Every effect is subtle, fast, and switched
   off entirely for people who ask for reduced motion. ---- */

body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
::selection { background: var(--accent-bg); color: var(--text); }

button, a, input, select, textarea, .card {
  transition: background-color 0.15s ease, box-shadow 0.18s ease,
              border-color 0.15s ease, transform 0.1s ease, filter 0.15s ease;
}

/* primaries get weight and a press */
button:not(.ghost) { box-shadow: 0 1px 2px rgba(76, 85, 168, 0.28); }
button:active { transform: scale(0.97); }

/* fields answer focus the way people expect from finished software */
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* elevation answers the pointer only where something is clickable */
.cal-cell:hover, .cal-year-month:hover, .cal-week-head:hover {
  box-shadow: 0 2px 10px rgba(28, 28, 26, 0.08);
}
.site-topbar { backdrop-filter: saturate(1.1); }

/* quiet, consistent scrollbars in the panels that scroll */
.chat-messages, #searchPanel {
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.chat-messages::-webkit-scrollbar, #searchPanel::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-thumb, #searchPanel::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 4px;
}

/* numbers line up like they were set by hand */
.metric-value, .dw-val, #dwClock, .cal-cell span:first-child { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- Native-mobile safe areas ----
   Installed standalone on a phone, the status bar overlays the page
   (viewport-fit=cover): every top bar pads itself below the notch and
   the page body clears the home-indicator bar and curved edges. All
   four insets are 0 in a normal browser window, so nothing changes on
   desktop. !important because page-local styles set padding with the
   shorthand, which would silently win over this file otherwise. */
@supports (padding: env(safe-area-inset-top)) {
  .site-topbar, .top-banner, .ig-nav, #appScreen > header {
    padding-top: calc(10px + env(safe-area-inset-top)) !important;
  }
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ---- Appearance themes: three complete looks over one token system.
   Inactive until <html data-otc-theme="..."> is set; the attribute
   selector out-specifies page-local :root declarations (app.html's
   --fb-*, world.html's --ig-*), so one block restyles every page. ---- */

/* 1. INK — editorial calm: paper ground, deep ink accent, serif
   display, squared corners. The app as a well-set journal. */
:root[data-otc-theme="ink"] {
  --bg: #fbfaf7; --surface: #ffffff; --surface-2: #f4f2ec;
  --border: #d8d4c8; --text: #191714; --text-secondary: #6e6a5f;
  --accent: #2f3559; --accent-bg: #e9eaf2; --danger: #96312d;
  --radius: 8px;
  --morning: #c29a32; --midday: #4a86ad; --evening: #b56636; --night: #3b4278;
  --display: "Iowan Old Style", "Palatino", Georgia, serif;
  --fb-bg: #f4f2ec; --fb-card: #ffffff; --fb-accent: #2f3559;
  --ig-bg: #fbfaf7; --ig-card: #ffffff; --ig-border: #d8d4c8;
}

/* 2. DUSK — night-first: the brand's night indigo becomes the world.
   Dark surfaces, luminous segments, the watch finally at home. */
:root[data-otc-theme="dusk"] {
  --bg: #12141d; --surface: #1b1e2b; --surface-2: #232739;
  --border: #2e3348; --text: #e8e9f0; --text-secondary: #9aa0b8;
  --accent: #8b93e8; --accent-bg: #262b45; --danger: #e07070;
  --morning: #e8b84b; --midday: #64a9d9; --evening: #e08350; --night: #8b93e8;
  --fb-bg: #12141d; --fb-card: #1b1e2b; --fb-accent: #8b93e8;
  --ig-bg: #12141d; --ig-card: #1b1e2b; --ig-border: #2e3348;
}
:root[data-otc-theme="dusk"] .card { box-shadow: 0 1px 2px rgba(0,0,0,0.4), 0 12px 32px -24px rgba(0,0,0,0.8); }
:root[data-otc-theme="dusk"] img[src*="logo"] { filter: brightness(1.6); }

/* 3. DAYBREAK — vivid warm: sunrise amber accent, saturated segments,
   generous curves. The most consumer-app energy of the three. */
:root[data-otc-theme="daybreak"] {
  --bg: #fdf8f0; --surface: #ffffff; --surface-2: #faf0e0;
  --border: #f0dfc8; --text: #241d15; --text-secondary: #8a7a63;
  --accent: #d97e2e; --accent-bg: #fbeedd; --danger: #c24034;
  --radius: 18px;
  --morning: #e9ae24; --midday: #3d97d1; --evening: #e0703c; --night: #5560c9;
  --fb-bg: #faf0e0; --fb-card: #ffffff; --fb-accent: #d97e2e;
  --ig-bg: #fdf8f0; --ig-card: #ffffff; --ig-border: #f0dfc8;
}

/* Promote-only sections: real members of the column, collapsed until
   promoted front (nav entry or the weather pill). Keeps home to one
   copy of everything — the section OR its nav entry, never both. */
.fb-col [data-promote-only]:not(.main-promoted) { display: none; }
