/* ORIA KI-Tafel — helles Tafel-Design, Kreide-Optik, Premium */
:root {
  --bg: #f2efe8;            /* warmes Papier */
  --panel: #ffffff;
  --ink: #23201a;
  --muted: #6f6a5e;
  --line: #e3ded2;
  --gold: #b8860b;
  --gold-soft: #f5ecd2;
  --slate: #262b31;         /* Tafel-Fläche */
  --slate-2: #1f2429;
  --chalk: #f5f5f4;
  --accent: #2f6f4f;
  --danger: #a33d2e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(35, 32, 26, .06), 0 8px 24px rgba(35, 32, 26, .08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Topbar ─── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--ink);
  color: #f5f2ea;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .25);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark {
  font-weight: 800;
  letter-spacing: .14em;
  font-size: 17px;
  color: var(--gold);
}
.brand-sub { font-size: 14px; opacity: .85; }
.topbar-status {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #8a8a8a;
  transition: background .3s;
}
.topbar-status.online { background: #5cc77a; box-shadow: 0 0 8px #5cc77a; }
.topbar-status.offline { background: var(--danger); }

/* ─── Layout ─── */
.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 14px 40px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 900px) {
  .layout { grid-template-columns: 1fr 300px; }
  .board-panel { grid-column: 1 / -1; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

/* ─── Tafel ─── */
.board-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, .05), transparent 55%),
    linear-gradient(160deg, var(--slate) 0%, var(--slate-2) 100%);
  border: 6px solid #8a6f45;
  box-shadow: inset 0 2px 18px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .2);
  touch-action: none;
}
#board {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 720;
  cursor: crosshair;
  touch-action: none;
}
.board-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(245, 245, 244, .35);
  font-size: clamp(18px, 3vw, 28px);
  font-style: italic;
  pointer-events: none;
  letter-spacing: .02em;
  transition: opacity .3s;
}
.board-hint.hidden { opacity: 0; }

/* ─── Toolbar ─── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.tool-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: var(--bg);
  border-radius: 10px;
}
.color-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.color-btn.active { box-shadow: 0 0 0 2px var(--gold); transform: scale(1.12); }
.width-btn {
  width: 30px; height: 30px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
}
.width-btn.active { background: var(--gold-soft); color: var(--gold); }
.tool-btn {
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
}
.tool-btn.active { background: var(--gold-soft); border-color: var(--gold); }
.tool-spacer { flex: 1; }
.action-btn {
  border: none;
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: var(--ink);
  color: #fff;
  transition: opacity .15s, transform .1s;
}
.action-btn:disabled { opacity: .35; cursor: default; }
.action-btn:not(:disabled):active { transform: scale(.97); }
.action-btn.record { background: var(--danger); }
.action-btn.record.recording { animation: pulse 1.2s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(163, 61, 46, .5); }
  50%      { box-shadow: 0 0 0 8px rgba(163, 61, 46, 0); }
}

/* ─── KI-Aktionen ─── */
.actions-panel h2 {
  margin: 0 0 12px;
  font-size: 15px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.ki-btn {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 9px;
  transition: border-color .15s, background .15s, transform .1s;
}
.ki-btn:hover:not(:disabled) { border-color: var(--gold); background: var(--gold-soft); }
.ki-btn:active:not(:disabled) { transform: scale(.99); }
.ki-btn:disabled { opacity: .4; cursor: default; }
.ki-btn.primary { background: var(--gold-soft); border-color: var(--gold); }
.ki-hint { display: block; font-size: 11.5px; font-weight: 400; color: var(--muted); margin-top: 2px; }

.formula-box { margin-bottom: 9px; }
.formula-box label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.row { display: flex; gap: 6px; }
#formula-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: "Cascadia Mono", Consolas, monospace;
  background: #fff;
  color: var(--ink);
}
#formula-input:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.row .ki-btn { width: auto; margin-bottom: 0; text-align: center; }

.read-row { display: flex; align-items: center; gap: 8px; }
.read-row .ki-btn { width: auto; margin-bottom: 0; }
#tts-audio { flex: 1; min-width: 0; height: 34px; }

/* ─── Ergebnisse ─── */
.result-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.tab {
  border: none;
  background: transparent;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--ink); border-bottom-color: var(--gold); }
.tab-body { display: none; }
.tab-body.active { display: block; }
.result-empty { color: var(--muted); font-size: 13px; padding: 14px 0; }
.recognized {
  font-size: 17px;
  line-height: 1.55;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 8px;
  white-space: pre-wrap;
  min-height: 40px;
  font-family: "Segoe UI", system-ui, sans-serif;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.mini-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.mini-btn:hover { border-color: var(--gold); }
#plot-result img {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
}
#formula-error, .error-msg {
  margin-top: 8px;
  padding: 9px 11px;
  border-radius: 8px;
  background: #fbeae6;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.4;
}
#explain-result .explain-text { font-size: 15px; line-height: 1.6; margin-bottom: 12px; }
.explain-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.explain-images figure { margin: 0; }
.explain-images img { width: 100%; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.explain-images figcaption { font-size: 11px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sessions-list .session-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 6px;
  border-bottom: 1px solid var(--line);
}
.sessions-list .session-item:last-child { border-bottom: none; }
.session-meta { flex: 1; min-width: 0; }
.session-date { font-size: 11.5px; color: var(--muted); }
.session-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-actions { display: flex; gap: 5px; }

/* ─── 3D-Modal ─── */
.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 16px;
  backdrop-filter: blur(3px);
}
.modal-card {
  background: #fff;
  border-radius: var(--radius);
  width: min(640px, 100%);
  max-height: 92vh;
  overflow: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 0; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { border: none; background: var(--bg); width: 32px; height: 32px; border-radius: 8px; font-size: 15px; cursor: pointer; }
.geo-desc { padding: 8px 16px; font-size: 13.5px; color: var(--muted); font-style: italic; }
#geo-stage { width: 100%; aspect-ratio: 4 / 3; background: radial-gradient(ellipse at center, #2a2f36, #171a1e); border-radius: 10px; overflow: hidden; }
.geo-note { text-align: center; font-size: 11.5px; color: var(--muted); padding: 8px 0 14px; margin: 0; }

/* ─── Loading ─── */
.loading[hidden] { display: none; }
.loading {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(20, 18, 14, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.loading-card {
  background: #fff;
  border-radius: 14px;
  padding: 20px 26px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .3);
}
.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--gold-soft);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { font-size: 14px; font-weight: 600; }

/* ─── Footer ─── */
.footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 14px 34px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}
.footer p { margin: 4px 0; }
.footer-meta { opacity: .7; font-size: 11.5px; }
