:root {
  color-scheme: dark;
  --canvas: #0d1110;
  --surface: #151b18;
  --surface-raised: #1b231f;
  --ink: #f2eee4;
  --muted: #aeb7b0;
  --dim: #79847d;
  --line: #334039;
  --green: #29c987;
  --green-dark: #102f24;
  --red: #d45b4b;
  --gold: #ddb45e;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--canvas); color: var(--ink); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.buddy-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.6rem;
  padding: 0.8rem clamp(1rem, 3vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: rgba(13, 17, 16, 0.96);
  backdrop-filter: blur(14px);
}

.buddy-brand { display: inline-flex; align-items: center; gap: 0.7rem; text-decoration: none; }
.buddy-brand img { width: 2.4rem; height: 2.4rem; }
.buddy-brand span { display: grid; gap: 0.1rem; }
.buddy-brand strong { font-size: 1rem; }
.buddy-brand small { color: var(--muted); font-size: 0.72rem; }
.buddy-header nav { display: flex; align-items: center; gap: 1rem; color: var(--muted); font-size: 0.86rem; }
.buddy-header nav a { padding: 0.65rem 0; text-decoration: none; }
.buddy-header nav a:hover, .buddy-header nav a:focus-visible { color: var(--ink); }
.account-button { min-height: 2.5rem; padding: 0 0.85rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); cursor: pointer; }

main, .buddy-footer { width: min(1440px, calc(100% - 2rem)); margin: 0 auto; }
.buddy-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; padding: clamp(2rem, 5vw, 3.8rem) 0 1.5rem; }
.eyebrow, .step-label { margin: 0 0 0.55rem; color: var(--green); font-size: 0.72rem; font-weight: 900; letter-spacing: 0; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { max-width: 18ch; margin: 0; font-size: clamp(2.1rem, 5vw, 4.6rem); line-height: 0.98; }
h2 { margin: 0; font-size: clamp(1.2rem, 2vw, 1.65rem); }
h3 { margin: 0; font-size: 0.78rem; text-transform: uppercase; }
.session-summary { display: flex; align-items: center; gap: 0.55rem; max-width: 25rem; color: var(--muted); font-size: 0.84rem; text-align: right; }
.status-dot { flex: 0 0 auto; width: 0.58rem; height: 0.58rem; border-radius: 50%; background: var(--gold); }
.status-dot.ready { background: var(--green); }
.status-dot.error { background: var(--red); }

.buddy-workspace { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(22rem, 0.85fr); min-height: 42rem; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.capture-pane, .recommendation-pane { min-width: 0; padding: clamp(1rem, 2.4vw, 1.7rem); }
.recommendation-pane { border-left: 1px solid var(--line); background: #111614; }
.pane-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; min-height: 4.2rem; }
.capture-state, .confidence { flex: 0 0 auto; padding: 0.42rem 0.58rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 0.72rem; font-weight: 800; }
.capture-state.live { border-color: rgba(41, 201, 135, 0.55); color: var(--green); }
.capture-state.captured { border-color: rgba(207, 170, 80, 0.62); color: var(--gold); }
.result-tabs { display: flex; gap: 1.2rem; }
.result-tab { min-height: 2.35rem; padding: 0; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 1.25rem; font-weight: 900; cursor: pointer; }
.result-tab.active { border-color: var(--green); color: var(--ink); }

.capture-stage { position: relative; display: grid; width: 100%; aspect-ratio: 16 / 9; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #080a09; }
.capture-stage video, .capture-stage > img { width: 100%; height: 100%; object-fit: contain; background: #050706; }
.capture-placeholder { display: grid; justify-items: center; gap: 0.45rem; color: var(--muted); text-align: center; }
.capture-placeholder strong { color: var(--ink); }
.capture-placeholder > span { max-width: 28rem; padding: 0 1rem; font-size: 0.82rem; }
.table-visual { position: relative; width: min(56%, 21rem); aspect-ratio: 1.9 / 1; margin-bottom: 0.65rem; border: 2px solid #3f604f; border-radius: 50%; background: #173e2c; box-shadow: inset 0 0 0 0.55rem #0d291d; }
.seat { position: absolute; width: 2.2rem; height: 0.62rem; border-radius: 999px; background: var(--red); }
.seat-top { top: -0.35rem; left: calc(50% - 1.1rem); }
.seat-bottom { bottom: -0.35rem; left: calc(50% - 1.1rem); background: var(--gold); }
.seat-left { top: calc(50% - 0.3rem); left: -0.7rem; transform: rotate(90deg); }
.seat-right { top: calc(50% - 0.3rem); right: -0.7rem; transform: rotate(90deg); }
.community-cards { position: absolute; top: calc(50% - 1rem); left: 50%; display: flex; gap: 0.22rem; transform: translateX(-50%); }
.community-cards i { display: block; width: 1.25rem; height: 2rem; border-radius: 3px; background: #e8e4d9; }

.capture-actions, .analyze-row { display: flex; align-items: center; gap: 0.65rem; margin-top: 0.85rem; }
.button, .icon-button { min-height: 2.85rem; border: 0; border-radius: var(--radius); font-weight: 900; cursor: pointer; }
.button { display: inline-flex; align-items: center; justify-content: center; padding: 0 1rem; }
.button.primary { background: var(--green); color: #06130e; }
.button.secondary { border: 1px solid var(--line); background: var(--surface-raised); color: var(--ink); }
.icon-button { width: 2.85rem; border: 1px solid var(--line); background: transparent; color: var(--red); }
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) { filter: brightness(1.08); }
.button:disabled, .icon-button:disabled { cursor: not-allowed; opacity: 0.42; }

.auth-shell label { display: grid; gap: 0.4rem; color: var(--muted); font-size: 0.78rem; font-weight: 800; }
.auth-shell input { width: 100%; min-height: 2.75rem; padding: 0 0.75rem; border: 1px solid var(--line); border-radius: var(--radius); outline: none; background: #0d1210; color: var(--ink); }
.auth-shell input:focus { border-color: var(--green); }
.analyze-row { justify-content: space-between; min-height: 3.8rem; padding-top: 0.45rem; border-top: 1px solid var(--line); }
.button.analyze { min-width: 12rem; background: var(--gold); color: #151007; }
#captureMessage { margin: 0; color: var(--muted); font-size: 0.8rem; text-align: right; }
#captureMessage.error { color: #ff9c8e; }

.result-empty, .result-loading { display: grid; min-height: 31rem; place-content: center; justify-items: center; gap: 0.55rem; color: var(--muted); text-align: center; }
.result-empty p, .result-loading p { max-width: 24rem; margin: 0; font-size: 0.86rem; line-height: 1.5; }
.result-empty strong, .result-loading strong { color: var(--ink); }
.result-mark { display: grid; width: 4.5rem; height: 4.5rem; margin-bottom: 0.6rem; place-items: center; border: 1px solid var(--green); border-radius: 50%; color: var(--green); font-weight: 900; }
.thinking-bar { display: block; width: 10rem; height: 0.35rem; overflow: hidden; border-radius: 999px; background: var(--line); }
.thinking-bar::after { display: block; width: 42%; height: 100%; border-radius: inherit; background: var(--green); content: ""; animation: thinking 1.1s ease-in-out infinite alternate; }
@keyframes thinking { from { transform: translateX(0); } to { transform: translateX(140%); } }

.result-content { display: grid; gap: 1.25rem; padding-top: 0.75rem; }
.result-action-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.75rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.recommendation-action { color: var(--green); font-size: clamp(2rem, 5vw, 4rem); font-weight: 950; line-height: 0.95; }
.recommendation-action.need-more-info { color: var(--gold); font-size: clamp(1.7rem, 4vw, 3rem); }
.recommendation-sizing { color: var(--muted); font-weight: 800; }
.result-summary { margin: 0; color: var(--ink); font-size: 1.08rem; line-height: 1.55; }
.result-content section { display: grid; gap: 0.6rem; }
.result-content h3 { color: var(--gold); }
.result-content ul { display: grid; gap: 0.5rem; margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.88rem; line-height: 1.45; }
.result-disclaimer { margin: 0; padding: 0.85rem; border-left: 3px solid var(--red); background: #211817; color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
.result-footer { display: flex; justify-content: space-between; gap: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--line); color: var(--dim); font-size: 0.7rem; }

.history-panel { min-height: 31rem; }
.history-message { min-height: 1.4rem; margin: 0 0 0.85rem; color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.history-message.error { color: #ff9c8e; }
.history-list { display: grid; gap: 0.65rem; margin: 0; padding: 0; list-style: none; }
.history-entry { width: 100%; min-height: 6.5rem; padding: 0.85rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-raised); color: var(--ink); text-align: left; cursor: pointer; }
.history-entry:hover { border-color: rgba(41, 201, 135, 0.55); }
.history-entry time, .history-entry span { display: block; color: var(--muted); font-size: 0.76rem; line-height: 1.4; }
.history-entry strong { display: block; margin: 0.35rem 0; color: var(--green); font-size: 1rem; }
.history-load { width: 100%; margin-top: 0.85rem; }
.history-back { justify-self: start; padding: 0; border: 0; background: transparent; color: var(--green); font-weight: 800; cursor: pointer; }
.history-meta { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.history-time { color: var(--muted); font-size: 0.78rem; }
.history-screenshot { width: 100%; max-height: 24rem; object-fit: contain; border: 1px solid var(--line); border-radius: var(--radius); background: #050706; }

.responsibility-band { display: grid; grid-template-columns: minmax(12rem, 0.4fr) minmax(0, 1fr); gap: 1.5rem; margin-top: 1rem; padding: 1.1rem 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); }
.responsibility-band strong { color: var(--gold); }
.responsibility-band p { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.55; }
.buddy-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 2rem 0 2.8rem; color: var(--dim); font-size: 0.78rem; }
.buddy-footer a { text-decoration: none; }

.auth-dialog { width: min(30rem, calc(100% - 2rem)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55); }
.auth-dialog::backdrop { background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(5px); }
.auth-shell { display: grid; gap: 1rem; padding: 1.25rem; }
.auth-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.dialog-close { width: 2.4rem; height: 2.4rem; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.4rem; cursor: pointer; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; padding: 0.3rem; border: 1px solid var(--line); border-radius: var(--radius); }
.auth-tab { min-height: 2.5rem; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-weight: 800; cursor: pointer; }
.auth-tab.active { background: var(--green-dark); color: var(--green); }
.auth-message { min-height: 1.2rem; margin: 0; color: var(--muted); font-size: 0.8rem; }
.auth-message.error { color: #ff9c8e; }

@media (max-width: 920px) {
  .buddy-workspace { grid-template-columns: 1fr; }
  .recommendation-pane { border-top: 1px solid var(--line); border-left: 0; }
  .result-empty, .result-loading, .history-panel { min-height: 20rem; }
}

@media (max-width: 640px) {
  .buddy-header { align-items: flex-start; flex-direction: column; }
  .buddy-header nav { width: 100%; justify-content: space-between; }
  .buddy-heading { align-items: flex-start; flex-direction: column; gap: 1rem; }
  .session-summary { text-align: left; }
  .result-tabs { gap: 0.9rem; }
  .result-tab { font-size: 1.05rem; }
  .capture-actions { flex-wrap: wrap; }
  .button.primary, .button.secondary { flex: 1 1 9rem; }
  .analyze-row { align-items: stretch; flex-direction: column; }
  #captureMessage { text-align: left; }
  .responsibility-band { grid-template-columns: 1fr; }
  .buddy-footer { align-items: flex-start; flex-direction: column; }
}
