/* ============================================================
   REKA — Design tokens (unchanged from the widget version —
   the palette/restraint direction was already correct, only the
   *layout* needed to become a normal full-page app instead of a
   floating widget)
   ============================================================ */
:root {
  --color-bg: #FAFAF9;
  --color-surface: #FFFFFF;
  --color-surface-hover: #F4F4F3;
  --color-border: #E7E5E2;
  --color-text: #1C1C1E;
  --color-text-secondary: #6B6B6B;
  --color-gold: #C8960C;
  --color-gold-soft: rgba(200, 150, 12, 0.12);
  --color-anchor: #B8BCC2;

  --radius-bubble: 12px;
  --ease-calm: cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1C1C1E;
    --color-surface: #2A2A2C;
    --color-surface-hover: #333335;
    --color-border: #3A3A3C;
    --color-text: #F5F5F5;
    --color-text-secondary: #9B9B9B;
    --color-gold-soft: rgba(200, 150, 12, 0.18);
    --color-anchor: #5F636B;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

/* ============================================================
   App shell — a self-contained container (not viewport-fixed
   tricks), so this can be dropped into another shell later
   (e.g. embedded inside a different product) without rework.
   Fills its parent; parent is <body> today (full page), could be
   a smaller container in a future embedded context.
   ============================================================ */
.reka-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 100%;
}

.reka-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.reka-logo { width: 24px; height: 24px; object-fit: contain; }

.reka-wordmark {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.2px;
}

.reka-icon-btn {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 6px;
  margin-left: auto;
}
.reka-icon-btn:hover { background: var(--color-surface-hover); }

/* ============================================================
   Status indicator — signature element (Section 9.2). Persistent
   fixture living in the message flow, always right after the
   latest turn (before/during/after any response — never removed).

   Two static poles, always horizontal, connected by a bold string
   (rubber band). A ball is threaded through the middle of that
   string — the ball's live position drives the string's shape
   (it bends to follow the ball, like an actual rubber band with a
   bead pulled through it). The poles never move; only the ball
   and the string's bend represent REKA's current state:
     - idle: ball wanders in bounded, unpredictable directions —
       restless, tethered, can't break free
     - thinking: ball travels along the string, pole to pole,
       string stays straight and taut
     - building: ball pulls straight up/down at the center,
       stretching the string into a V shape and back
   Gold ball, neutral gray poles/string. Actual motion is computed
   in JS (see reka-ball / string-left / string-right in app.js) —
   this file only handles static appearance.
   ============================================================ */
.reka-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 0;
  flex-shrink: 0;
}

.reka-indicator svg { width: 56px; height: 42px; overflow: visible; }
.reka-indicator .pole { fill: var(--color-anchor); }
.reka-indicator .tether { stroke: var(--color-anchor); stroke-width: 2.5; stroke-linecap: round; }
.reka-indicator .ball { fill: var(--color-gold); }

.reka-indicator-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  text-transform: capitalize;
}

/* ============================================================
   Main content area — messages or settings, one visible at a time
   ============================================================ */
.reka-main {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.reka-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

.reka-message {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: var(--radius-bubble);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.reka-message.user {
  align-self: flex-end;
  background: var(--color-gold);
  color: #1C1C1E;
}

.reka-message.assistant {
  align-self: flex-start;
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.reka-message.tool-call {
  align-self: flex-start;
  background: var(--color-gold-soft);
  color: var(--color-text-secondary);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  border: 1px dashed var(--color-gold);
}

.reka-summary-line {
  font-size: 12px;
  font-style: italic;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  opacity: 0.85;
}

.reka-message-body {
  white-space: pre-wrap;
}

/* ============================================================
   Settings — a full view swap within .reka-main, not an overlay
   ============================================================ */
.reka-settings {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.reka-settings-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reka-settings-title-row {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.reka-settings-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.reka-field-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 12px;
  margin-bottom: 4px;
}

.reka-field-input {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 13px;
  color: var(--color-text);
  background: var(--color-bg);
}

.reka-field-input:focus {
  outline: 2px solid var(--color-gold);
  outline-offset: 1px;
}

.reka-model-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.reka-secondary-btn {
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  height: 36px;
}
.reka-secondary-btn:hover { background: var(--color-gold-soft); }
.reka-secondary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.reka-settings-hint {
  font-size: 12px;
  color: var(--color-text-secondary);
  min-height: 16px;
  margin: 10px 0 0;
}
.reka-settings-hint.error { color: #C0392B; }
.reka-settings-hint.success { color: #1D9E75; }

/* Plain show/hide toggle between the message list and settings view */
.view-hidden {
  display: none !important;
}

/* ============================================================
   Input row — fixed at the bottom of the app shell
   ============================================================ */
.reka-input-row {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.reka-input-row textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface);
  max-height: 140px;
}

.reka-input-row textarea:focus {
  outline: 2px solid var(--color-gold);
  outline-offset: 1px;
}

.reka-send-btn {
  background: var(--color-gold);
  color: #1C1C1E;
  border: none;
  border-radius: 10px;
  padding: 0 18px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: filter 0.15s var(--ease-calm);
}
.reka-send-btn:hover { filter: brightness(1.08); }
.reka-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
