:root {
  --bg-night: #071223;
  --bg-deep: #0f2f4a;
  --bg-ocean: #1e658f;
  --accent-ember: #ed6f2a;
  --accent-gold: #f3b65c;
  --ink-strong: #e7f3ff;
  --ink-soft: rgba(231, 243, 255, 0.78);
  --panel-bg: rgba(10, 30, 51, 0.67);
  --panel-border: rgba(255, 255, 255, 0.12);
  --danger: #d64545;
  --success: #3cb371;
  --shadow-strong: 0 24px 45px rgba(0, 0, 0, 0.35);
  --radius-xl: 22px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: 'Avenir Next', 'Hiragino Sans', 'Yu Gothic UI', 'Noto Sans JP', sans-serif;
  color: var(--ink-strong);
  background: radial-gradient(circle at 78% 10%, rgba(243, 182, 92, 0.35), transparent 35%),
    radial-gradient(circle at 8% 90%, rgba(237, 111, 42, 0.22), transparent 42%),
    linear-gradient(130deg, var(--bg-night) 0%, var(--bg-deep) 58%, var(--bg-ocean) 100%);
  position: relative;
  overflow-x: hidden;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: radial-gradient(circle, #ffffff 0.7px, transparent 0.7px);
  background-size: 3px 3px;
  animation: pulse-grain 14s linear infinite;
}

.app-shell {
  width: min(1400px, calc(100vw - 2.2rem));
  margin: 1.1rem auto 1.4rem;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1rem;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  background: var(--panel-bg);
  box-shadow: var(--shadow-strong);
  backdrop-filter: blur(14px);
  padding: 1rem 1.1rem;
  animation: rise 0.5s ease both;
}

.sidebar {
  position: sticky;
  top: 1.1rem;
  height: calc(100vh - 2.5rem);
  overflow: auto;
}

.brand h1 {
  margin: 0.1rem 0 0.5rem;
  font-family: 'Avenir Next Condensed', 'Hiragino Kaku Gothic ProN', sans-serif;
  letter-spacing: 0.03em;
  font-size: 1.95rem;
}

.brand-eyebrow {
  margin: 0;
  font-size: 0.73rem;
  letter-spacing: 0.22em;
  color: var(--accent-gold);
}

.brand-caption {
  margin: 0 0 1rem;
  color: var(--ink-soft);
  line-height: 1.4;
  font-size: 0.89rem;
}

.main {
  display: grid;
  gap: 1rem;
}

.status-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.status-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.status-badge {
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.status-badge.ok {
  border-color: rgba(60, 179, 113, 0.8);
  background: rgba(60, 179, 113, 0.17);
}

.status-badge.warn {
  border-color: rgba(243, 182, 92, 0.85);
  background: rgba(243, 182, 92, 0.2);
}

.section-title {
  margin: 0;
  font-size: 0.99rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.section-caption {
  margin: 0.32rem 0 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.panel-header,
.section-head,
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.panel-actions,
.tab-row,
.action-grid {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.26);
  color: var(--ink-strong);
  background: rgba(255, 255, 255, 0.08);
  padding: 0.56rem 0.9rem;
  border-radius: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.16);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.button-primary {
  width: 100%;
  margin-bottom: 0.8rem;
  background: linear-gradient(120deg, #0e5e93, #1f7da8);
  border-color: rgba(125, 214, 255, 0.7);
}

.button-strong {
  background: linear-gradient(130deg, rgba(237, 111, 42, 0.87), rgba(243, 182, 92, 0.83));
  border-color: rgba(255, 231, 180, 0.75);
  color: #132237;
}

.button-danger {
  border-color: rgba(214, 69, 69, 0.7);
  background: rgba(214, 69, 69, 0.24);
}

.project-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.42rem;
}

.project-item {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.7rem;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.project-item:hover {
  border-color: rgba(255, 255, 255, 0.45);
  transform: translateY(-1px);
}

.project-item.active {
  border-color: rgba(243, 182, 92, 0.93);
  background: rgba(243, 182, 92, 0.11);
}

.project-item h3 {
  margin: 0;
  font-size: 0.95rem;
}

.project-item p {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.form-grid {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.form-grid label.full-row {
  grid-column: 1 / -1;
}

.form-grid label,
.section-item label {
  display: grid;
  gap: 0.34rem;
}

.form-grid label span,
.section-item label span {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.form-grid textarea {
  min-height: 80px;
}

select,
input,
textarea {
  width: 100%;
  color: var(--ink-strong);
  border: 1px solid rgba(255, 255, 255, 0.23);
  border-radius: 11px;
  background: rgba(6, 18, 36, 0.66);
  padding: 0.58rem 0.68rem;
  font-family: inherit;
  resize: vertical;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.7) 50%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.7) 50%, transparent 50%);
  background-position: calc(100% - 15px) calc(1em + 3px), calc(100% - 10px) calc(1em + 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(243, 182, 92, 0.83);
  box-shadow: 0 0 0 2px rgba(243, 182, 92, 0.22);
}

.section-head {
  margin-top: 0.92rem;
}

.top-gap {
  margin-top: 1.2rem;
}

.chat-log {
  margin-top: 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-md);
  padding: 0.6rem;
  max-height: 260px;
  overflow: auto;
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 0.52rem;
}

.chat-item {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 0.52rem;
  background: rgba(255, 255, 255, 0.03);
}

.chat-item.user {
  border-color: rgba(243, 182, 92, 0.7);
  background: rgba(243, 182, 92, 0.12);
}

.chat-item.assistant {
  border-color: rgba(109, 205, 255, 0.65);
  background: rgba(109, 205, 255, 0.1);
}

.chat-role {
  margin: 0 0 0.2rem;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.chat-content {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.chat-compose {
  margin-top: 0.58rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: end;
}

.sections-container {
  margin-top: 0.6rem;
  display: grid;
  gap: 0.6rem;
}

.section-item {
  display: grid;
  grid-template-columns: 1.2fr 1.8fr auto;
  gap: 0.48rem;
  align-items: end;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-md);
  padding: 0.55rem;
  background: rgba(255, 255, 255, 0.04);
}

.section-item .full-row {
  grid-column: 1 / -1;
}

.roles-container {
  margin-top: 0.6rem;
  display: grid;
  gap: 0.6rem;
}

.role-item {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  align-items: end;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-md);
  padding: 0.6rem;
  background: rgba(255, 255, 255, 0.04);
}

.action-panel {
  display: grid;
  gap: 0.85rem;
}

.workflow-status {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.42rem;
}

.workflow-step {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 0.42rem 0.5rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.03);
}

.workflow-step.done {
  border-color: rgba(60, 179, 113, 0.7);
  background: rgba(60, 179, 113, 0.12);
  color: #d9ffe8;
}

.workflow-step.in-progress {
  border-color: rgba(243, 182, 92, 0.85);
  background: rgba(243, 182, 92, 0.16);
  color: #fff2d9;
}

.action-log {
  margin: 0;
  min-height: 1.3rem;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.screen-tabs {
  margin-top: 0.95rem;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.screen-nav {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.screen-current-label {
  margin: 0;
  font-size: 0.84rem;
  color: var(--ink-soft);
  flex: 1;
  text-align: center;
}

.screen-tab {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.27);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink-strong);
  padding: 0.42rem 0.78rem;
  font-size: 0.82rem;
  cursor: pointer;
}

.screen-tab.active {
  background: rgba(243, 182, 92, 0.25);
  border-color: rgba(243, 182, 92, 0.85);
}

.workflow-screen {
  display: none;
  margin-top: 0.65rem;
}

.workflow-screen.active {
  display: block;
}

.panel-actions .button-primary {
  width: auto;
  margin-bottom: 0;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(4, 15, 26, 0.62);
  display: grid;
  place-items: center;
}

.busy-card {
  min-width: 240px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  background: rgba(8, 24, 41, 0.9);
  padding: 1rem 1.1rem;
  display: grid;
  justify-items: center;
  gap: 0.55rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.busy-spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--accent-gold);
  animation: spin 0.9s linear infinite;
}

body.is-busy {
  cursor: wait;
}

.tab {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.27);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink-strong);
  padding: 0.42rem 0.78rem;
  font-size: 0.82rem;
  cursor: pointer;
}

.tab.active {
  background: rgba(243, 182, 92, 0.25);
  border-color: rgba(243, 182, 92, 0.85);
}

.view {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.62rem;
}

.stack-grid {
  display: grid;
  gap: 0.62rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.hidden {
  display: none;
}

.card {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.72rem;
}

.card h3,
.card h4 {
  margin: 0 0 0.4rem;
}

.card ul {
  margin: 0.35rem 0;
  padding-left: 1rem;
}

.meta {
  margin: 0.1rem 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.kv {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 0.55rem;
  align-items: center;
}

.kv dt {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.kv dd {
  margin: 0;
}

.slide-card {
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 18px;
  padding: 0.86rem;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03));
}

.slide-preview {
  margin-top: 0.55rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(145deg, rgba(4, 17, 30, 0.94), rgba(13, 43, 67, 0.94));
  overflow: hidden;
}

.slide-preview-body {
  padding: 0.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 0.72rem;
}

.slide-preview h4 {
  margin: 0 0 0.35rem;
}

.slide-preview ul {
  margin: 0;
  padding-left: 1rem;
  color: var(--ink-soft);
}

.asset-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.asset-grid {
  display: grid;
  gap: 0.62rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.asset-choice {
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
}

.asset-choice.selected {
  border-color: rgba(243, 182, 92, 0.86);
  background: rgba(243, 182, 92, 0.12);
}

.candidate-row {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 0.55rem;
}

.note {
  color: var(--ink-soft);
  font-size: 0.84rem;
}

@keyframes rise {
  from {
    transform: translateY(9px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes pulse-grain {
  0% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(-4px);
  }
  100% {
    transform: translateX(0);
  }
}

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

@media (max-width: 1160px) {
  .app-shell {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .slide-preview-body {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 920px) {
  .app-shell {
    width: min(1400px, calc(100vw - 1rem));
    margin: 0.5rem auto 1rem;
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    max-height: none;
  }

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

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

  .chat-compose {
    grid-template-columns: 1fr;
  }

  .screen-nav {
    flex-wrap: wrap;
  }

  .screen-current-label {
    order: 3;
    width: 100%;
    text-align: left;
  }

  .status-panel,
  .panel-header,
  .section-head,
  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
