:root {
  --bg: #0f1114;
  --bg-2: #161a1f;
  --card: #1b2026;
  --line: #2a3039;
  --text: #e9e6e0;
  --muted: #959aa3;
  --accent: #e6a85c;       /* warmes Bernstein */
  --accent-2: #f3c78f;
  --ok: #7fc8a0;
  --danger: #e4776b;
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #1d222a 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h2 { margin: 4px 0 6px; font-size: 1.5rem; letter-spacing: -0.01em; }
h3 { margin: 0 0 10px; font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); min-height: 1.4em; margin: 8px 0 0; }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-title { margin: 18px 0 2px; font-weight: 600; letter-spacing: 0.02em; }
.login form { display: grid; gap: 10px; margin-top: 18px; }
.mark {
  width: 72px; height: 72px; margin: 0 auto; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent-2), var(--accent) 45%, #8a5a26 100%);
  box-shadow: 0 0 40px rgba(230, 168, 92, 0.35);
}

input, select, textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.45; }

.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 16px;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
  text-decoration: none; display: inline-block; text-align: center;
}
.btn:hover { border-color: #3a424d; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1208; font-weight: 600; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #0c1a12; font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- App-Rahmen ---------- */
.app { display: flex; flex-direction: column; min-height: 100%; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: rgba(15, 17, 20, 0.82); backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(42, 48, 57, 0.6);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: 0.03em; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.off { background: var(--danger); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.badge { font-size: 0.75rem; padding: 3px 9px; border-radius: 99px; background: rgba(230,168,92,.14); color: var(--accent-2); border: 1px solid rgba(230,168,92,.35); }
.icon-btn { background: none; border: 0; padding: 8px; border-radius: 10px; color: var(--text); cursor: pointer; }
.icon-btn[aria-pressed="false"] { color: var(--muted); }
.icon-btn[aria-pressed="false"] .wave { opacity: 0; }

main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 16px 16px calc(96px + var(--safe-b)); }
.view { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Gespräch: die Sonne (unten) ---------- */


/* ---------- Karten ---------- */
.cards { display: grid; gap: 14px; margin-top: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.card-title { font-weight: 600; }
.card-meta { color: var(--muted); font-size: .85rem; margin: 2px 0 10px; overflow-wrap: anywhere; }
.card .note { font-size: .85rem; color: var(--accent-2); background: rgba(230,168,92,.08); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; }
.card textarea { min-height: 180px; }
.card .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.empty { color: var(--muted); text-align: center; padding: 40px 10px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- Gedächtnis ---------- */
.memory-form { display: grid; grid-template-columns: 130px 1fr; gap: 8px; margin: 14px 0 18px; }
.memory-form textarea, .memory-form button { grid-column: 1 / -1; }
.list { display: grid; gap: 8px; }
.mem { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.mem .tag { flex: none; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-2); border: 1px solid rgba(230,168,92,.35); border-radius: 6px; padding: 1px 6px; margin-top: 3px; }
.mem .body { flex: 1; min-width: 0; }
.mem .subject { font-weight: 600; }
.mem .del { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px 6px; font-size: 1.1rem; }

/* ---------- Protokoll ---------- */
.timeline { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 2px; }
.timeline li { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid rgba(42,48,57,.6); }
.timeline time { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.timeline .k-sent { color: var(--ok); }
.timeline .k-error { color: var(--danger); }

/* ---------- Einstellungen ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 14px; }
.panel label { display: block; margin-bottom: 8px; color: var(--muted); font-size: .9rem; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.conn { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid rgba(42,48,57,.6); }
.conn:last-child { border-bottom: 0; }
.conn .who { min-width: 0; }
.conn .who small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.status-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; }
.status-list dt { color: var(--muted); }
.status-list dd { margin: 0; overflow-wrap: anywhere; }
code { background: var(--bg-2); padding: 1px 6px; border-radius: 6px; font-size: .85em; }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + var(--safe-b)); background: rgba(15, 17, 20, 0.92); backdrop-filter: blur(14px);
  border-top: 1px solid rgba(42, 48, 57, 0.7);
}
.tabbar a { position: relative; display: grid; justify-items: center; gap: 2px; padding: 6px 0; color: var(--muted); text-decoration: none; font-size: .7rem; }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.active { color: var(--accent-2); }
.count { position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #1a1208; font-size: .7rem; line-height: 18px; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%); z-index: 10;
  background: #2a2f37; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; max-width: calc(100% - 32px);
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}

/* ---------- Sonne: die ganze Oberfläche beim Gespräch ---------- */
/* Auf der Sonne sind Kopfzeile und Leiste ausgeblendet. Die Sonne ist die einzige Fläche. */
body[data-view="gespraech"] .topbar,
body[data-view="gespraech"] .tabbar { display: none; }

#view-gespraech { position: fixed; inset: 0; display: grid; place-items: center; overflow: hidden; }
.sun {
  position: relative; width: min(74vw, 340px); aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%;
  background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.sun:focus-visible { outline: 2px solid var(--accent); outline-offset: 8px; }
/* Gleiche Sonne wie das App-Icon: goldener Kern mit feinem Ring */
.sun-orb {
  position: absolute; inset: 20.5%; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #f6d3a4 0%, #e6a85c 45%, #8a5a26 100%);
  box-shadow: 0 0 60px rgba(230, 168, 92, .35), 0 0 150px rgba(230, 168, 92, .15);
}
.sun-halo { position: absolute; inset: 14%; border-radius: 50%; border: 3px solid rgba(230, 168, 92, .25); }
.sun-orb, .sun-halo { transition: filter .3s ease, border-color .3s ease, border-width .3s ease; }
.sun[data-hoert="ja"] .sun-halo { border-color: #f6d3a4; border-width: 6px; }
.sun[data-hoert="ja"] .sun-orb { filter: brightness(1.3); }

.sun[data-mode="idle"] .sun-orb { animation: atmen 6s ease-in-out infinite; }
.sun[data-mode="listening"] .sun-orb { animation: zuhoeren 1.8s ease-in-out infinite; }
.sun[data-mode="listening"] .sun-halo { border-color: rgba(243, 199, 143, .9); border-width: 4px; animation: welle 1.4s ease-out infinite; }
.sun[data-mode="starting"] .sun-orb { animation: atmen 1.6s ease-in-out infinite; }
.sun[data-mode="starting"] .sun-halo { border-color: rgba(230, 168, 92, .5); animation: atmen 1.6s ease-in-out infinite; }
.sun[data-mode="thinking"] .sun-orb { animation: denken 2.4s ease-in-out infinite; }
.sun[data-mode="thinking"] .sun-halo { border-style: dashed; border-color: rgba(243, 199, 143, .6); animation: kreisen 5s linear infinite; }
.sun[data-mode="speaking"] .sun-orb { animation: sprechen .7s ease-in-out infinite alternate; }
.sun[data-mode="speaking"] .sun-halo { border-color: rgba(243, 199, 143, .75); animation: welle 1.2s ease-out infinite; }

@keyframes atmen { 0%, 100% { transform: scale(1); filter: brightness(1); } 50% { transform: scale(1.025); filter: brightness(1.07); } }
@keyframes zuhoeren { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes welle { 0% { transform: scale(.94); opacity: .9; } 100% { transform: scale(1.14); opacity: 0; } }
@keyframes denken { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.14); } }
@keyframes kreisen { to { transform: rotate(360deg); } }
@keyframes sprechen { from { transform: scale(1); } to { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .sun *, .sun { animation: none !important; } }

.gear {
  position: absolute; top: calc(12px + var(--safe-t)); right: 12px; padding: 10px; border: 0; border-radius: 12px;
  background: none; color: var(--muted); cursor: pointer;
}

@media (min-width: 900px) {
  .tabbar { top: 0; bottom: 0; right: auto; width: 92px; grid-template-columns: 1fr; grid-auto-rows: min-content; align-content: center; gap: 10px; border-top: 0; border-right: 1px solid rgba(42,48,57,.7); }
  .app { padding-left: 92px; }
  main { padding-bottom: 40px; }
  .toast { bottom: 100px; }
}
