*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #080c18;
  --bg2:        #0e1425;
  --bg3:        #141d33;
  --border:     #24304d;
  --text:       #f0f0f8;
  --text-sub:   #9aa0bc;
  --text-muted: #8898b8;
  --accent:     #e8eeff;
  --scene-color:#7eb3ff;
  --why-color:  #b48fff;
  --radius: 6px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Hiragino Sans', sans-serif;
  --content-max: 820px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 2.0;
  min-height: 100vh;
}

/* ── HEADER ───────────────────────────────────────────── */

header {
  background: linear-gradient(180deg, #0c1120 0%, var(--bg) 100%);
  border-bottom: 1px solid rgba(100, 140, 255, 0.12);
  box-shadow: 0 4px 32px rgba(80, 120, 255, 0.06);
  padding: 18px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-logo {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  mix-blend-mode: screen;
  filter: drop-shadow(0 0 8px rgba(120, 170, 255, 0.45))
          drop-shadow(0 0 2px rgba(255, 200, 100, 0.25));
}

.header-titles {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-company {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: rgba(130, 160, 220, 0.6);
  text-transform: uppercase;
  line-height: 1;
}

.brand-product {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: uppercase;
  line-height: 1.2;
}

.header-tagline {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

/* ── LAYOUT ───────────────────────────────────────────── */

main {
  display: grid;
  grid-template-columns: 400px 1fr;
  height: calc(100vh - 65px);
}

/* ── INPUT PANEL ──────────────────────────────────────── */

.input-panel {
  border-right: 1px solid rgba(100, 140, 255, 0.1);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow: hidden;
}

.input-script-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input-script-area textarea {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.input-bottom {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-top: 1px solid rgba(100, 140, 255, 0.08);
  padding-top: 20px;
}

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 9px;
}

textarea {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.9;
  padding: 16px 18px;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
}

textarea:focus { border-color: #3a4f7a; }
textarea::placeholder { color: var(--text-muted); }

select {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  padding: 12px 16px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a6285' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}

select option { background: var(--bg2); }

.btn-analyze {
  width: 100%;
  background: var(--accent);
  color: #080c18;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 15px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-analyze:hover  { opacity: 0.88; }
.btn-analyze:disabled { opacity: 0.28; cursor: not-allowed; }

/* ── OUTPUT PANEL ─────────────────────────────────────── */

.output-panel {
  overflow-y: auto;
  padding: 40px 6%;
}

.output-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* placeholder */

.placeholder {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 160px);
  gap: 10px;
  text-align: center;
}

.placeholder-title { font-size: 13px; letter-spacing: 0.08em; color: #1e2d50; }
.placeholder-sub   { font-size: 12px; color: #141f38; }

/* ── COLLAPSIBLE SECTION ──────────────────────────────── */

.output-section {
  padding: 32px 0;
  position: relative;
}

/* 光のライン区切り */
.output-section::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(80, 120, 220, 0.1) 20%,
    rgba(110, 155, 255, 0.25) 50%,
    rgba(80, 120, 220, 0.1) 80%,
    transparent 100%
  );
}

.output-section:last-child::after { display: none; }

.section-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  margin-bottom: 20px;
}

.section-hd:hover .section-title { color: var(--text-sub); }

.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color 0.15s;
}

.hd-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-copy-sec {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.15s;
}

.btn-copy-sec:hover { color: var(--accent); }

.chevron {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.2s;
  display: inline-block;
}

.section-bd.collapsed { display: none; }
.section-bd.collapsed + .section-hd .chevron,
.section-hd[aria-expanded="false"] .chevron { transform: rotate(-90deg); }

/* ── COGNITIVE CHANGE ─────────────────────────────────── */

.cognitive-grid {
  display: grid;
  grid-template-columns: 1fr 44px 1fr;
  align-items: start;
  gap: 0;
}

.cognitive-card {
  background: var(--bg2);
  border: 1px solid rgba(100, 140, 255, 0.12);
  border-radius: var(--radius);
  padding: 22px 26px;
  box-shadow: inset 0 1px 0 rgba(150, 190, 255, 0.05);
}

.cognitive-card .card-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.cognitive-card p {
  font-size: 16px;
  line-height: 1.9;
  color: var(--text);
}

.arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 18px;
  padding-top: 30px;
}

.cognitive-design {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 26px;
  font-size: 15px;
  color: var(--text-sub);
  line-height: 2.0;
  margin-top: 12px;
}

.cognitive-design::before {
  content: 'DESIGN  ';
  letter-spacing: 0.12em;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
}

/* ── STRUCTURE ────────────────────────────────────────── */

.structure-phases {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.phase-row {
  display: grid;
  grid-template-columns: 100px 88px 1fr;
  gap: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 26px;
  align-items: start;
}

.phase-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.phase-duration {
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 2px;
}

.phase-content {
  font-size: 15px;
  line-height: 1.9;
  color: var(--text);
}

.phase-role {
  grid-column: 2 / 4;
  font-size: 13px;
  color: var(--text-sub);
  border-top: 1px solid var(--border);
  margin-top: 10px;
  padding-top: 10px;
  line-height: 1.8;
}

/* ── EXPRESSION TABS ──────────────────────────────────── */

.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #3a4870;
  font-family: var(--font);
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 8px 16px 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--text-sub); }

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Expression card */

.expression-card {
  background: var(--bg2);
  border: 1px solid rgba(100, 140, 255, 0.12);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(150, 190, 255, 0.05);
}

.expression-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border);
}

.meta-block {
  padding: 22px 26px;
}

.meta-block:first-child { border-right: 1px solid var(--border); }

.meta-block:first-child .meta-label {
  color: var(--scene-color);
  background: rgba(126, 179, 255, 0.07);
}

.meta-block:last-child .meta-label {
  color: var(--why-color);
  background: rgba(180, 143, 255, 0.07);
}

.meta-label {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 3px;
  margin-bottom: 12px;
}

.meta-text {
  font-size: 15px;
  line-height: 1.9;
  color: var(--text);
}

.design-list {
  padding: 18px 26px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.design-item {
  display: flex;
  gap: 12px;
  font-size: 15px;
  line-height: 1.9;
  padding: 12px 16px;
  background: var(--bg3);
  border-radius: 4px;
  color: var(--text);
}

.design-item::before {
  content: '→';
  color: var(--text-muted);
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── FILE DROP ────────────────────────────────────────── */

.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-btn {
  display: inline-block;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 5px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.file-btn:hover { color: var(--accent); border-color: #3a4f7a; }

.file-hint {
  font-size: 11px;
  color: var(--text-muted);
}

textarea.drag-over {
  border-color: var(--scene-color);
  background: rgba(126, 179, 255, 0.04);
}

/* ── PRODUCTION LAYER ─────────────────────────────────── */

.production-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.prod-card {
  background: var(--bg2);
  border: 1px solid rgba(100, 140, 255, 0.12);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(150, 190, 255, 0.05);
}

.prod-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}

.prod-scene-index {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  flex-shrink: 0;
}

.prod-scene-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.btn-copy-card {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.15s;
  flex-shrink: 0;
}

.btn-copy-card:hover { color: var(--accent); }

/* Zone within card */

.prod-group { border-bottom: 1px solid var(--border); }
.prod-group:last-child { border-bottom: none; }

.prod-group-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 22px;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid var(--border);
}

/* Field row */

.prod-fields {
  display: flex;
  flex-direction: column;
}

.prod-field {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0;
  border-bottom: 1px solid var(--border);
  min-height: 48px;
}

.prod-field:last-child { border-bottom: none; }

.prod-field-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 14px 18px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding-top: 16px;
}

.btn-copy-field {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  cursor: pointer;
  transition: color 0.15s;
  white-space: nowrap;
  text-transform: uppercase;
}

.btn-copy-field:hover { color: var(--accent); }

.prod-field-value {
  font-size: 14px;
  line-height: 1.9;
  color: var(--text);
  padding: 12px 20px;
}

/* Visual bullet list */

.visual-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 4px;
  padding-bottom: 4px;
}

.visual-item {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
}

.visual-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 18px;
  padding-top: 2px;
}

.visual-text { flex: 1; }

/* Emotion flow */

.emotion-flow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.emotion-tag {
  font-size: 12px;
  color: var(--text-sub);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
}

.emotion-arrow { color: var(--text-muted); font-size: 13px; }

/* Insert Type badge */

.insert-type-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid currentColor;
}

.type-broll     { color: #7eb3ff; }
.type-diagram   { color: #ffd080; }
.type-typo      { color: #f0f0f8; }
.type-metaphor  { color: #b48fff; }
.type-compare   { color: #80ffb4; }
.type-cta       { color: #ff9080; }

/* Retention Importance */

.retention-importance {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid currentColor;
  flex-shrink: 0;
  white-space: nowrap;
}

.ri-1 { color: var(--text-muted); opacity: 0.55; }
.ri-2 { color: var(--text-muted); }
.ri-3 { color: #ffd080; }
.ri-4 { color: #ffaa40; }
.ri-5 { color: #ff8060; }

/* Diagram Type badge */

.diagram-type-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #ffd080;
  border: 1px solid rgba(255, 208, 128, 0.28);
  border-radius: 4px;
  padding: 3px 10px;
  background: rgba(255, 208, 128, 0.05);
}

/* B-roll keywords */

.broll-keywords-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.broll-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.broll-lang {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  width: 22px;
  flex-shrink: 0;
}

.broll-tag {
  font-size: 12px;
  padding: 3px 9px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-sub);
}

.broll-en-phrase {
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--scene-color);
  letter-spacing: 0.02em;
  background: rgba(126, 179, 255, 0.06);
  border: 1px solid rgba(126, 179, 255, 0.15);
  border-radius: 4px;
  padding: 3px 10px;
}

/* Image prompts A / B / C */

.image-prompts-list {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.image-prompt-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg3);
  border-radius: 4px;
}

.prompt-letter {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  background: var(--border);
  border-radius: 3px;
  padding: 2px 7px;
  flex-shrink: 0;
  margin-top: 3px;
}

.prompt-text {
  flex: 1;
  font-size: 13px;
  font-style: italic;
  color: var(--text-sub);
  line-height: 1.7;
}

.btn-copy-prompt {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  cursor: pointer;
  transition: color 0.15s;
  margin-top: 2px;
}

.btn-copy-prompt:hover { color: var(--accent); }

/* ── LOADING ──────────────────────────────────────────── */

.loading {
  display: none;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 160px);
  flex-direction: column;
  gap: 18px;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.06em;
}

.loading.visible { display: flex; }

.spinner {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-top-color: #8895c4;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── ERROR ────────────────────────────────────────────── */

.error-msg {
  background: #120818;
  border: 1px solid #2a1040;
  border-radius: var(--radius);
  color: #c080ff;
  font-size: 13px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

/* ── SCROLLBAR ────────────────────────────────────────── */

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
