:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e1ea;
  --teal: #168f7a;
  --teal-dark: #0f6f60;
  --coral: #ef6b57;
  --amber: #f0b429;
  --blue: #3563e9;
  --shadow: 0 16px 36px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", Arial, sans-serif;
}

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

button,
select {
  min-height: 40px;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 24px;
  background: #111827;
  color: #f9fafb;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-block {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), var(--coral));
  font-weight: 800;
  letter-spacing: 0;
}

.brand-block h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.brand-block p,
.muted {
  margin: 4px 0 0;
  color: var(--muted);
}

.sidebar .muted {
  color: #aab4c3;
}

.side-section {
  margin-top: 28px;
}

.side-section h2 {
  margin: 0 0 12px;
  color: #dbe7f3;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.step-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step-list li {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #dbe7f3;
  font-size: 14px;
}

.step-list li[data-status="done"] {
  border-color: rgba(22, 143, 122, 0.45);
}

.step-list li[data-status="active"] {
  border-color: rgba(239, 107, 87, 0.65);
  background: rgba(239, 107, 87, 0.12);
}

.learning-profile {
  display: grid;
  gap: 10px;
}

.profile-row {
  display: grid;
  gap: 6px;
}

.profile-row strong {
  font-size: 13px;
  color: #eef4fb;
}

.meter {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  width: var(--value);
  background: linear-gradient(90deg, var(--teal), var(--amber));
}

.workspace {
  display: grid;
  gap: 18px;
  align-content: start;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.topbar h2 {
  margin: 4px 0 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.18;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-pill,
.tiny-tag {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.control-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

select {
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 112px;
  padding: 12px;
  line-height: 1.55;
}

select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(22, 143, 122, 0.12);
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(320px, 1.1fr);
  gap: 18px;
}

.panel {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.full-panel {
  min-width: 0;
}

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

.panel-heading h3 {
  margin: 4px 0 0;
  font-size: 19px;
  letter-spacing: 0;
}

.primary-btn,
.secondary-btn,
.small-btn {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0;
}

.primary-btn {
  padding: 0 16px;
  background: var(--teal);
  color: #fff;
}

.primary-btn:hover {
  background: var(--teal-dark);
}

.secondary-btn {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary-btn:hover,
.small-btn:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.small-btn {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 156px;
  padding: 18px;
  border: 1px dashed #a8b5c5;
  border-radius: 8px;
  background: #f9fbfd;
  text-align: center;
  cursor: pointer;
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drop-zone span {
  color: var(--ink);
  font-size: 18px;
}

.drop-zone small {
  max-width: 320px;
  color: var(--muted);
  line-height: 1.45;
}

.preview-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
  min-height: 0;
  margin: 12px 0;
}

.preview-item {
  display: grid;
  gap: 6px;
}

.preview-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.preview-item small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-block {
  margin-top: 12px;
}

.analysis-grid,
.prompt-board,
.gallery,
.copy-output {
  min-height: 132px;
}

.empty-state {
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  text-align: center;
  padding: 20px;
}

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

.analysis-card,
.prompt-card,
.result-card,
.copy-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.analysis-card {
  padding: 12px;
}

.analysis-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.analysis-card p {
  margin: 0;
  line-height: 1.5;
}

.palette {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: var(--color);
}

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

.prompt-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  cursor: pointer;
}

.prompt-card[data-selected="true"] {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(22, 143, 122, 0.12);
}

.prompt-card h4,
.result-card h4,
.copy-card h4 {
  margin: 0;
  font-size: 16px;
}

.prompt-card p,
.copy-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.prompt-text {
  max-height: 112px;
  overflow: auto;
  padding: 10px;
  border-radius: 8px;
  background: #f7f9fc;
  color: #344054;
  font-size: 13px;
  line-height: 1.55;
}

.tag-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef7f5;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
}

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

.result-card {
  overflow: hidden;
}

.result-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #eef2f7;
}

.result-body {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.rating-row,
.reason-row,
.inline-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.rating-row button[data-active="true"],
.reason-row button[data-active="true"] {
  border-color: var(--coral);
  color: var(--coral);
  background: #fff6f3;
}

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

.copy-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.copy-card .headline {
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: none;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  box-shadow: var(--shadow);
}

.toast[data-show="true"] {
  display: block;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .control-band,
  .work-grid,
  .prompt-board,
  .gallery,
  .copy-output {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .panel-heading {
    display: grid;
  }

  .control-band,
  .work-grid,
  .analysis-grid,
  .prompt-board,
  .gallery,
  .copy-output {
    grid-template-columns: 1fr;
  }

  .primary-btn,
  .secondary-btn,
  .inline-controls select,
  .inline-controls button {
    width: 100%;
  }
}
