:root {
  --ink: #090a0d;
  --panel: #111319;
  --panel-2: #151821;
  --line: rgba(255, 255, 255, 0.105);
  --muted: #8a8f9d;
  --text: #f5f2ea;
  --acid: #d8ff48;
  --acid-soft: rgba(216, 255, 72, 0.12);
  --violet: #a890ff;
  --danger: #ff786f;
  --radius: 24px;
  font-family: Inter, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--ink);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-height: 100%; background: var(--ink); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 78% -10%, rgba(168, 144, 255, 0.11), transparent 32%),
    radial-gradient(circle at 8% 18%, rgba(216, 255, 72, 0.05), transparent 25%),
    var(--ink);
}

button, input, select, textarea, [contenteditable="true"] { font: inherit; }
button { color: inherit; }

.shell { width: min(1540px, calc(100% - 48px)); margin: 0 auto; }

.topbar {
  height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: baseline; letter-spacing: -0.055em; font-weight: 900; }
.brand-nine { font-size: 24px; }
.brand-colon { color: var(--acid); font-size: 15px; margin: 0 8px; letter-spacing: .08em; }
.brand-moi { font-size: 24px; color: #aaafba; }

.top-actions { display: flex; align-items: center; gap: 10px; }
.corpus-pill, .key-button, .icon-button {
  height: 42px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.025);
  border-radius: 99px;
}
.corpus-pill { display: inline-flex; align-items: center; gap: 6px; padding: 0 16px; color: var(--muted); font-size: 13px; }
.corpus-pill strong { color: var(--text); }
.key-button { padding: 0 17px; cursor: pointer; display: flex; align-items: center; gap: 9px; }
.icon-button { width: 42px; padding: 0; cursor: pointer; font-size: 20px; color: var(--muted); }
.key-button:hover, .icon-button:hover { border-color: rgba(216,255,72,.38); }
.key-dot { width: 7px; height: 7px; border-radius: 50%; background: #535762; box-shadow: 0 0 0 4px rgba(83,87,98,.14); }
.key-dot.connected { background: var(--acid); box-shadow: 0 0 0 4px rgba(216,255,72,.12); }

main { padding: 68px 0 54px; }
.intro { display: grid; grid-template-columns: 1.25fr .75fr; column-gap: 56px; align-items: end; margin-bottom: 40px; }
.eyebrow { margin: 0 0 14px; color: var(--acid); letter-spacing: .19em; font-size: 11px; font-weight: 800; }
.intro .eyebrow { grid-column: 1 / -1; }
.intro h1 { margin: 0; max-width: 800px; font-size: clamp(42px, 5.4vw, 78px); line-height: .98; letter-spacing: -.062em; font-weight: 720; }
.intro h1 span { color: #777d89; }
.intro-copy { margin: 0 0 5px; justify-self: end; max-width: 500px; color: #a7acb6; font-size: 16px; line-height: 1.6; }

.workspace { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel {
  min-height: 470px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(21,24,33,.97), rgba(14,16,21,.97));
  box-shadow: 0 22px 70px rgba(0,0,0,.24);
  overflow: hidden;
}
.output-panel { border-color: rgba(216,255,72,.15); }
.panel-head { min-height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--line); }
.panel-head > div:first-child { display: flex; align-items: center; gap: 14px; }
.panel-head h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.step { color: var(--acid); font: 700 11px/1 monospace; }
.mini-actions { display: flex; gap: 14px; }
.text-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; padding: 5px 0; }
.text-button:hover { color: var(--text); }
.photo-button { color: var(--acid); }
.source-panel textarea, .output-text {
  width: 100%;
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  padding: 26px;
  font-size: 17px;
  line-height: 1.72;
  text-align: start;
  unicode-bidi: plaintext;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.source-panel textarea::placeholder { color: #555b67; }
.source-image {
  min-height: 94px;
  display: grid;
  grid-template-columns: 68px 1fr auto;
  align-items: center;
  gap: 14px;
  margin: 0 20px 18px;
  padding: 11px;
  border: 1px solid rgba(216,255,72,.18);
  border-radius: 15px;
  background: rgba(216,255,72,.045);
}
.source-image img { width: 68px; height: 68px; display: block; object-fit: cover; border-radius: 10px; background: #090b0f; }
.source-image div { min-width: 0; }
.source-image strong, .source-image span { display: block; }
.source-image strong { overflow: hidden; color: #d8dbe0; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.source-image span { margin-top: 5px; color: #737985; font-size: 10px; line-height: 1.35; }
.source-image button { border: 0; color: #9298a3; background: transparent; cursor: pointer; font-size: 11px; }
.source-image button:hover { color: #ff9c95; }
.source-foot { min-height: 43px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; color: #676c78; border-top: 1px solid var(--line); font-size: 11px; }
.autosave::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-right: 7px; border-radius: 50%; background: #626875; }
.state-chip { border-radius: 99px; padding: 7px 11px; color: var(--muted); background: rgba(255,255,255,.045); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.state-chip.working { color: var(--acid); background: var(--acid-soft); }
.state-chip.ready { color: #0b0e0b; background: var(--acid); }
.state-chip.error { color: #ffd5d0; background: rgba(255,120,111,.14); }
.empty-output { flex: 1; display: grid; place-content: center; text-align: center; color: #656b76; padding: 40px; }
.empty-output p { margin: 10px 0 0; line-height: 1.6; font-size: 14px; }
.empty-mark { color: var(--acid); font-size: 58px; line-height: 1; font-weight: 900; }
.output-text {
  direction: auto;
  min-height: 280px;
  overflow-y: auto;
  font-size: 19px;
  line-height: 1.72;
  caret-color: var(--acid);
}
.output-text:focus { box-shadow: inset 0 0 0 1px rgba(216,255,72,.14); }
.output-text[dir="rtl"] { text-align: right; }
.output-text[dir="ltr"] { text-align: left; }
.analysis-strip strong, .example-item p { unicode-bidi: plaintext; text-align: start; }
.analysis-strip { border-top: 1px solid var(--line); display: grid; grid-template-columns: 1.2fr 1fr auto; min-height: 64px; }
.analysis-strip > div { padding: 12px 18px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.analysis-strip span { color: #666d79; font-size: 9px; font-weight: 800; letter-spacing: .11em; }
.analysis-strip strong { color: #b8bdc6; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.analysis-strip button { border: 0; background: transparent; color: #a7acb6; padding: 0 17px; cursor: pointer; font-size: 11px; }
.analysis-strip button:hover { color: var(--acid); }
.analysis-strip b { display: inline-grid; place-content: center; width: 20px; height: 20px; margin-left: 5px; border-radius: 50%; background: rgba(255,255,255,.07); }
.output-actions { min-height: 67px; display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); }
.secondary, .approve, .reject, .correction { min-height: 39px; border-radius: 11px; padding: 0 14px; cursor: pointer; font-size: 12px; font-weight: 700; }
.secondary { background: rgba(255,255,255,.045); border: 1px solid var(--line); }
.secondary:hover { background: rgba(255,255,255,.075); }
.approve { margin-left: auto; border: 1px solid rgba(216,255,72,.45); background: var(--acid-soft); color: var(--acid); }
.approve:hover { color: #0b0e0b; background: var(--acid); }
.reject { border: 1px solid rgba(255,120,111,.25); background: transparent; color: #e29b95; }
.correction { margin-left: auto; border: 1px solid rgba(168,144,255,.35); background: rgba(168,144,255,.1); color: #c9bbff; }

.controls { margin-top: 16px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(17,19,25,.88); }
.control-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.controls label > span, .key-field > span, .reject-note > span { display: block; margin: 0 0 8px 3px; color: #777e8b; font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
select, .intent-field input, .reject-note input {
  width: 100%; height: 45px; border: 1px solid var(--line); border-radius: 12px; outline: 0; padding: 0 13px; color: #d8d9dc; background: #0c0e12;
}
select:focus, input:focus, textarea:focus, [contenteditable="true"]:focus { border-color: rgba(216,255,72,.35); }
.intent-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: end; margin-top: 15px; }
.intent-field span em { margin-left: 5px; color: #4f5560; font-style: normal; text-transform: none; letter-spacing: 0; }
.fidelity-toggle { height: 45px; min-width: 205px; display: flex; align-items: center; gap: 10px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.fidelity-toggle input { position: absolute; opacity: 0; }
.toggle-ui { position: relative; width: 31px; height: 18px; flex: 0 0 auto; margin: 0 !important; border-radius: 99px; background: #3a3e46; }
.toggle-ui::after { content: ""; position: absolute; width: 12px; height: 12px; top: 3px; left: 3px; border-radius: 50%; background: #9398a2; transition: .2s; }
.fidelity-toggle input:checked + .toggle-ui { background: rgba(216,255,72,.26); }
.fidelity-toggle input:checked + .toggle-ui::after { left: 16px; background: var(--acid); }
.fidelity-toggle > span:last-child { margin: 0; text-transform: none; letter-spacing: 0; }
.fidelity-toggle strong, .fidelity-toggle small { display: block; }
.fidelity-toggle strong { color: #d6d8dc; font-size: 11px; }
.fidelity-toggle small { color: #676d78; font-size: 9px; margin-top: 2px; }
.generate { height: 45px; display: inline-flex; align-items: center; justify-content: space-between; gap: 36px; border: 0; border-radius: 12px; padding: 0 18px; color: #0b0d0b; background: var(--acid); cursor: pointer; font-weight: 850; box-shadow: 0 0 40px rgba(216,255,72,.08); }
.generate:hover { filter: brightness(1.05); transform: translateY(-1px); }
.generate:disabled { cursor: wait; opacity: .6; transform: none; }
.generate i { font-style: normal; font-size: 18px; }
.generate.compact { gap: 10px; min-width: 130px; justify-content: center; }

.refine { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding: 0 4px; }
.refine > span { color: #666c78; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.refine div { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.refine button { border: 1px solid var(--line); border-radius: 99px; color: #9da2ac; background: transparent; padding: 8px 12px; cursor: pointer; font-size: 11px; }
.refine button:hover { color: var(--text); border-color: rgba(216,255,72,.27); }

footer { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 40px; border-top: 1px solid var(--line); color: #555b66; font-size: 10px; }
footer > span { color: #737985; font-weight: 800; letter-spacing: -.03em; }
footer p { max-width: 680px; text-align: right; line-height: 1.55; }

.dialog { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; border: 0; color: var(--text); background: rgba(2,3,5,.72); backdrop-filter: blur(15px); }
.dialog[open] { display: grid; place-items: center; }
.dialog::backdrop { background: rgba(2,3,5,.72); backdrop-filter: blur(15px); }
.dialog-card { position: relative; width: min(520px, calc(100% - 34px)); max-height: calc(100vh - 50px); overflow: auto; margin: 0; padding: 31px; border: 1px solid var(--line); border-radius: 22px; background: #12151b; box-shadow: 0 30px 100px rgba(0,0,0,.55); }
.dialog-card h2 { margin: 0 0 10px; font-size: 30px; letter-spacing: -.045em; }
.dialog-card > p:not(.eyebrow):not(.dialog-status) { color: #9298a4; font-size: 13px; line-height: 1.6; }
.dialog-close { position: absolute; right: 17px; top: 15px; width: 34px; height: 34px; border: 0; border-radius: 50%; color: #8a909b; background: rgba(255,255,255,.05); cursor: pointer; font-size: 20px; }
.key-field { display: block; margin-top: 24px; }
.key-field div { display: flex; }
.key-field input { flex: 1; min-width: 0; height: 45px; border: 1px solid var(--line); border-right: 0; border-radius: 12px 0 0 12px; outline: 0; padding: 0 13px; color: var(--text); background: #0b0d11; }
.key-field button { width: 61px; border: 1px solid var(--line); border-radius: 0 12px 12px 0; background: rgba(255,255,255,.04); cursor: pointer; font-size: 11px; }
.remember-key { display: flex; gap: 8px; margin-top: 12px; color: #818793; font-size: 11px; }
.model-line { display: flex; justify-content: space-between; gap: 15px; margin-top: 22px; padding: 13px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 11px; }
.model-line span { color: #727985; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.dialog-status { min-height: 17px; margin: 14px 0 0; color: var(--acid); font-size: 11px; }
.dialog-card > a { display: inline-block; margin-top: 12px; color: #9da4af; font-size: 11px; text-decoration: none; }
.dialog-card > a:hover { color: var(--acid); }

.data-card { width: min(610px, calc(100% - 34px)); }
.data-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 24px 0; }
.data-stats div { padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.02); }
.data-stats strong { display: block; color: var(--acid); font-size: 22px; }
.data-stats span { color: #777e8a; font-size: 10px; }
.data-section { padding: 18px 0; border-top: 1px solid var(--line); }
.data-section h3 { margin: 0 0 6px; font-size: 14px; }
.data-section p { margin: 0 0 13px; color: #777e89; font-size: 11px; line-height: 1.5; }
.wide { width: 100%; margin-top: 7px; }

.examples-card { width: min(760px, calc(100% - 34px)); }
.examples-list { display: grid; gap: 9px; margin-top: 22px; }
.example-item { padding: 16px 17px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.02); }
.example-item span { display: block; margin-bottom: 8px; color: var(--acid); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.example-item p { max-height: 142px; overflow: auto; margin: 0; color: #b4b8c0; white-space: pre-wrap; line-height: 1.55; font-size: 12px; }

.reason-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 22px 0; }
.reason-grid button { min-height: 42px; border: 1px solid var(--line); border-radius: 12px; color: #aeb3bc; background: rgba(255,255,255,.025); cursor: pointer; font-size: 11px; }
.reason-grid button.selected { color: var(--acid); border-color: rgba(216,255,72,.42); background: var(--acid-soft); }
.reject-note { display: block; margin-bottom: 14px; }

.toast { position: fixed; left: 50%; bottom: 22px; z-index: 20; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 11px 16px; border: 1px solid var(--line); border-radius: 99px; color: #e3e5e8; background: rgba(19,22,28,.95); box-shadow: 0 15px 60px rgba(0,0,0,.4); font-size: 11px; transition: .22s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .intro { grid-template-columns: 1fr; gap: 22px; }
  .intro-copy { justify-self: start; }
  .workspace { grid-template-columns: 1fr; }
  .control-row { grid-template-columns: repeat(2, 1fr); }
  .intent-row { grid-template-columns: 1fr 1fr; }
  .intent-field { grid-column: 1 / -1; }
  .panel { min-height: 420px; }
}

@media (max-width: 620px) {
  .shell { width: min(100% - 24px, 1540px); }
  .topbar { height: 72px; }
  .corpus-pill { display: none; }
  main { padding-top: 42px; }
  .intro h1 { font-size: 43px; }
  .intro-copy { font-size: 14px; }
  .panel-head { padding: 0 17px; }
  .source-panel textarea, .output-text { padding: 19px; font-size: 16px; }
  .source-image { grid-template-columns: 54px 1fr; margin: 0 12px 12px; }
  .source-image img { width: 54px; height: 54px; }
  .source-image button { grid-column: 2; justify-self: start; padding: 0; }
  .control-row { grid-template-columns: 1fr; }
  .intent-row { grid-template-columns: 1fr; }
  .fidelity-toggle { width: 100%; }
  .generate { width: 100%; }
  .output-actions { flex-wrap: wrap; }
  .approve { margin-left: 0; }
  .analysis-strip { grid-template-columns: 1fr; }
  .analysis-strip > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .analysis-strip button { min-height: 46px; }
  .refine { align-items: flex-start; flex-direction: column; gap: 10px; }
  .refine div { justify-content: flex-start; }
  footer { align-items: flex-start; flex-direction: column; padding: 22px 0; gap: 8px; }
  footer p { margin: 0; text-align: left; }
  .data-stats { grid-template-columns: 1fr; }
}
