:root {
  --bg: #f5f1eb;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-border: rgba(27, 31, 36, 0.08);
  --text-main: #19212a;
  --text-muted: #66707c;
  --accent: #c8643f;
  --accent-dark: #a74f30;
  --accent-soft: rgba(200, 100, 63, 0.08);
  --line-soft: rgba(25, 33, 42, 0.08);
  --shadow: 0 10px 32px rgba(25, 33, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Pretendard", "Apple SD Gothic Neo", sans-serif;
  color: var(--text-main);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.28)),
    var(--bg);
}

button,
input {
  font: inherit;
}

.hidden {
  display: none;
}

.page-shell {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.mode-tabs {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 16px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.mode-tab {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 700;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.mode-tab:hover {
  transform: translateY(-1px);
}

.mode-tab.active {
  color: #fff;
  background: var(--accent);
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  padding: 20px 22px;
}

.eyebrow,
.section-label {
  margin: 0 0 8px;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

.hero-copy-block {
  max-width: 560px;
}

.hero h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.hero-copy {
  max-width: 560px;
  margin: 12px 0 0;
  font-size: 0.96rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.hero-facts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 240px;
}

.fact-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  font-size: 0.84rem;
  color: var(--text-main);
}

.upload-panel {
  padding: 18px;
}

.upload-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  border-radius: 16px;
  border: 1px dashed rgba(25, 33, 42, 0.16);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), var(--accent-soft));
  cursor: pointer;
}

.upload-title {
  font-size: 1.08rem;
  font-weight: 700;
}

.upload-subtitle {
  font-size: 0.92rem;
  color: var(--text-muted);
}

#videoInput {
  margin-top: 8px;
}

.audio-options {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.72);
}

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

.audio-option-label {
  font-size: 0.92rem;
  font-weight: 700;
}

.audio-option-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.audio-option-input {
  width: 92px;
  padding: 9px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #fff;
  color: var(--text-main);
}

.audio-option-unit,
.audio-option-help {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.audio-option-help {
  margin: 0;
}

.actions,
.result-header,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.actions {
  margin-top: 14px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 15px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    opacity 160ms ease;
  font-size: 0.92rem;
  font-weight: 600;
}

.primary-button {
  color: #fff;
  background: var(--accent);
}

.ghost-button {
  color: var(--text-main);
  background: rgba(25, 33, 42, 0.05);
  border: 1px solid var(--line-soft);
}

.danger-button {
  color: #8d3620;
  background: rgba(200, 100, 63, 0.08);
  border-color: rgba(200, 100, 63, 0.18);
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.status-text,
.selection-text {
  margin: 0;
  color: var(--text-muted);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(25, 33, 42, 0.34);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  width: min(860px, calc(100% - 24px));
  max-height: min(80vh, 760px);
  margin: 48px auto;
  padding: 18px;
  overflow: auto;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(25, 33, 42, 0.18);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.1;
}

.modal-summary {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.94rem;
}

.storage-content {
  display: grid;
  gap: 12px;
}

.storage-section {
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  overflow: hidden;
}

.storage-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(25, 33, 42, 0.04);
}

.storage-section-title {
  margin: 0;
  font-size: 0.98rem;
}

.storage-count {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.storage-empty {
  margin: 0;
  padding: 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.storage-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.storage-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 16px;
  padding: 12px 14px;
  border-top: 1px solid var(--line-soft);
}

.storage-item-main {
  min-width: 0;
}

.storage-item-name,
.storage-item-path,
.storage-item-meta {
  margin: 0;
}

.storage-item-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.storage-item-path,
.storage-item-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.storage-item-size {
  align-self: center;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--accent-dark);
  white-space: nowrap;
}

.result-panel {
  margin-top: 16px;
  padding: 18px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.result-grid.list-layout {
  grid-template-columns: 1fr;
}

.frame-card {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line-soft);
}

.frame-preview {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #dbe4de;
}

.frame-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px 11px;
}

.frame-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
}

.frame-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.audio-card {
  display: grid;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(200, 100, 63, 0.06));
  border: 1px solid var(--line-soft);
}

.audio-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.audio-card-copy {
  min-width: 0;
}

.audio-card-title,
.audio-card-time,
.audio-card-filename {
  margin: 0;
}

.audio-card-title {
  font-size: 0.98rem;
  font-weight: 700;
}

.audio-card-time {
  margin-top: 3px;
  font-size: 0.85rem;
  color: var(--accent-dark);
}

.audio-card-filename {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.audio-preview {
  width: 100%;
}

.video-card {
  display: grid;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(25, 33, 42, 0.04));
  border: 1px solid var(--line-soft);
}

.video-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.video-card-copy {
  min-width: 0;
}

.video-card-title,
.video-card-time,
.video-card-filename {
  margin: 0;
}

.video-card-title {
  font-size: 0.98rem;
  font-weight: 700;
}

.video-card-time {
  margin-top: 3px;
  font-size: 0.85rem;
  color: var(--accent-dark);
}

.video-card-filename {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.video-preview {
  width: 100%;
  max-height: 360px;
  border-radius: 14px;
  background: #0f141a;
}

.storyline-card {
  overflow: hidden;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line-soft);
}

.storyline-preview {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #d8e0e8;
}

.storyline-card-copy {
  display: grid;
  gap: 4px;
  padding: 12px;
}

.storyline-card-title,
.storyline-card-time,
.storyline-card-meta {
  margin: 0;
}

.storyline-card-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.storyline-card-time {
  font-size: 0.84rem;
  color: var(--accent-dark);
}

.storyline-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.analysis-panel {
  margin-top: 16px;
  padding: 18px;
}

.analysis-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.analysis-header h2 {
  margin: 0;
  font-size: clamp(1.3rem, 3vw, 2rem);
  line-height: 1.1;
}

.analysis-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.analysis-content {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.analysis-block {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.82);
}

.analysis-block-title {
  margin: 0 0 10px;
  font-size: 0.94rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.analysis-paragraph {
  margin: 0;
  line-height: 1.65;
  color: var(--text-main);
}

.analysis-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text-main);
}

.analysis-list li + li {
  margin-top: 8px;
}

.analysis-object {
  display: grid;
  gap: 10px;
}

.analysis-object-item {
  padding: 12px;
  border-radius: 12px;
  background: rgba(25, 33, 42, 0.04);
}

.analysis-object-key {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

.prompt-block-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.prompt-sections {
  display: grid;
  gap: 12px;
}

.prompt-section {
  padding: 12px;
  border-radius: 12px;
  background: rgba(25, 33, 42, 0.03);
  border: 1px solid var(--line-soft);
}

.prompt-section-title {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

.prompt-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: keep-all;
  line-height: 1.7;
  color: var(--text-main);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.88rem;
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 960px);
    padding-top: 18px;
  }

  .hero {
    flex-direction: column;
  }

  .result-header,
  .toolbar,
  .modal-header,
  .audio-option-field,
  .analysis-header,
  .prompt-block-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-facts {
    justify-content: flex-start;
    max-width: none;
  }

  .result-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .modal-panel {
    margin: 18px auto;
    max-height: calc(100vh - 36px);
  }

  .storage-item {
    grid-template-columns: 1fr;
  }
}
