@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #191816;
  --muted: #77736b;
  --line: #d9d5cc;
  --paper: #f4f1ea;
  --card: #fbfaf6;
  --dark: #171715;
  --lime: #c8ef52;
  --orange: #ff6b35;
  --blue: #3970f6;
  --mono: "DM Mono", monospace;
  --sans: "Manrope", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); min-width: 320px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.topbar { height: 72px; padding: 0 28px; display: flex; align-items: center; gap: 30px; border-bottom: 1px solid #3a3935; background: var(--dark); color: #fff; position: sticky; top: 0; z-index: 20; }
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 12px; min-width: 260px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--lime); color: var(--dark); border-radius: 4px; font-weight: 800; transform: rotate(-2deg); }
.brand b { font-size: 13px; letter-spacing: .13em; display: block; }
.brand small { color: #8d8b84; font: 11px var(--mono); letter-spacing: .08em; }
.pipeline { flex: 1; display: flex; justify-content: center; align-items: center; gap: 12px; color: #716f69; font: 12px var(--mono); letter-spacing: .06em; }
.pipeline .active { color: var(--lime); }
.pipeline i { width: 28px; height: 1px; background: #474641; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.api-status { display: flex; align-items: center; gap: 7px; color: #88857f; font: 12px var(--mono); }
.api-status i { width: 7px; height: 7px; border-radius: 50%; background: #888; }
.api-status.ready { color: #cfd1cb; }
.api-status.ready i { background: var(--lime); box-shadow: 0 0 12px #c8ef5277; }
.api-status.error i { background: var(--orange); }
.icon-button { border: 1px solid #46453f; border-radius: 5px; background: #242420; color: #eee; padding: 9px 12px; font-size: 11px; }

.page-shell { max-width: 1580px; margin: auto; padding: 14px 24px 48px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 40px; margin-bottom: 30px; }
.eyebrow { font: 12px var(--mono); letter-spacing: .16em; color: var(--blue); margin: 0 0 12px; }
h1 { font-size: clamp(32px, 4vw, 58px); line-height: 1.03; letter-spacing: -.055em; margin: 0; max-width: 760px; }
h1 em { color: var(--orange); font-style: normal; }
.intro-copy { max-width: 460px; color: #6a675f; font-size: 13px; line-height: 1.85; margin: 0 0 5px; }

.experiment-bar { min-height: 54px; display: flex; align-items: center; gap: 22px; padding: 8px 14px; margin-bottom: 8px; background: #e8e4db; border: 1px solid var(--line); border-radius: 6px 6px 0 0; }
.seed-control { display: flex; align-items: center; gap: 12px; }
.seed-control span { font: 12px var(--mono); color: var(--muted); }
.seed-control input { width: 132px; background: var(--card); border: 1px solid #c8c4bb; border-radius: 4px; padding: 9px; font: 12px var(--mono); }
.switch { display: flex; align-items: center; gap: 9px; font-size: 11px; cursor: pointer; }
.switch input, .toggle-list input { position: absolute; opacity: 0; }
.switch span, .toggle-list label span { position: relative; width: 34px; height: 19px; background: #aaa69e; border-radius: 20px; transition: .2s; }
.switch span::after, .toggle-list label span::after { content: ""; width: 13px; height: 13px; border-radius: 50%; background: white; position: absolute; left: 3px; top: 3px; transition: .2s; }
.switch input:checked + span, .toggle-list input:checked + span { background: var(--blue); }
.switch input:checked + span::after, .toggle-list input:checked + span::after { transform: translateX(15px); }
.ghost-button { border: 1px solid #bbb7ae; background: transparent; color: #5b5851; padding: 8px 11px; border-radius: 4px; font: 12px var(--mono); }
.restart-button { border: 0; background: var(--orange); color: #fff; padding: 9px 12px; border-radius: 4px; font-size: 12px; font-weight: 800; }
.experiment-tip { margin-left: auto; display: flex; gap: 12px; align-items: center; font-size: 12px; color: var(--muted); }
.experiment-tip b { background: var(--ink); color: var(--lime); padding: 5px 8px; border-radius: 3px; font: 12px var(--mono); }

.work-grid { display: grid; grid-template-columns: minmax(0, 3.2fr) minmax(0, 2.2fr) minmax(0, 2.6fr); align-items: stretch; height: calc(100dvh - 148px); min-height: 0; border: 1px solid var(--line); border-top: 0; background: var(--line); gap: 1px; overflow: hidden; }
.panel { min-width: 0; min-height: 0; padding: 15px; background: var(--card); overflow: hidden; }
.panel-heading { flex: none; display: flex; align-items: center; margin-bottom: 16px; }
.panel-heading > span { font: 26px var(--mono); color: #c0bcb4; margin-right: 12px; }
.panel-heading h2 { margin: 0; font-size: 15px; text-transform: uppercase; letter-spacing: .05em; }
.panel-heading p { color: var(--muted); font-size: 12px; margin: 3px 0 0; }
.panel-heading > small { margin-left: auto; font: 11px var(--mono); color: #aaa69e; }
.parameter-strip { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #eeebe4; border: 1px solid #d9d5cc; border-radius: 4px; padding: 7px 9px; margin: -11px 0 12px; }
.parameter-strip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #77736b; font: 11px var(--mono); }
.parameter-strip button { flex: none; border: 0; background: var(--dark); color: var(--lime); border-radius: 3px; padding: 6px 7px; font: 11px var(--mono); }
.design-panel { display: flex; flex-direction: column; }
.design-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; padding-right: 5px; overscroll-behavior: contain; }
.design-actions { flex: none; padding-top: 10px; border-top: 1px solid var(--line); background: var(--card); }
.attribute-builder { display: grid; grid-template-columns: 1fr; gap: 1px; border: 1px solid #d7d3ca; border-radius: 5px; margin-bottom: 9px; overflow: hidden; background: #dedad1; }
.attribute-row { min-width: 0; display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 5px; align-items: start; padding: 5px 7px; background: #faf9f5; }
.attribute-row[data-group="texture"], .attribute-row[data-group="delivery"], .attribute-row[data-group="character"], .attribute-row[data-group="context"] { grid-column: 1 / -1; }
.attribute-row b { display: block; color: #817d75; font-size: 11px; margin-bottom: 4px; }
.attribute-row div { display: flex; flex-wrap: wrap; gap: 4px; }
.attribute-row button { border: 1px solid #d1cdc4; background: #fff; color: #6e6a63; border-radius: 3px; padding: 4px 6px; font-size: 11px; }
.attribute-row button.selected { border-color: var(--blue); background: #edf2ff; color: var(--blue); font-weight: 700; }
.compact-field input { width: 100%; padding: 9px; font-size: 12px; }
.deepseek-button { width: 100%; display: flex; align-items: center; justify-content: space-between; border: 1px solid #282824; background: var(--dark); color: white; border-radius: 4px; padding: 9px 10px; margin: 0 0 12px; font-size: 12px; }
.deepseek-button span::before { content: "◆"; color: var(--lime); margin-right: 7px; }
.deepseek-button small { color: #aaa79f; font-size: 11px; }
.deepseek-button { flex-wrap: wrap; gap: 4px; }
.tension-actions { flex-wrap: wrap; }
.take-head b { font-size: 13px; }
.take-head button { font-size: 12px; }
.quality-card { flex-wrap: wrap; }
.design-text-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.design-text-grid textarea { height: 86px; resize: none; }
.field { display: block; margin-bottom: 12px; position: relative; }
.field > span { display: block; font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.field > span small { color: #9b978e; font-weight: 500; margin-left: 5px; }
textarea, input, select { border: 1px solid #cbc7be; background: #fff; color: var(--ink); border-radius: 4px; outline: none; }
textarea { width: 100%; padding: 9px 10px; resize: vertical; font-size: 14px; line-height: 1.5; }
textarea:focus, input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 2px #3970f611; }
.counter { display: block; text-align: right; color: #99958d; font: 11px var(--mono); margin-top: 4px; }
.mood-chips, .cue-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 7px; }
.mood-chips button, .cue-chips button { border: 1px solid #c8c4bb; border-radius: 3px; background: transparent; padding: 5px 7px; color: #706d66; font: 11px var(--mono); }
.mood-chips button:hover, .mood-chips button.selected { background: var(--ink); color: var(--lime); border-color: var(--ink); }
.mood-layout { display: grid; grid-template-columns: 1fr; gap: 8px; align-items: start; }
.mood-layout .mood-chips { margin: 0; align-content: start; }
.mood-editor textarea { min-height: 77px; resize: none; }
.tension-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 7px; }
.tension-actions label { display: flex; align-items: center; gap: 4px; color: var(--orange); font-size: 11px; cursor: pointer; }
.tension-actions input { accent-color: var(--orange); }
.tension-actions button { border: 0; background: none; color: var(--blue); padding: 4px; font: 11px var(--mono); }
.cue-chips button:hover { color: var(--blue); border-color: var(--blue); }
.prompt-preview { background: #22221f; color: #d9d8d0; border-radius: 5px; padding: 9px 11px; margin-bottom: 11px; }
.prompt-preview summary { cursor: pointer; color: #aaa89f; font: 11px var(--mono); }
.prompt-preview > div { display: flex; justify-content: space-between; color: #77766f; font: 11px var(--mono); }
.prompt-preview button { border: 0; background: none; color: var(--lime); font: inherit; }
.prompt-preview pre { white-space: pre-wrap; max-height: 88px; overflow: auto; margin: 9px 0 0; font: 9px/1.55 var(--mono); }
.primary-button { width: 100%; min-height: 50px; border: 0; border-radius: 5px; background: var(--blue); color: white; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; font-weight: 700; }
.primary-button small { opacity: .6; font: 11px var(--mono); }
.primary-button.light { background: var(--lime); color: var(--dark); }
.primary-button:disabled { opacity: .42; cursor: not-allowed; }
.primary-button.loading span::after { content: "  ···"; animation: pulse 1s infinite; }

.reference-panel { display: flex; flex-direction: column; background: #f0ede6; }
.empty-state { text-align: center; padding: 150px 30px 40px; color: #8e8a82; }
.empty-state b { color: #66635c; font-size: 12px; }
.empty-state p { font-size: 12px; line-height: 1.7; max-width: 230px; margin: 8px auto; }
.wave-icon { height: 45px; display: flex; justify-content: center; align-items: center; gap: 4px; margin-bottom: 18px; }
.wave-icon i { width: 3px; background: #bab6ad; border-radius: 2px; }
.wave-icon i:nth-child(1), .wave-icon i:nth-child(5) { height: 12px; }
.wave-icon i:nth-child(2), .wave-icon i:nth-child(4) { height: 28px; }
.wave-icon i:nth-child(3) { height: 42px; }
.take-list { min-height: 0; overflow-y: auto; scrollbar-gutter: stable; display: grid; align-content: start; gap: 6px; padding-right: 4px; }
.take-card { border: 1px solid #d0ccc3; background: var(--card); border-radius: 5px; padding: 10px; transition: .2s; }
.take-card.selected { border-color: var(--blue); box-shadow: inset 3px 0 var(--blue); }
.take-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.take-index { width: 26px; height: 26px; display: grid; place-items: center; background: #e7e3da; border-radius: 3px; font: 12px var(--mono); }
.take-head div { flex: 1; min-width: 0; }
.take-head button { flex: none; }
.take-head b { font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.take-head small { color: #96928a; font: 11px var(--mono); }
.take-head button { margin-left: auto; border: 0; border-radius: 3px; background: var(--ink); color: white; padding: 6px 8px; font: 11px var(--mono); }
.take-card.selected .take-head button { background: var(--blue); }
.take-card audio { width: 100%; height: 32px; }
.take-details { margin-top: 4px; font-size: 11px; color: #625e57; }
.take-details summary { cursor: pointer; }
.take-details summary span { float: right; color: var(--blue); }
.take-details p { line-height: 1.5; }
.take-details dl { margin: 8px 0 0; }
.take-details dt { margin-top: 6px; font-weight: 700; }
.take-details dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.take-tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.take-tags span { border: 1px solid #ddd9d1; color: #7e7a72; padding: 3px 5px; border-radius: 2px; font: 11px var(--mono); }
.take-tags .same-request { border-color: var(--blue); background: #edf2ff; color: var(--blue); font-weight: 700; }
.take-tags .raw-response { border-color: #91ac34; background: #f0f8d6; color: #59700f; font-weight: 700; }
.take-mood { margin: 8px 0 0; color: #6f6b64; font-size: 12px; line-height: 1.55; }

.tts-panel { display: flex; flex-direction: column; }
.tts-panel > .primary-button, .tts-panel > .field, .tts-panel > .quality-card { flex-shrink: 0; }
.tts-panel .grow { flex: none; }
.tts-panel .grow textarea { min-height: 112px; max-height: 180px; }
.custom-cue { display: flex; gap: 5px; }
.custom-cue input { min-width: 0; flex: 1; padding: 9px; font-size: 12px; }
.custom-cue button { border: 0; background: var(--dark); color: var(--lime); border-radius: 4px; padding: 0 12px; font-size: 12px; }
.grow { flex: 1; }
.quality-card { display: flex; align-items: center; gap: 9px; border: 1px solid #c8c4bb; border-radius: 5px; padding: 11px; margin: 2px 0 13px; cursor: pointer; }
.quality-card input { position: absolute; opacity: 0; }
.checkmark { width: 23px; height: 23px; border: 1px solid #bbb7af; color: transparent; display: grid; place-items: center; border-radius: 3px; }
.quality-card input:checked + .checkmark { background: var(--lime); border-color: #a7cf32; color: var(--dark); }
.quality-card b { font-size: 12px; display: block; }
.quality-card small { color: #99958d; font: 11px var(--mono); }
.quality-card em { margin-left: auto; color: #aaa69e; font: normal 11px var(--mono); }
.tts-history { flex: 1; min-height: 120px; overflow: hidden; border-top: 1px solid var(--line); margin-top: 13px; padding-top: 11px; display: flex; flex-direction: column; }
.history-title { display: flex; justify-content: space-between; color: #77736b; font: 11px var(--mono); margin-bottom: 8px; }
#ttsTakeList { min-height: 0; overflow-y: auto; scrollbar-gutter: stable; padding-right: 4px; }
.tts-take { border: 1px solid #d7d3ca; background: #fff; border-radius: 4px; padding: 9px; margin-top: 7px; }
.tts-take-head { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.tts-take-head b { font: 11px var(--mono); }
.tts-take-head span { color: #908c84; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tts-take-head a { margin-left: auto; color: var(--blue); font: 11px var(--mono); }
.tts-take audio { width: 100%; height: 30px; }
.is-hidden { display: none !important; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 30; background: #0008; backdrop-filter: blur(2px); }
.settings-drawer { position: fixed; z-index: 31; right: 0; top: 0; width: min(580px, 100%); height: 100vh; background: var(--card); transform: translateX(102%); transition: transform .25s ease; display: flex; flex-direction: column; box-shadow: -16px 0 50px #0002; }
.settings-drawer.open { transform: translateX(0); }
.settings-drawer > header { background: var(--dark); color: white; padding: 24px; display: flex; justify-content: space-between; align-items: center; }
.settings-drawer header p { color: var(--lime); font: 11px var(--mono); margin: 0 0 4px; }
.settings-drawer header h2 { margin: 0; font-size: 19px; }
.settings-drawer header button { color: #aaa; background: none; border: 0; font-size: 28px; }
.drawer-scroll { overflow: auto; flex: 1; padding: 22px 24px; }
.settings-section { margin-bottom: 28px; }
.settings-title { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 9px; margin-bottom: 15px; }
.settings-title span { font: 12px var(--mono); color: var(--blue); }
.settings-title small { color: #aaa69e; font: 11px var(--mono); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label > span { display: block; color: #5f5c55; font-size: 12px; margin-bottom: 5px; }
.form-grid label i { font: normal 11px var(--mono); color: #aaa69e; }
.form-grid input, .form-grid select { width: 100%; padding: 9px; font: 12px var(--mono); }
.api-note { background: #eef1fa; border-left: 3px solid var(--blue); color: #646a78; font-size: 12px; line-height: 1.6; padding: 9px; }
.toggle-list { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 17px; }
.toggle-list label { display: flex; align-items: center; gap: 7px; font-size: 12px; cursor: pointer; }
.toggle-list label span { width: 29px; height: 17px; }
.toggle-list label span::after { width: 11px; height: 11px; }
.toggle-list input:checked + span::after { transform: translateX(12px); }
.settings-drawer > footer { border-top: 1px solid var(--line); padding: 14px 24px; display: flex; gap: 10px; }
.settings-drawer footer .primary-button { width: 190px; margin-left: auto; min-height: 42px; justify-content: center; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: 24px; transform: translate(-50%, 90px); max-width: min(520px, 90vw); background: var(--dark); color: #eee; border-left: 4px solid var(--lime); padding: 12px 16px; border-radius: 4px; opacity: 0; transition: .25s; font-size: 11px; box-shadow: 0 8px 30px #0004; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-left-color: var(--orange); }
@keyframes pulse { 50% { opacity: .25; } }

@media (max-width: 1240px) {
  .pipeline { display: none; }
  .top-actions { margin-left: auto; }
  .work-grid { grid-template-columns: 1fr 1fr; height: auto; max-height: none; overflow: visible; }
  .panel { height: 75dvh; min-height: 0; }
  .tts-panel { grid-column: 1 / -1; min-height: 680px; max-height: 820px; }
  .design-text-grid, .mood-layout { grid-template-columns: 1fr; }
  .design-text-grid textarea { height: auto; resize: vertical; }
}
@media (max-width: 720px) {
  .topbar { padding: 0 14px; height: 62px; }
  .brand { min-width: 0; }
  .brand small, .api-status { display: none; }
  .page-shell { padding: 24px 14px 44px; }
  .intro { display: block; }
  .intro-copy { margin-top: 20px; }
  .experiment-bar { align-items: flex-start; flex-wrap: wrap; }
  .experiment-tip { width: 100%; margin: 0; }
  .work-grid { grid-template-columns: 1fr; }
  .tts-panel { grid-column: auto; }
  .panel { height: 80dvh; min-height: 0; max-height: none; padding: 14px; overflow: hidden; }
  .design-panel { overflow: hidden; }
  .attribute-builder { grid-template-columns: 1fr; }
  .attribute-row[data-group] { grid-column: auto; }
  .take-list, #ttsTakeList { max-height: 65vh; }
  .empty-state { padding: 60px 20px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
}

.selected-cues { max-height: 80px; overflow-y: auto; padding: 6px; background: #eef2ff; border-radius: 4px; }
.cue-chips button.selected { border-color: var(--blue); color: var(--blue); background: #eef2ff; }
.take-head .discard-button, .tts-take-head .discard-button { margin-left: 0; padding: 5px; background: transparent; color: #a33e28; border: 1px solid #d9b9b1; border-radius: 3px; font-size: 11px; flex: none; }
