/* ═══════════════════════════════════════════════════════════════════
   TAALGENOOT — Application Stylesheet
   Design: Literary · Refined · South African
   Fonts:  Lora (display) · DM Sans (body)
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ─────────────────────────────────────────────── */
:root {
  /* Colour palette */
  --col-bg:          #141210;
  --col-surface:     #1c1916;
  --col-surface-2:   #242018;
  --col-surface-3:   #2e2820;
  --col-border:      #352e24;
  --col-border-2:    #463e32;

  --col-gold:        #c8921a;
  --col-gold-light:  #e0aa38;
  --col-gold-dim:    rgba(200, 146, 26, 0.12);
  --col-gold-glow:   rgba(200, 146, 26, 0.25);
  --col-rust:        #a84422;
  --col-rust-light:  #c45530;
  --col-green:       #4a7a48;
  --col-green-light: #5d9a5a;

  --col-text:        #f0e6d4;
  --col-text-2:      #a89478;
  --col-text-3:      #6b5a44;

  /* Typography */
  --font-display: 'Lora', Georgia, 'Times New Roman', serif;
  --font-body:    'DM Sans', system-ui, -apple-system, sans-serif;

  /* Spacing scale (8px base) */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;

  /* Border radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 40px rgba(0,0,0,0.6);
  --shadow-gold: 0 0 20px rgba(200,146,26,0.2);

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 120ms;
  --t-base: 200ms;
  --t-slow: 350ms;

  /* Layout */
  --header-h: 56px;
  --tabnav-h: 44px;
}

/* ─── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  height: 100%;
  overflow: hidden;          /* App shell — panels handle their own scroll */
  background: var(--col-bg);
  color: var(--col-text);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Screen-reader only utility */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--col-border-2); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--col-text-3); }

/* ─── App Shell ──────────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;         /* dvh for mobile browser chrome */
  height: 100vh;          /* fallback */
  overflow: hidden;
}

/* ─── Header ─────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 var(--sp-5);
  background: var(--col-surface);
  border-bottom: 1px solid var(--col-border);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.header__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--col-gold), var(--col-rust));
  border-radius: var(--r-md);
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: #1a1208;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: var(--shadow-gold);
  letter-spacing: -1px;
}

.header__title-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.header__title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--col-gold-light);
  letter-spacing: -0.02em;
  line-height: 1;
}

.header__subtitle {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--col-text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ─── Icon Button ────────────────────────────────────────────────── */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-sm);
  color: var(--col-text-2);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}

.btn-icon:hover {
  background: var(--col-surface-3);
  color: var(--col-text);
  border-color: var(--col-border-2);
}

.btn-icon:focus-visible {
  outline: 2px solid var(--col-gold);
  outline-offset: 2px;
}

/* User button */
.btn-user {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 34px;
  padding: 0 var(--sp-3);
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-full);
  color: var(--col-text-2);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}

.btn-user:hover {
  background: var(--col-surface-3);
  color: var(--col-text);
  border-color: var(--col-gold);
}

.btn-user:focus-visible {
  outline: 2px solid var(--col-gold);
  outline-offset: 2px;
}

.btn-user__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, var(--col-gold), var(--col-rust));
  border-radius: 50%;
  color: #1a1208;
}

.btn-user__name {
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Tab Navigation ─────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  height: var(--tabnav-h);
  background: var(--col-surface);
  border-bottom: 1px solid var(--col-border);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 0 var(--sp-2);
}

.tab-nav::-webkit-scrollbar { display: none; }

.tab-nav__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  height: 100%;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--col-text-3);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}

.tab-nav__item:hover {
  color: var(--col-text-2);
}

.tab-nav__item.is-active {
  color: var(--col-gold-light);
  border-bottom-color: var(--col-gold);
}

.tab-nav__item:focus-visible {
  outline: 2px solid var(--col-gold);
  outline-offset: -2px;
}

/* ─── Panel Container ────────────────────────────────────────────── */
/*
   KEY LAYOUT PRINCIPLE:
   The container is a relative positioned block that fills all
   remaining vertical space. Each .panel sits as absolute, inset:0,
   and is hidden by default. Only .panel.is-active is shown.
   No other rule may set display on .panel — ever.
*/
.panel-container {
  position: relative;
  flex: 1;
  overflow: hidden;        /* Panels handle their own internal scroll */
}

/* ─── Panel Base ─────────────────────────────────────────────────── */
/*
   All panels: hidden by default.
   display:none removes from layout AND accessibility tree correctly.
   The active panel is shown with a single rule below.
   Note: panel--chat uses flex internally (column); panel--scroll uses block.
*/
.panel {
  position: absolute;
  inset: 0;
  display: none;           /* Hidden: only ONE rule sets display */
  overflow: hidden;
}

/* Active panel — show it */
.panel.is-active {
  display: flex;
  flex-direction: column;
  animation: panelIn var(--t-base) var(--ease) both;
}

/* Scroll panels use block internally, so override flex */
.panel--scroll.is-active {
  display: block;
  overflow-y: auto;
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Panel Inner (for padding + max-width) ──────────────────────── */
.panel__inner {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.panel__header {
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--col-border);
}

.panel__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--col-gold-light);
  margin-bottom: var(--sp-1);
}

.panel__desc {
  font-size: 0.82rem;
  color: var(--col-text-2);
}

/* ─── Chat Panel ─────────────────────────────────────────────────── */
.panel--chat {
  /* display is set by .panel.is-active — flex column */
}

.chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* Welcome screen */
.chat__welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-4);
  padding: var(--sp-8) var(--sp-4);
  max-width: 440px;
  margin: 0 auto;
}

.welcome__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--col-gold), var(--col-rust));
  border-radius: var(--r-xl);
  font-family: var(--font-display);
  font-size: 2rem;
  color: #1a1208;
  font-weight: 700;
  box-shadow: var(--shadow-gold);
  letter-spacing: -2px;
}

.welcome__title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--col-gold-light);
  letter-spacing: -0.02em;
}

.welcome__subtitle {
  font-size: 0.9rem;
  color: var(--col-text-2);
  line-height: 1.65;
}

.welcome__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: center;
}

/* ─── Chat Messages ──────────────────────────────────────────────── */
.message {
  display: flex;
  gap: var(--sp-3);
  max-width: min(85%, 580px);
  animation: msgIn var(--t-slow) cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.message--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message--assistant {
  align-self: flex-start;
}

.message__avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 3px;
}

.message--user .message__avatar {
  background: var(--col-rust);
  color: #fff;
}

.message--assistant .message__avatar {
  background: linear-gradient(135deg, var(--col-gold), var(--col-rust));
  color: #1a1208;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: var(--shadow-gold);
}

.message__body {
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  font-size: 0.9rem;
  line-height: 1.7;
  word-break: break-word;
}

.message--user .message__body {
  background: var(--col-rust);
  border-color: var(--col-rust-light);
  color: #ffe8dc;
  border-radius: var(--r-lg) var(--r-lg) var(--r-sm) var(--r-lg);
}

.message--assistant .message__body {
  border-radius: var(--r-lg) var(--r-lg) var(--r-lg) var(--r-sm);
}

/* Markdown rendering in AI messages */
.message__body strong { color: var(--col-gold-light); font-weight: 600; }
.message__body em     { color: var(--col-text-2); font-style: italic; }
.message__body code   {
  background: var(--col-bg);
  border: 1px solid var(--col-border);
  border-radius: var(--r-sm);
  padding: 0.1em 0.35em;
  font-size: 0.85em;
  color: var(--col-gold);
  font-family: 'Consolas', 'Monaco', monospace;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  align-self: flex-start;
}

.typing-indicator__dots {
  display: flex;
  gap: 4px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-lg) var(--r-lg) var(--r-lg) var(--r-sm);
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--col-gold);
  border-radius: 50%;
  opacity: 0.4;
  animation: typingPulse 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingPulse {
  0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
  30%            { opacity: 1;   transform: translateY(-4px); }
}

/* ─── Chat Footer ────────────────────────────────────────────────── */
.chat__footer {
  flex-shrink: 0;
  padding: var(--sp-3) var(--sp-5);
  background: var(--col-surface);
  border-top: 1px solid var(--col-border);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

/* Mode pills */
.chat__modes {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.chat__modes::-webkit-scrollbar { display: none; }

.mode-pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 var(--sp-3);
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-full);
  color: var(--col-text-2);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--t-fast) var(--ease);
}

.mode-pill:hover {
  border-color: var(--col-border-2);
  color: var(--col-text);
}

.mode-pill.is-active {
  background: var(--col-gold-dim);
  border-color: var(--col-gold);
  color: var(--col-gold-light);
}

.mode-pill:focus-visible {
  outline: 2px solid var(--col-gold);
  outline-offset: 1px;
}

/* Input row */
.chat__input-row {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-end;
}

.chat__input {
  flex: 1;
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  color: var(--col-text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.5;
  resize: none;
  min-height: 44px;
  max-height: 140px;
  overflow-y: auto;
  transition: border-color var(--t-fast) var(--ease);
}

.chat__input::placeholder { color: var(--col-text-3); }

.chat__input:focus {
  outline: none;
  border-color: var(--col-gold);
}

.chat__send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--col-gold), var(--col-gold-light));
  border: none;
  border-radius: var(--r-md);
  color: #1a1208;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              opacity var(--t-fast) var(--ease);
  box-shadow: 0 2px 8px rgba(200,146,26,0.3);
}

.chat__send:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(200,146,26,0.45);
}

.chat__send:active:not(:disabled) { transform: translateY(0); }

.chat__send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.chat__send:focus-visible {
  outline: 2px solid var(--col-gold-light);
  outline-offset: 2px;
}

/* Export bar */
.chat__export {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.chat__export-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--col-text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: var(--sp-1);
}

.export-btn {
  height: 24px;
  padding: 0 var(--sp-3);
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-full);
  color: var(--col-text-2);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}

.export-btn:hover {
  border-color: var(--col-gold);
  color: var(--col-gold-light);
}

.export-btn--clear {
  margin-left: auto;
  border-color: rgba(168,68,34,0.4);
  color: var(--col-rust-light);
}

.export-btn--clear:hover {
  border-color: var(--col-rust-light);
  background: rgba(168,68,34,0.12);
}

/* ─── Quick Chips ────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 var(--sp-4);
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-full);
  color: var(--col-text-2);
  font-family: var(--font-body);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}

.chip:hover {
  border-color: var(--col-gold);
  color: var(--col-gold-light);
  background: var(--col-gold-dim);
}

.chip:focus-visible {
  outline: 2px solid var(--col-gold);
  outline-offset: 2px;
}

/* ─── Translate Panel ────────────────────────────────────────────── */
.translate__layout {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--col-border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.translate__box {
  display: flex;
  flex-direction: column;
}

.translate__lang-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  background: var(--col-surface-2);
  border-bottom: 1px solid var(--col-border);
}

.translate__lang-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--col-text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.translate__lang-flag { font-size: 1.1rem; }

.translate__area {
  background: transparent;
  border: none;
  padding: var(--sp-4);
  color: var(--col-text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  resize: none;
  min-height: 120px;
}

.translate__area:focus { outline: none; }
.translate__area::placeholder { color: var(--col-text-3); }

.translate__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-3) 0;
  background: var(--col-surface-2);
  border-top: 1px solid var(--col-border);
  border-bottom: 1px solid var(--col-border);
}

.translate__swap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--col-surface-3);
  border: 1px solid var(--col-border-2);
  border-radius: 50%;
  color: var(--col-gold);
  cursor: pointer;
  transition: all var(--t-base) var(--ease);
}

.translate__swap:hover {
  background: var(--col-gold-dim);
  border-color: var(--col-gold);
  transform: rotate(180deg);
}

.translate__result {
  padding: var(--sp-4);
  min-height: 120px;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--col-gold-light);
  font-style: italic;
  white-space: pre-wrap;
}

.translate__placeholder {
  color: var(--col-text-3);
  font-style: normal;
  font-size: 0.875rem;
}

.translate__actions {
  display: flex;
  gap: var(--sp-3);
}

/* ─── Tool Panels (Grammar, Dictionary, Proverbs) ────────────────── */
.tool__textarea {
  width: 100%;
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  color: var(--col-text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.7;
  resize: vertical;
  min-height: 160px;
  transition: border-color var(--t-fast) var(--ease);
}

.tool__textarea:focus {
  outline: none;
  border-color: var(--col-gold);
}

.tool__textarea::placeholder { color: var(--col-text-3); }

.tool__search-row {
  display: flex;
  gap: var(--sp-3);
}

.tool__input {
  flex: 1;
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-md);
  padding: 0 var(--sp-4);
  height: 44px;
  color: var(--col-text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: border-color var(--t-fast) var(--ease);
}

.tool__input:focus {
  outline: none;
  border-color: var(--col-gold);
}

.tool__input::placeholder { color: var(--col-text-3); }

.tool__tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.tag-btn {
  height: 28px;
  padding: 0 var(--sp-3);
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-full);
  color: var(--col-text-2);
  font-family: var(--font-body);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}

.tag-btn:hover {
  border-color: var(--col-gold);
  color: var(--col-gold-light);
}

/* Result area */
.tool__result {
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-md);
  padding: var(--sp-5);
  font-size: 0.875rem;
  line-height: 1.8;
  color: var(--col-text);
}

.tool__result strong { color: var(--col-gold-light); }
.tool__result em     { color: var(--col-text-2); }
.tool__result h3     { color: var(--col-gold-light); font-family: var(--font-display); margin: var(--sp-4) 0 var(--sp-2); }
.tool__result p      { margin-bottom: var(--sp-3); }

/* ─── About Panel ────────────────────────────────────────────────── */
.about__hero {
  background: linear-gradient(135deg, var(--col-surface-2), var(--col-surface));
  border: 1px solid var(--col-border);
  border-radius: var(--r-xl);
  padding: var(--sp-8) var(--sp-6);
  text-align: center;
}

.about__logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--col-gold), var(--col-rust));
  border-radius: var(--r-xl);
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: #1a1208;
  font-weight: 700;
  box-shadow: var(--shadow-gold);
  margin-bottom: var(--sp-4);
}

.about__title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--col-gold-light);
  margin-bottom: var(--sp-1);
}

.about__version {
  font-size: 0.8rem;
  color: var(--col-text-3);
}

.about__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
}

.about__card {
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--col-text-2);
  text-align: center;
}

.about__card-icon { font-size: 1.6rem; }

.about__section {
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-md);
  padding: var(--sp-5);
}

.about__section h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--col-text);
  margin-bottom: var(--sp-3);
}

.about__section p {
  font-size: 0.875rem;
  color: var(--col-text-2);
  line-height: 1.75;
}

.about__footer {
  text-align: center;
  font-size: 0.78rem;
  color: var(--col-text-3);
  padding: var(--sp-2) 0 var(--sp-4);
}

.about__footer a {
  color: var(--col-gold);
  text-decoration: none;
}

.about__footer a:hover { text-decoration: underline; }

/* ─── Buttons ────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 var(--sp-6);
  background: linear-gradient(135deg, var(--col-gold), var(--col-gold-light));
  border: none;
  border-radius: var(--r-md);
  color: #1a1208;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              opacity var(--t-fast) var(--ease);
  box-shadow: 0 2px 8px rgba(200,146,26,0.3);
  white-space: nowrap;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(200,146,26,0.45);
}

.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary:focus-visible {
  outline: 2px solid var(--col-gold-light);
  outline-offset: 2px;
}

.btn-primary.btn--full { width: 100%; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 var(--sp-5);
  background: var(--col-surface-2);
  border: 1px solid var(--col-border-2);
  border-radius: var(--r-md);
  color: var(--col-text-2);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  white-space: nowrap;
}

.btn-secondary:hover {
  color: var(--col-text);
  border-color: var(--col-gold);
}

.btn-secondary.btn--full { width: 100%; }

.btn-link {
  background: none;
  border: none;
  color: var(--col-gold);
  font-family: var(--font-body);
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.btn-link:hover { color: var(--col-gold-light); }

/* ─── Dialogs ────────────────────────────────────────────────────── */
/* ─── Dialog base ────────────────────────────────────────────────── */
/*
   CRITICAL: showModal() places <dialog> in the browser's top layer and
   centres it automatically via UA stylesheet `margin: auto`.
   DO NOT add position:fixed or inset:0 — that fights the top-layer and
   pins the dialog to the viewport corner instead of centring it.
   All we need: reset padding/border/background and let the browser do
   the centering. The .dialog__inner card provides all visual styling.
*/
dialog {
  border: none;
  padding: var(--sp-4);      /* breathing room from viewport edge */
  background: transparent;
  outline: none;
  /* Constraints so content never touches the screen edge */
  max-width:  calc(100vw - var(--sp-8));
  max-height: calc(100dvh - var(--sp-8));
  /* Browser default: margin:auto → centres the dialog. Keep it. */
}

/* Shared backdrop */
dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

/* Animation on the dialog element when opened */
dialog[open] {
  animation: dialogFadeIn var(--t-base) var(--ease) both;
}

@keyframes dialogFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* The visual card inside the dialog */
.dialog__inner {
  background: var(--col-surface);
  border: 1px solid var(--col-border-2);
  border-radius: var(--r-xl);
  padding: var(--sp-8);
  width: 100%;
  max-width: 400px;
  max-height: 85dvh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: dialogIn var(--t-base) var(--ease) both;
}

@keyframes dialogIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.dialog__close {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-sm);
  color: var(--col-text-2);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}

.dialog__close:hover {
  color: var(--col-text);
  border-color: var(--col-border-2);
}

.dialog__title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--col-gold-light);
  margin-bottom: var(--sp-5);
}

.dialog__desc {
  font-size: 0.875rem;
  color: var(--col-text-2);
  margin-bottom: var(--sp-5);
  margin-top: calc(-1 * var(--sp-3));
}

/* Search dialog variant — wider card */
.dialog--search {
  padding: 0;
  max-width: min(560px, calc(100vw - var(--sp-8)));
}

.dialog--search .dialog__inner {
  max-width: 100%;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 75dvh;
  animation: none; /* parent dialog already animates */
}

/* ─── Dialog Tabs ────────────────────────────────────────────────── */
.dialog-tabs {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
  background: var(--col-surface-2);
  border-radius: var(--r-md);
  padding: var(--sp-1);
}

.dialog-tab {
  flex: 1;
  height: 34px;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  color: var(--col-text-2);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}

.dialog-tab:hover { color: var(--col-text); }

.dialog-tab.is-active {
  background: var(--col-surface-3);
  color: var(--col-gold-light);
}

/* ─── Forms ──────────────────────────────────────────────────────── */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--col-text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  height: 44px;
  padding: 0 var(--sp-4);
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-md);
  color: var(--col-text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: border-color var(--t-fast) var(--ease);
}

.form-input:focus {
  outline: none;
  border-color: var(--col-gold);
}

.form-input::placeholder { color: var(--col-text-3); }

.form-error {
  background: rgba(168, 68, 34, 0.12);
  border: 1px solid rgba(168, 68, 34, 0.35);
  border-radius: var(--r-sm);
  padding: var(--sp-3) var(--sp-4);
  font-size: 0.82rem;
  color: #e07050;
}

.form-success {
  background: rgba(74, 122, 72, 0.12);
  border: 1px solid rgba(74, 122, 72, 0.35);
  border-radius: var(--r-sm);
  padding: var(--sp-3) var(--sp-4);
  font-size: 0.82rem;
  color: var(--col-green-light);
}

/* Auth user card */
.auth-user-card {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-5);
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-4);
}

.auth-user-card__avatar {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--col-gold), var(--col-rust));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1208;
  flex-shrink: 0;
}

.auth-user-card__name {
  font-weight: 600;
  color: var(--col-text);
  margin-bottom: 2px;
}

.auth-user-card__email {
  font-size: 0.8rem;
  color: var(--col-text-2);
}

.auth-stats {
  display: flex;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.auth-stat {
  flex: 1;
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-1);
}

.auth-stat__value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--col-gold-light);
}

.auth-stat__label {
  font-size: 0.7rem;
  color: var(--col-text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── History Drawer ─────────────────────────────────────────────── */
/* ─── History Drawer ─────────────────────────────────────────────── */
/*
   The drawer is a full-viewport <dialog> with content sliding from the left.
   We override the browser's centering by giving it explicit 100vw × 100dvh
   dimensions and margin:0, then use flexbox to push .drawer__inner to the left.
*/
.drawer {
  border: none;
  outline: none;
  background: transparent;
  padding: 0;
  margin: 0;
  width:      100vw;
  height:     100dvh;
  height:     100vh;   /* fallback */
  max-width:  100vw;
  max-height: 100dvh;
}

.drawer[open] {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
}

.drawer::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
}

.drawer__inner {
  width: 300px;
  max-width: 85vw;
  height: 100%;
  background: var(--col-surface);
  border-right: 1px solid var(--col-border);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideIn var(--t-slow) var(--ease) both;
}

@keyframes slideIn {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-5);
  border-bottom: 1px solid var(--col-border);
  flex-shrink: 0;
}

.drawer__title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--col-gold-light);
}

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-3);
}

.drawer__empty {
  font-size: 0.82rem;
  color: var(--col-text-3);
  text-align: center;
  padding: var(--sp-8) var(--sp-4);
  line-height: 1.6;
}

.drawer__footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--col-border);
  flex-shrink: 0;
}

/* History items */
.history-item {
  display: block;
  width: 100%;
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-2);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--t-fast) var(--ease);
}

.history-item:hover { border-color: var(--col-gold); }

.history-item__title {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--col-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: var(--sp-1);
}

.history-item__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--col-text-3);
}

.history-item__del {
  background: none;
  border: none;
  color: var(--col-rust);
  cursor: pointer;
  font-size: 0.72rem;
  padding: 0 var(--sp-1);
  opacity: 0.6;
  transition: opacity var(--t-fast);
}

.history-item__del:hover { opacity: 1; }

/* ─── Search Dialog ──────────────────────────────────────────────── */
.search__header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--col-border);
  color: var(--col-text-2);
  flex-shrink: 0;
}

.search__input {
  flex: 1;
  background: none;
  border: none;
  color: var(--col-text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0;
}

.search__input:focus { outline: none; }
.search__input::placeholder { color: var(--col-text-3); }

.search__results {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-3);
}

.search__hint {
  font-size: 0.82rem;
  color: var(--col-text-3);
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
}

.search-hit {
  display: block;
  width: 100%;
  background: var(--col-surface-2);
  border: 1px solid var(--col-border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-2);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--t-fast) var(--ease);
}

.search-hit:hover { border-color: var(--col-gold); }

.search-hit__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--col-text);
  margin-bottom: var(--sp-1);
}

.search-hit__snippet {
  font-size: 0.78rem;
  color: var(--col-text-2);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-hit__snippet mark {
  background: rgba(200, 146, 26, 0.2);
  color: var(--col-gold-light);
  border-radius: 2px;
  padding: 0 2px;
}

.search-hit__meta {
  display: flex;
  gap: var(--sp-3);
  font-size: 0.7rem;
  color: var(--col-text-3);
  margin-top: var(--sp-2);
}

/* ─── Toast Notifications ────────────────────────────────────────── */
.toasts {
  position: fixed;
  top: calc(var(--header-h) + var(--sp-4));
  right: var(--sp-4);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--col-surface-2);
  border: 1px solid var(--col-border-2);
  border-left: 3px solid var(--col-gold);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  font-size: 0.83rem;
  color: var(--col-text);
  box-shadow: var(--shadow-md);
  max-width: 300px;
  pointer-events: auto;
  animation: toastIn var(--t-base) var(--ease) both;
}

.toast--error  { border-left-color: var(--col-rust-light); }
.toast--success{ border-left-color: var(--col-green-light); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─── Loading Spinner ────────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--col-border-2);
  border-top-color: var(--col-gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--col-text-2);
  font-size: 0.85rem;
  padding: var(--sp-5);
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (min-width: 640px) {
  .chat__messages { padding: var(--sp-8) var(--sp-6); }
  .chat__footer   { padding: var(--sp-4) var(--sp-6); }
  .message        { max-width: min(70%, 560px); }
  .about__grid    { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 400px) {
  .about__grid { grid-template-columns: repeat(2, 1fr); }
  .tab-nav__item span { display: none; }
  .tab-nav__item { padding: 0 var(--sp-4); }
}

/* ─── Focus management ───────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--col-gold);
  outline-offset: 2px;
}

/* Remove outline for mouse users */
:focus:not(:focus-visible) { outline: none; }

/* ─── Print ──────────────────────────────────────────────────────── */
@media print {
  .header, .tab-nav, .chat__footer { display: none; }
  body { background: #fff; color: #000; overflow: auto; }
  .panel-container, .panel.is-active { position: static; overflow: visible; }
}
