/* Urban AI Studio — warmes Premium-Dunkel, Serif-Begruessung, ruhige Karten.
   Self-contained (bindet styles.css NICHT ein — keine globalen Falle-Selektoren). */

:root {
  --bg: #262624;
  --bg-deep: #1f1e1c;
  --panel: #2d2c29;
  --panel-2: #34332f;
  --line: #3d3c37;
  --line-strong: #4a4842;
  --text: #eceae4;          /* ~12:1 auf --bg */
  --muted: #b8b5ac;         /* ~6.5:1 */
  --subtle: #8b887f;        /* ~4.5:1 */
  --cream: #f0eee7;
  --cream-ink: #262624;
  --accent: #4cc8d9;        /* Urban-Cyan, warm abgestimmt */
  --danger: #ff9d8a;

  --serif: "Iowan Old Style", "Palatino", Georgia, "Times New Roman", serif;
  --sans: -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
}

* { box-sizing: border-box; }

/* Eigene display-Regeln (grid/flex) wuerden das UA-Stylesheet fuer [hidden]
   ueberschreiben — deshalb hier hart erzwingen. */
[hidden] { display: none !important; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

button { font-family: var(--sans); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── CTA-Buttons (hell auf dunkel, wie die Vorlage) ───────────────── */
.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--cream);
  color: var(--cream-ink);
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  padding: 12px 20px;
  cursor: pointer;
  transition: opacity 0.2s;
  min-height: 44px;
}
.cta:hover { opacity: 0.9; }
.cta:disabled { opacity: 0.45; cursor: not-allowed; }
.cta-small { font-size: 14px; padding: 9px 16px; min-height: 38px; border-radius: 10px; }

.ghost {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.ghost:hover { color: var(--text); border-color: var(--accent); }

/* ── Zustand 1: Auth ──────────────────────────────────────────────── */
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
}
.auth-logo {
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 20px;
  margin-bottom: 18px;
}
.auth-title {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
  margin: 0 0 6px;
  letter-spacing: 0.01em;
}
.auth-sub { color: var(--muted); margin: 0 0 22px; font-size: 15px; }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg-deep);
  border-radius: var(--radius-md);
  padding: 5px;
  margin-bottom: 20px;
}
.auth-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 0;
  border-radius: 10px;
  cursor: pointer;
  min-height: 40px;
}
.auth-tab.is-active { background: var(--panel-2); color: var(--text); }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 16px; /* >=16px verhindert iOS-Zoom beim Fokus */
  padding: 12px 14px;
  min-height: 46px;
}
.field input::placeholder { color: var(--subtle); }
.field input:focus { border-color: var(--accent); outline: none; }

.auth-error {
  min-height: 20px;
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--danger);
}
#auth-submit { width: 100%; }

.auth-foot {
  display: flex;
  justify-content: space-between;
  margin: 20px 0 0;
  font-size: 13px;
}
.auth-foot a { color: var(--subtle); text-decoration: none; }
.auth-foot a:hover { color: var(--accent); }

/* ── App-Rahmen: Rail links ───────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 64px 1fr;
  min-height: 100vh;
}
.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 0;
  background: var(--bg-deep);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
}
.rail-logo {
  width: 38px; height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 17px;
  text-decoration: none;
  margin-bottom: 6px;
}
.rail-btn {
  width: 38px; height: 38px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.rail-btn:hover { color: var(--text); border-color: var(--line-strong); background: var(--panel); }
.rail-spacer { flex: 1; }
.rail-avatar {
  width: 36px; height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* ── Zustand 2: Hero / Onboarding ─────────────────────────────────── */
.hero {
  display: grid;
  place-items: center;
  padding: 48px 24px;
  min-height: 100vh;
}
.hero-inner {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.hero-title {
  font-family: var(--serif);
  font-size: clamp(30px, 5vw, 44px);
  font-weight: 500;
  letter-spacing: 0.01em;
  text-align: center;
  margin: 0 0 30px;
}
.hero-mark { color: var(--accent); font-size: 0.8em; }

.composer-card {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 16px 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
}
.composer-card:focus-within { border-color: var(--line-strong); }
.composer-card textarea {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  resize: none;
  max-height: 200px;
}
.composer-card textarea::placeholder { color: var(--subtle); }
.composer-card textarea:focus { outline: none; }
.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}
.composer-model {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--subtle);
  letter-spacing: 0.04em;
}

.hero-note {
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.hero-note.is-warn { color: var(--danger); }
.hero-note.is-busy { color: var(--accent); }

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}
.chip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  padding: 9px 16px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  min-height: 40px;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }

.hero-continue {
  margin-top: 26px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
}

.onboarding {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 40px 0 0;
  padding: 0;
  width: 100%;
}
.onboarding li {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.onboarding strong {
  display: block;
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

/* ── Zustand 4: Cowork ────────────────────────────────────────────── */
.hero-cowork-link {
  margin-top: 10px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
}
.hero-cowork-link:hover { color: var(--accent); }

.cowork {
  display: grid;
  place-items: start center;
  padding: 48px 24px;
  min-height: 100vh;
}
.cowork-inner { width: 100%; max-width: 720px; }

.task-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0 0 22px;
}
.task-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}
.task-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.task-icon { font-size: 20px; }
.task-title { color: var(--text); font-size: 14px; font-weight: 600; }
.task-desc { color: var(--subtle); font-size: 12px; line-height: 1.45; }

.cowork-composer textarea { margin-bottom: 8px; }
.cowork-context {
  border-top: 1px solid var(--line) !important;
  padding-top: 10px;
  font-family: var(--mono) !important;
  font-size: 13px !important;
  color: var(--muted) !important;
}

/* Progress-Karte — bewusst WEISS wie in der Vorlage */
.progress-card {
  background: #ffffff;
  color: #1f1e1c;
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.3);
  margin: 12px 0 22px;
}
.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 14px;
}
.progress-chevron { color: #8b887f; font-size: 18px; line-height: 0.4; }
.progress-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.progress-steps li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 15.5px;
  color: #97948c;
  transition: color 0.3s;
}
.progress-steps li .step-circle {
  flex-shrink: 0;
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 2px solid #d8d5cd;
  color: #97948c;
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.3s, color 0.3s, background 0.3s;
}
.progress-steps li.is-active { color: #1f1e1c; }
.progress-steps li.is-active .step-circle {
  border-color: #2f7fe0;
  color: #2f7fe0;
}
.progress-steps li.is-done { color: #1f1e1c; }
.progress-steps li.is-done .step-circle {
  border-color: #2f7fe0;
  background: #2f7fe0;
  color: #fff;
}
.progress-steps li .step-body { padding-top: 2px; min-width: 0; }
.progress-steps li .step-note {
  display: block;
  font-size: 13px;
  color: #6f6c64;
  margin-top: 2px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Artefakte */
.artifacts { display: flex; flex-direction: column; gap: 10px; }
.artifact-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.artifact-name {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  overflow-wrap: anywhere;
}
.artifact-meta { color: var(--subtle); font-size: 12px; margin-left: 8px; }
.artifact-actions { display: flex; gap: 8px; flex-shrink: 0; }

.cowork-result-notes {
  margin: 16px 2px 0;
  font-size: 14px;
  color: var(--muted);
}
.cowork-actions { margin-top: 18px; }

/* ── Zustand 5: API-Zugang ────────────────────────────────────────── */
.apiview {
  padding: 48px 24px;
  min-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}
.apiview-inner { width: 100%; max-width: 720px; margin: 0 auto; min-width: 0; }
.apiview-lede { color: var(--muted); margin: 0 0 28px; }

.queue-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 28px;
}
.queue-row { display: flex; gap: 12px; }
.queue-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}
.queue-num { font-family: var(--mono); font-size: 22px; color: var(--accent); }
.queue-lbl { font-size: 11px; color: var(--subtle); letter-spacing: 0.04em; }
.queue-note { margin: 10px 2px 0; font-size: 12px; color: var(--subtle); }

.keys-section { margin-bottom: 32px; }
.keys-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.keys-head h2, .usage-section h2 {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  margin: 0;
}
.key-form { display: flex; gap: 8px; }
#key-name {
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
  min-width: 180px;
}
#key-name:focus { border-color: var(--accent); outline: none; }

.key-reveal {
  background: #14201b;
  border: 1px solid #2c5a44;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.key-reveal-warn { margin: 0 0 10px; font-size: 13px; color: #9fe7c4; }
.key-reveal-row { display: flex; gap: 10px; align-items: center; }
.key-reveal-row code {
  flex: 1;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  overflow-x: auto;
  white-space: nowrap;
}

.keys-list { display: flex; flex-direction: column; gap: 8px; }
.key-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.key-item.is-revoked { opacity: 0.5; }
.key-item-main { min-width: 0; }
.key-item-name { font-size: 14px; color: var(--text); }
.key-item-meta { font-family: var(--mono); font-size: 11px; color: var(--subtle); margin-top: 2px; }
.key-empty { color: var(--subtle); font-size: 14px; padding: 8px 2px; }

.usage-hint { color: var(--muted); font-size: 13px; margin: 6px 0 10px; }
.codeblock {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  overflow-x: auto;
  white-space: pre;
}

@media (max-width: 560px) {
  .apiview { padding: 24px 16px; }
  .queue-row { flex-wrap: wrap; }
  .queue-stat { min-width: 60px; }
  .keys-head { flex-direction: column; align-items: stretch; }
  .key-form { flex-direction: column; }
  #key-name { min-width: 0; }
}

/* ── Zustand 3: Workspace ─────────────────────────────────────────── */
.studio {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
  padding: 16px 20px;
}
.builder { padding-bottom: 12px; }
.build-bar { display: flex; gap: 10px; }
#build-prompt {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 16px;
  padding: 10px 14px;
  min-height: 42px;
}
#build-prompt::placeholder { color: var(--subtle); }
#build-prompt:focus { border-color: var(--accent); outline: none; }
.build-notes {
  margin: 6px 2px 0;
  min-height: 18px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.build-notes.is-busy { color: var(--accent); }
.build-notes.is-warn { color: var(--danger); }

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 14px;
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.pane-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
}
.pane-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--subtle);
}
.pane-actions { display: flex; gap: 8px; }

.filetabs { display: flex; gap: 4px; }
.filetab {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--subtle);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
}
.filetab:hover { color: var(--text); }
.filetab.is-active {
  color: var(--accent);
  border-color: var(--line-strong);
  background: var(--bg-deep);
}

.editor {
  flex: 1;
  min-height: 0;
  max-height: none;
  resize: none;
  border: none;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  padding: 14px 16px;
  tab-size: 2;
  white-space: pre;
}
.editor:focus { outline: none; }

.editor, .console { scrollbar-color: var(--line-strong) transparent; }
.editor::-webkit-scrollbar, .console::-webkit-scrollbar { width: 10px; height: 10px; }
.editor::-webkit-scrollbar-thumb, .console::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 5px;
}
.editor::-webkit-scrollbar-corner, .console::-webkit-scrollbar-corner { background: transparent; }

.pane-right { min-height: 0; }
.preview {
  flex: 1;
  min-height: 0;
  border: none;
  background: #fff;
}
.console-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 150px;
  border-top: 1px solid var(--line);
}
.pane-bar-console { border-bottom: 1px solid var(--line); }
.console {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  background: var(--bg-deep);
}
.console-line { white-space: pre-wrap; overflow-wrap: anywhere; }
.console-line.level-warn { color: #f5d08a; }
.console-line.level-error { color: var(--danger); }
.console-line.level-info, .console-line.level-log { color: var(--muted); }
.console-line .console-prefix { color: var(--subtle); }

/* ── Mobil ────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    flex-direction: row;
    height: auto;
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 10px 14px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    gap: 8px;
  }
  .rail-logo { margin-bottom: 0; }
  .rail-avatar { margin-left: 4px; }

  .hero { min-height: calc(100vh - 60px); padding: 32px 18px; }
  .onboarding { grid-template-columns: 1fr; gap: 10px; margin-top: 30px; }
  .cowork { padding: 28px 16px; }
  .task-grid { grid-template-columns: repeat(2, 1fr); }
  .artifact-card { flex-direction: column; align-items: flex-start; }

  .studio { height: auto; min-height: calc(100vh - 60px); padding: 12px 14px; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: none; }
  .pane-editor { min-height: 320px; }
  .editor { min-height: 240px; }
  .preview { min-height: 300px; }
  .build-bar .cta-small { padding: 9px 14px; }
}
