:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --panel-alt: #f8faf9;
  --text: #1e2624;
  --muted: #64716d;
  --line: #d9ddd7;
  --accent: #1e6f5c;
  --accent-dark: #145142;
  --warn-bg: #fff3d7;
  --warn-text: #6d4b00;
  --bad-bg: #fde9e4;
  --bad-text: #7d2b1f;
  --blue: #255f8f;
  --shadow: 0 12px 28px rgba(31, 45, 41, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 16px;
  max-width: 1680px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
}

h3 {
  font-size: 15px;
  line-height: 1.25;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.status-pill,
.level-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid rgba(30, 111, 92, 0.22);
  border-radius: 6px;
  padding: 5px 10px;
  background: #e6f1ed;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.muted {
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(230px, 0.75fr) minmax(460px, 1.6fr) minmax(320px, 1fr);
  gap: 16px;
  margin: 0 auto;
  max-width: 1680px;
}

.bottom-workspace {
  display: grid;
  grid-template-columns: minmax(480px, 1.35fr) minmax(360px, 1fr);
  gap: 16px;
  margin: 16px auto 0;
  max-width: 1680px;
}

.case-panel,
.main-panel,
.result-panel,
.prompt-panel,
.feedback-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.case-panel,
.main-panel,
.result-panel {
  padding: 16px;
}

.prompt-panel,
.feedback-panel {
  padding: 16px;
}

.panel-heading,
.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.muted-text,
.small-count {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.case-list {
  display: grid;
  gap: 10px;
}

.case-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--text);
  text-align: left;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    transform 0.18s ease;
}

.case-button:hover,
.case-button.active {
  border-color: var(--accent);
  background: #f0f7f4;
}

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

.case-name {
  display: block;
  margin-bottom: 6px;
  font-weight: 800;
}

.case-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 5px;
  padding: 3px 7px;
  background: #eef1ef;
  color: #45504c;
  font-size: 12px;
  font-weight: 700;
}

.tag.success {
  background: #e3f2eb;
  color: var(--accent-dark);
}

.tag.warning {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.risk-notice {
  display: none;
  margin-bottom: 14px;
  border: 1px solid #efc66d;
  border-radius: 8px;
  padding: 12px;
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 14px;
  line-height: 1.5;
}

.risk-notice.show {
  display: block;
}

.section-block {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

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

.asset-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-alt);
}

.asset-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: #e8ece9;
}

.asset-body {
  min-height: 76px;
  padding: 9px;
}

.asset-role {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.asset-name {
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 111, 92, 0.12);
}

.primary-button,
.ghost-button {
  min-height: 36px;
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 800;
  white-space: nowrap;
}

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

.primary-button:hover {
  background: var(--accent-dark);
}

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

.ghost-button:hover {
  border-color: var(--accent);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}

.segmented button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.segmented button.active {
  border-color: var(--blue);
  background: #e8f0f7;
  color: #17496f;
}

.result-view {
  margin: 0;
}

.result-view img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8ece9;
  object-fit: cover;
}

.result-view figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.result-notes {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.live-generation {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

.generation-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--text);
  white-space: nowrap;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.wide-button {
  width: 100%;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.generation-status {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-alt);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.generation-status[data-tone="success"] {
  border-color: rgba(30, 111, 92, 0.32);
  background: #e8f5ef;
  color: var(--accent-dark);
}

.generation-status[data-tone="warning"] {
  border-color: #efc66d;
  background: var(--warn-bg);
  color: var(--warn-text);
}

.generation-status[data-tone="error"] {
  border-color: #f0a899;
  background: var(--bad-bg);
  color: var(--bad-text);
}

.generated-view {
  margin: 12px 0 0;
}

.generated-view img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8ece9;
  object-fit: cover;
}

.generated-view figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.note {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-alt);
  font-size: 13px;
  line-height: 1.45;
}

.note strong {
  color: var(--accent-dark);
}

#promptPreview {
  min-height: 280px;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
}

.feedback-form {
  display: grid;
  grid-template-columns: minmax(130px, 0.45fr) minmax(180px, 1fr) auto;
  gap: 8px;
  margin-bottom: 12px;
}

.feedback-list {
  display: grid;
  gap: 8px;
  max-height: 282px;
  overflow: auto;
}

.feedback-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  font-size: 13px;
  line-height: 1.45;
}

.feedback-item .time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 320px;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--text);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .result-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .workspace,
  .bottom-workspace {
    display: grid;
    grid-template-columns: 1fr;
  }

  .asset-grid,
  .config-grid,
  .feedback-form {
    grid-template-columns: 1fr;
  }

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

  .generation-controls {
    grid-template-columns: 1fr;
  }

  .checkbox-row {
    justify-content: flex-start;
  }
}
