/* Gustly: structure is the graphic. Hairlines, pane/ground bands, 0 radius, one solid primary. */

@font-face {
  font-family: "Syne";
  src: url("/fonts/syne-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  /* ground / pane bands */
  --bg: #0c1012;
  --pane: #111618;
  --raise: #182023;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.16);
  /* text contrast, worst case on --raise: muted 7.2:1, faint 4.6:1 */
  --text: #e8edef;
  --muted: #a3adb1;
  --faint: #828c91;
  --accent: #4fd1d9;
  --accent-hover: #6ddce3;
  --accent-ink: #051113;
  --send: #3ccf8e;
  --soft: #e6b450;
  --sit: #8d999f;
  --warn: #e39a5b;
  --danger: #ef8a7d;
  --sidebar: 264px;
  --map: minmax(340px, 38vw);
  --tap: 44px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-job: ui-serif, "Iowan Old Style", Charter, Georgia, serif;
  --t-body: 16px;
  --t-meta: 14px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  border-radius: 0;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.frame {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 0 16px 0 24px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  font-family: "Syne", var(--font);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

/* Logo mark: transparent PNG, aspect 800:943 */
.mark {
  flex: none;
  display: block;
  height: auto;
}

.mark-sm {
  width: 24px;
}

.mark-lg {
  width: 112px;
}

/* Landing is the first paint. The app replaces it once a session is in. */
.login {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  text-align: center;
}

.login-credit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: auto;
  padding-top: 24px;
  font-size: var(--t-meta);
  color: var(--faint);
}

.login-credit a {
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  text-underline-offset: 3px;
}

.login-credit a:hover,
.login-credit a:focus-visible {
  text-decoration: underline;
}

.login > :first-child {
  margin-top: auto;
}

body[data-auth="in"] .login {
  display: none;
}

body:not([data-auth="in"]) .frame {
  display: none;
}

body[data-auth="hold"] .login-actions,
body[data-auth="hold"] .login-note {
  display: none;
}

.lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
}

.lockup-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wordmark {
  margin: 0;
  font-family: "Syne", var(--font);
  font-weight: 700;
  font-size: clamp(44px, 12vw, 64px);
  line-height: 1;
  letter-spacing: -0.03em;
}

.tagline {
  margin: 0;
  font-size: var(--t-meta);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.login-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.login-cta {
  min-width: 240px;
  min-height: 48px;
  font-size: var(--t-body);
}

.login-note,
.login-status {
  margin: 0;
  max-width: 36ch;
  font-size: var(--t-meta);
  color: var(--muted);
}

.login-note {
  font-style: italic;
}

.login-status {
  color: var(--text);
}

.btn.google {
  gap: 12px;
  background: #fff;
  color: #1f1f1f;
  font-weight: 600;
}

.google-g {
  width: 18px;
  height: 18px;
  flex: none;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  object-fit: cover;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.user-meta {
  font-size: var(--t-meta);
  color: var(--muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 16px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--t-meta);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms var(--ease), border-color 120ms var(--ease);
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.btn.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.outline {
  border-color: var(--line-2);
}

.btn.quiet {
  color: var(--muted);
}

.link-btn {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: var(--t-meta);
  font-weight: 500;
  cursor: pointer;
}

/* Shell: sidebar and map are pane bands, chat is ground */
.shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.shell[data-map="open"] {
  grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--map);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--pane);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.sidebar-new {
  margin: 16px 16px 0;
  justify-content: flex-start;
}

.sidebar-label {
  margin: 24px 16px 4px;
  font-size: var(--t-meta);
  font-weight: 500;
  color: var(--faint);
}

.conv-list {
  flex: 1;
  margin: 0;
  padding: 0;
  list-style: none;
}

.conv-list button {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 0 16px;
  border: 0;
  border-left: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: var(--t-meta);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.conv-list button[aria-current="true"] {
  border-left-color: var(--accent);
  background: var(--raise);
  color: var(--text);
}

/* Profile: a section of the sidebar band, split by a hairline */
.profile-card {
  padding: 16px;
  border-top: 1px solid var(--line);
  box-shadow: inset 2px 0 0 transparent;
  transition: box-shadow 600ms var(--ease);
}

.profile-card[data-flash="1"] {
  box-shadow: inset 2px 0 0 var(--accent);
}

.profile-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.profile-card-title {
  margin: 0;
  font-size: var(--t-meta);
  font-weight: 600;
}

.profile-rows {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 12px;
  margin: 0;
  font-size: var(--t-meta);
}

.profile-rows dt {
  color: var(--faint);
}

.profile-rows dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.profile-rows dd.unset {
  color: var(--faint);
}

.profile-note {
  margin: 12px 0 0;
  font-size: var(--t-meta);
  color: var(--faint);
}

/* Chat */
.chat-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-scroll {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 32px 24px 16px;
  outline: none;
}

.chat-scroll:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.chat-scroll > .messages {
  width: 100%;
  margin-top: auto;
}

.jump-latest {
  position: absolute;
  left: 50%;
  bottom: 132px;
  z-index: 5;
  min-height: 36px;
  padding: 0 14px;
  transform: translateX(-50%);
  border: 1px solid var(--line-2);
  background: var(--raise);
  color: var(--text);
  font: inherit;
  font-size: var(--t-meta);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.jump-latest[hidden] {
  display: none;
}

.jump-latest:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.msg.assistant {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.msg.failed .body {
  padding-left: 12px;
  border-left: 2px solid var(--danger);
  color: var(--muted);
}

.msg-copy {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  background: none;
  color: var(--faint);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms var(--ease), color 120ms var(--ease);
}

.msg.assistant:hover .msg-copy,
.msg-copy:focus-visible {
  opacity: 1;
}

.msg-copy:hover,
.msg-copy:focus-visible {
  color: var(--text);
  border-color: var(--line-2);
}

@media (hover: none) {
  .msg-copy {
    opacity: 1;
  }
}

.empty {
  max-width: 560px;
  margin: 12vh auto 0;
}

.empty h1 {
  margin: 0 0 8px;
  font-family: var(--font-job);
  font-size: clamp(32px, 4.4vw, 40px);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.lede {
  margin: 0;
  color: var(--muted);
}

.messages {
  display: grid;
  gap: 20px;
  max-width: 720px;
  margin: 0 auto;
}

.msg {
  display: flex;
  min-width: 0;
}

.msg .body {
  min-width: 0;
  max-width: 68ch;
  overflow-wrap: anywhere;
}

.msg.user {
  justify-content: flex-end;
}

.msg.user .body {
  max-width: 80%;
  padding: 10px 14px;
  background: var(--raise);
  border: 1px solid var(--line);
  white-space: pre-wrap;
}

.msg.assistant .body {
  line-height: 1.6;
}

.msg.assistant.streaming .body:empty::before {
  content: "Thinking";
  color: var(--faint);
  animation: pulse 1.2s var(--ease) infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.4;
  }
}

/* Rendered model markdown */
.md > * {
  margin: 0;
}

.md > * + * {
  margin-top: 10px;
}

.md h3 {
  font-size: var(--t-body);
  font-weight: 650;
}

.md strong {
  color: var(--text);
  font-weight: 650;
}

.md ul,
.md ol {
  padding-left: 22px;
}

.md li + li {
  margin-top: 4px;
}

.md li::marker {
  color: var(--accent);
}

.md code {
  padding: 1px 5px;
  background: var(--raise);
  border: 1px solid var(--line);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.md pre {
  padding: 12px 14px;
  overflow-x: auto;
  background: var(--raise);
  border: 1px solid var(--line);
}

.md pre code {
  padding: 0;
  border: 0;
  background: none;
  white-space: pre;
}

.md blockquote {
  padding-left: 12px;
  border-left: 2px solid var(--line-2);
  color: var(--muted);
}

.md a {
  color: var(--accent);
  text-underline-offset: 2px;
}

.md hr {
  border: 0;
  border-top: 1px solid var(--line);
}

.msg.note {
  font-size: var(--t-meta);
  color: var(--muted);
}

.msg.note .body {
  padding-left: 12px;
  border-left: 2px solid var(--accent);
}

.tool-status {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px 8px;
  font-size: var(--t-meta);
  color: var(--muted);
}

.tool-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  animation: pulse 1.2s var(--ease) infinite;
}

/* Composer */
.composer {
  padding: 0 24px calc(16px + env(safe-area-inset-bottom));
}

.composer-shell {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 720px;
  margin: 0 auto;
  padding: 6px 6px 6px 4px;
  border: 1px solid var(--line-2);
  background: var(--raise);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}

.composer-shell:focus-within {
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px rgba(79, 209, 217, 0.14),
    0 12px 32px rgba(0, 0, 0, 0.35);
}

.composer textarea {
  flex: 1;
  min-height: var(--tap);
  max-height: 160px;
  padding: 11px 12px;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  line-height: 1.4;
  resize: none;
  outline: none;
}

.composer textarea::placeholder {
  color: var(--faint);
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.send-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: 2px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  transition: background 120ms var(--ease), opacity 120ms var(--ease);
}

.send-btn:disabled {
  background: var(--line-2);
  color: var(--faint);
  cursor: default;
}

.send-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.composer-hint {
  max-width: 720px;
  margin: 8px auto 0;
  font-size: 12px;
  color: var(--faint);
  text-align: center;
}

/* Map */
.map-pane {
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr) minmax(160px, 40%);
  min-width: 0;
  min-height: 0;
  background: var(--pane);
  border-left: 1px solid var(--line);
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 4px 16px;
  border-bottom: 1px solid var(--line);
}

.map-title {
  margin: 0;
  font-size: var(--t-meta);
  font-weight: 600;
}

.map,
.map .leaflet-container {
  background: var(--pane);
  font: inherit;
}

.gustly-tiles {
  filter: saturate(0.6) brightness(0.85);
}

.spot-cards {
  display: grid;
  align-content: start;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}

.spot-card {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: background 120ms var(--ease);
}

.spot-card[aria-selected="true"] {
  border-left-color: var(--accent);
  background: var(--raise);
}

.spot-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.spot-card h3 {
  margin: 0;
  font-size: var(--t-body);
  font-weight: 600;
}

.verdict {
  flex-shrink: 0;
  font-size: var(--t-meta);
  font-weight: 600;
}

.verdict.send {
  color: var(--send);
}

.verdict.soft {
  color: var(--soft);
}

.verdict.sit {
  color: var(--sit);
}

.spot-meta,
.spot-summary {
  margin: 4px 0 0;
  font-size: var(--t-meta);
  color: var(--muted);
}

.wind-strip {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  align-items: end;
  gap: 4px;
  height: 24px;
  margin-top: 12px;
}

.wind-bar {
  min-height: 4px;
  background: var(--accent);
  opacity: 0.7;
}

.badge {
  display: inline-block;
  margin-top: 4px;
  font-size: var(--t-meta);
  color: var(--warn);
}

.map-fab {
  position: fixed;
  right: 16px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 20;
  display: none;
}

/* Profile editor */
.profile-dialog {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--line-2);
  background: var(--pane);
  color: var(--text);
}

.profile-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.profile-form {
  display: grid;
  gap: 24px;
  padding: 24px;
}

.profile-form-head h2 {
  margin: 0;
  font-family: var(--font-job);
  font-size: 24px;
  font-weight: 500;
}

.profile-form-sub {
  margin: 4px 0 0;
  font-size: var(--t-meta);
  color: var(--muted);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 12px;
}

.field {
  display: grid;
  gap: 4px;
  font-size: var(--t-meta);
  color: var(--muted);
}

.field.wide {
  grid-column: 1 / -1;
}

.field input,
.field select {
  width: 100%;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--line-2);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  outline: none;
}

.form-error {
  margin: 0;
  font-size: var(--t-meta);
  color: var(--danger);
}

.profile-form-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Narrow */
@media (max-width: 960px) {
  .shell,
  .shell[data-map="open"] {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar,
  .user-chip {
    display: none;
  }

  .profile-open {
    display: inline-flex;
  }

  .topbar {
    padding: 0 8px 0 16px;
  }

  .chat-scroll {
    padding: 24px 16px;
  }

  .composer {
    padding: 0 12px calc(12px + env(safe-area-inset-bottom));
  }

  .composer-hint {
    display: none;
  }

  .tool-status {
    padding: 0 16px 8px;
  }

  .map-pane {
    position: fixed;
    inset: 0;
    z-index: 30;
    border-left: 0;
  }

  .map-fab {
    display: inline-flex;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 961px) {
  .profile-open {
    display: none;
  }
}

@media (hover: hover) and (pointer: fine) {
  .btn.quiet:hover,
  .btn.outline:hover,
  .conv-list button:hover {
    background: var(--raise);
    color: var(--text);
  }

  .btn.primary:hover:not(:disabled) {
    background: var(--accent-hover);
  }

  .btn.google:hover {
    background: #f3f4f4;
  }

  .send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
  }

  .spot-card:hover {
    background: var(--raise);
  }

  .link-btn:hover {
    text-decoration: underline;
  }
}

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