:root {
  --bg: #f6f3ed;
  --surface: #fffdfa;
  --surface-2: #f0faf7;
  --ink: #1f2827;
  --muted: #697572;
  --line: #ddd6ca;
  --accent: #0f766e;
  --accent-2: #c2415a;
  --accent-3: #a56b2a;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(50, 43, 34, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Yu Gothic UI",
    "Meiryo",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 24px;
  background: #25312f;
  color: #fffdfa;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.topbar h1,
.topbar p {
  margin: 0;
}

.topbar h1 {
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

.eyebrow {
  color: #bcd6d0;
  font-size: 12px;
  line-height: 1.3;
}

.topbar-actions,
.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  transition:
    background 120ms ease,
    border-color 120ms ease,
    transform 120ms ease;
}

.button:hover {
  border-color: #b9aa98;
  background: #fff7eb;
}

.button:active {
  transform: translateY(1px);
}

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

.button.primary:hover {
  background: #0b625b;
}

.button.ghost {
  background: transparent;
  color: inherit;
}

.button.danger {
  border-color: #e1b7b2;
  color: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(860px, 1fr);
  min-height: calc(100vh - 75px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-right: 1px solid var(--line);
  background: #ede6da;
}

.panel,
.table-panel,
.editor-panel,
.preview-panel,
.wide-panel,
.research-card,
.caption-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(31, 40, 39, 0.04);
}

.panel {
  padding: 14px;
}

h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: 0;
}

.field {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.field span,
.mix-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d3c8bb;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input,
select {
  min-height: 38px;
  padding: 0 10px;
}

textarea {
  padding: 10px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.16);
}

.mix-row {
  display: grid;
  grid-template-columns: 70px 1fr 28px;
  align-items: center;
  gap: 10px;
  min-height: 36px;
}

.mix-row strong {
  color: var(--accent);
  font-size: 13px;
}

.content {
  min-width: 0;
  padding: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tab {
  min-width: 92px;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

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

.status-pill,
.ng-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e4f4f0;
  color: #0b625b;
  font-size: 12px;
  font-weight: 700;
}

.ng-badge {
  background: #fff0ed;
  color: var(--danger);
}

.hidden {
  display: none;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.planner-grid {
  display: grid;
  grid-template-columns: 37% 33% minmax(260px, 30%);
  gap: 12px;
  align-items: stretch;
  height: calc(100vh - 142px);
  min-height: 660px;
}

.table-panel,
.editor-panel,
.preview-panel {
  min-height: 0;
  overflow: hidden;
}

.table-head,
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.reel-list {
  height: calc(100% - 63px);
  overflow: auto;
  padding: 8px;
}

.reel-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: start;
  gap: 10px;
  width: 100%;
  margin-bottom: 6px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fbf8f1;
  color: inherit;
  text-align: left;
}

.reel-row:hover {
  border-color: #d0c2b0;
}

.reel-row.active {
  border-color: var(--accent);
  background: var(--surface-2);
}

.row-day {
  display: grid;
  place-items: center;
  min-height: 40px;
  border-radius: 8px;
  background: #eadfcf;
  color: #4f3c25;
  font-size: 12px;
  font-weight: 700;
}

.row-main strong {
  display: block;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-main span {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-tag {
  min-width: 64px;
  padding: 5px 7px;
  border-radius: 999px;
  background: #e9edf4;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.type-tag.three {
  background: #e4f4f0;
  color: #0b625b;
}

.type-tag.stop {
  background: #f5e8ee;
  color: #9a3152;
}

.type-tag.ranking {
  background: #f4ead8;
  color: #8a551d;
}

.editor-scroll {
  height: calc(100% - 57px);
  overflow: auto;
  padding: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-grid .field:nth-child(3) {
  grid-column: 1 / -1;
}

.preview-panel {
  display: grid;
  grid-template-rows: minmax(410px, 1fr) minmax(220px, 0.65fr);
  gap: 12px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.phone-preview {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 0;
  padding: 22px;
  border: 1px solid #20302e;
  border-radius: 28px;
  background:
    linear-gradient(160deg, rgba(15, 118, 110, 0.78), rgba(194, 65, 90, 0.66)),
    url("data:image/svg+xml,%3Csvg width='390' height='690' viewBox='0 0 390 690' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='390' height='690' fill='%2325312f'/%3E%3Cpath d='M0 122C70 90 130 88 210 130C286 170 326 146 390 108V690H0Z' fill='%233a463e'/%3E%3Ccircle cx='72' cy='96' r='38' fill='%23e7d8b6' fill-opacity='.2'/%3E%3Ccircle cx='316' cy='212' r='70' fill='%230f766e' fill-opacity='.18'/%3E%3C/svg%3E");
  background-size: cover;
  color: #fff;
  box-shadow: var(--shadow);
}

.preview-topline {
  align-self: start;
  justify-self: stretch;
  margin-bottom: 18px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.preview-card {
  display: grid;
  gap: 16px;
  width: min(100%, 320px);
  padding: 24px 18px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 8px;
  background: rgba(21, 27, 25, 0.42);
  backdrop-filter: blur(12px);
  text-align: center;
}

.preview-kicker {
  margin: 0;
  color: #bfe5dd;
  font-size: 13px;
  font-weight: 700;
}

.preview-card h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.35;
}

.preview-card p {
  margin: 0;
  line-height: 1.65;
}

.choice-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.choice-row span {
  display: grid;
  place-items: center;
  min-height: 56px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 26px;
  font-weight: 700;
}

.preview-cta {
  color: #ffe8b8;
  font-size: 13px;
}

.caption-box {
  min-height: 0;
  overflow: hidden;
}

.caption-box h2 {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

pre {
  height: calc(100% - 48px);
  margin: 0;
  overflow: auto;
  padding: 12px;
  color: #33413f;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.wide-panel {
  padding: 0;
  overflow: hidden;
}

.field-map {
  display: grid;
  grid-template-columns: 210px 180px 1fr;
}

.map-row {
  display: contents;
}

.map-row > div {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  line-height: 1.5;
}

.map-row.header > div {
  background: #25312f;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.map-row code {
  color: var(--accent);
  font-family: Consolas, monospace;
  font-size: 13px;
}

.research-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.research-workspace {
  display: grid;
  gap: 12px;
}

.research-input-panel {
  min-height: 0;
}

.research-form {
  padding: 12px;
}

.research-list-panel,
.research-insight-panel {
  min-height: 520px;
  overflow: hidden;
}

.research-list,
.research-insights {
  height: calc(100% - 57px);
  max-height: calc(100vh - 345px);
  overflow: auto;
  padding: 12px;
}

.research-card {
  padding: 18px;
}

.research-card p {
  margin: 10px 0 0;
  color: #475350;
  line-height: 1.75;
}

.research-result-card {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf8f1;
}

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

.research-card-head h3,
.insight-section h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}

.research-card-head p {
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-badge {
  display: grid;
  place-items: center;
  min-width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.research-meta,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.research-meta span,
.chip-row span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: #e9edf4;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.chip-row span {
  background: #e4f4f0;
  color: #0b625b;
}

.research-note {
  margin: 0;
  color: #33413f;
  font-size: 13px;
  line-height: 1.7;
}

.research-card-actions {
  display: flex;
  justify-content: flex-end;
}

.insight-section {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.idea-list {
  margin: 0;
  padding-left: 22px;
  color: #33413f;
  line-height: 1.8;
}

@media (max-width: 980px) {
  body {
    min-width: 0;
  }

  .topbar,
  .workspace,
  .planner-grid,
  .research-grid {
    display: block;
  }

  .topbar-actions,
  .toolbar {
    flex-wrap: wrap;
    margin-top: 12px;
  }

  .workspace {
    min-height: auto;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .planner-grid {
    height: auto;
    min-height: auto;
  }

  .table-panel,
  .editor-panel,
  .preview-panel {
    margin-bottom: 12px;
  }

  .reel-list,
  .editor-scroll,
  .research-list,
  .research-insights {
    height: auto;
    max-height: 520px;
  }

  .preview-panel {
    display: block;
  }

  .phone-preview {
    min-height: 560px;
    margin-bottom: 12px;
  }
}
