:root {
  color-scheme: dark;
  --bg: #0e1016;
  --panel: rgba(19, 24, 34, 0.9);
  --panel-strong: rgba(24, 31, 45, 0.96);
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef3ff;
  --muted: #9da7be;
  --accent: #ff936f;
  --accent-2: #f2d479;
  --success: #98efbf;
  --danger: #ff98a6;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  --radius: 24px;
  --font: "Hiragino Sans", "Noto Sans JP", sans-serif;
}

* {
  box-sizing: border-box;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: radial-gradient(circle at top right, rgba(255, 147, 111, 0.18), transparent 30%),
    radial-gradient(circle at left, rgba(242, 212, 121, 0.12), transparent 26%), var(--bg);
  color: var(--text);
}

body {
  overflow: hidden;
}

.background {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at center, black 40%, transparent 85%);
  pointer-events: none;
}

.app-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 18px;
}

.app-card {
  width: min(1380px, 100%);
  height: min(860px, calc(100vh - 36px));
  border: 1px solid var(--line);
  border-radius: 32px;
  background: rgba(12, 16, 23, 0.84);
  backdrop-filter: blur(28px);
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 16px;
}

.app-header,
.section-heading,
.toolbar,
.header-actions,
.tabs,
.simple-item,
.uploader {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header,
.section-heading,
.toolbar {
  justify-content: space-between;
}

.app-header {
  min-height: 120px;
}

.tabs {
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  width: fit-content;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
}

.tab.is-active {
  background: linear-gradient(135deg, var(--accent), #ff6e8d);
  color: #1b0d0d;
}

.tab-panel {
  display: none;
  min-height: 0;
}

.tab-panel.is-active {
  display: block;
}

.panel-grid,
.summary-grid,
.details-grid,
.script-form {
  display: grid;
  gap: 16px;
}

.panel-grid {
  grid-template-columns: 1.45fr 0.9fr;
  min-height: 0;
  height: 100%;
}

.summary-grid {
  grid-template-columns: repeat(3, 1fr);
}

.details-grid {
  grid-template-columns: 0.9fr 1fr 1fr;
  margin-top: 16px;
}

.panel,
.summary-card,
.beat,
.video-card,
.label-group,
.cluster-row,
.narrative-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.panel,
.summary-card,
.video-card,
.cluster-row,
.label-group,
.beat,
.narrative-panel {
  padding: 18px;
}

.panel-primary,
.panel-secondary {
  height: 100%;
}

.panel-primary {
  overflow: hidden;
}

.panel-secondary {
  display: grid;
  align-content: start;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(30px, 3.5vw, 50px);
  line-height: 1.03;
  margin-bottom: 12px;
}

h2 {
  font-size: 24px;
  margin-bottom: 0;
}

h3 {
  font-size: 18px;
  margin-bottom: 14px;
}

.lede,
.muted,
.hint {
  color: var(--muted);
}

textarea,
select,
input,
button,
summary {
  font: inherit;
}

textarea,
select,
input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(10, 13, 20, 0.92);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
}

textarea {
  min-height: 0;
  height: 240px;
  resize: none;
  line-height: 1.5;
  margin: 14px 0 0;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--accent), #ff6e8d);
  color: #1b0d0d;
  font-weight: 700;
  cursor: pointer;
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.mini-stats,
.stack,
.cluster-table,
.video-list,
.dictionary,
.script-output,
.file-queue {
  display: grid;
  gap: 12px;
}

.mini-stats {
  grid-template-columns: repeat(2, 1fr);
}

.stat,
.pill {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 18px;
  padding: 12px 14px;
}

.stat strong,
.pill strong,
.beat strong {
  color: var(--accent-2);
}

.pill {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.simple-list {
  display: grid;
  gap: 14px;
}

.simple-item {
  align-items: flex-start;
}

.simple-item strong {
  color: var(--accent);
}

.summary-card {
  min-height: 240px;
}

.narrative-panel {
  margin-top: 16px;
}

.uploader {
  margin-top: 14px;
}

.uploader input {
  flex: 1;
}

.file-queue {
  margin-top: 14px;
  max-height: 180px;
  overflow: auto;
}

.queue-item {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.advanced-input {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.score-positive {
  color: var(--success);
}

.score-negative {
  color: var(--danger);
}

.details-panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.details-dictionary {
  margin-top: 16px;
}

summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
}

.video-list,
.cluster-table,
.dictionary {
  max-height: 430px;
  overflow: auto;
  padding-right: 6px;
}

.video-card h3 {
  margin-bottom: 8px;
}

.label-group ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.script-form {
  grid-template-columns: repeat(2, 1fr);
}

.script-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.script-form button {
  grid-column: 1 / -1;
}

.script-output {
  max-height: 100%;
  overflow: auto;
}

.one-liner-summary {
  background: linear-gradient(135deg, rgba(255, 147, 111, 0.12), rgba(242, 212, 121, 0.08));
  border: 1px solid rgba(255, 147, 111, 0.3);
  border-radius: 18px;
  padding: 14px 20px;
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 14px;
}

.one-liner-summary strong {
  color: var(--accent-2);
  font-size: 17px;
}

.auto-set-divider {
  grid-column: 1 / -1;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 4px;
  text-transform: uppercase;
}

@media (max-width: 1080px) {
  body {
    overflow: auto;
  }

  .app-card {
    height: auto;
  }

  .panel-grid,
  .summary-grid,
  .details-grid,
  .script-form,
  .mini-stats {
    grid-template-columns: 1fr;
  }

  textarea {
    height: 320px;
  }

  .uploader {
    flex-direction: column;
    align-items: stretch;
  }
}
