:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-muted: #eef2ed;
  --text: #202621;
  --muted: #68736a;
  --line: #dbe2dc;
  --green: #1f7a59;
  --green-dark: #165a42;
  --coral: #d75d49;
  --amber: #b7771f;
  --focus: #244a9b;
  --shadow: 0 18px 40px rgba(32, 38, 33, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    Pretendard,
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0 22px;
}

.topbar h1,
.result-header h2,
.panel-section h2,
.history-block h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
}

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

.status-pill,
.source-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.ready,
.source-badge.ready {
  border-color: rgba(31, 122, 89, 0.35);
  background: #e8f4ee;
  color: var(--green-dark);
}

.status-pill.demo,
.source-badge.demo {
  border-color: rgba(183, 119, 31, 0.35);
  background: #fff5e4;
  color: #80500d;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 20px;
  align-items: start;
}

.writer-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.writer-panel {
  padding: 22px;
}

.result-panel {
  position: sticky;
  top: 18px;
  padding: 20px;
}

.panel-section {
  padding: 0 0 24px;
  margin: 0 0 24px;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-of-type {
  margin-bottom: 16px;
}

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

.section-heading.compact {
  margin-top: 18px;
  margin-bottom: 10px;
}

.panel-section h2,
.result-header h2,
.history-block h2 {
  font-size: 18px;
  line-height: 1.25;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border-radius: 8px;
  background: var(--surface-muted);
  margin-bottom: 16px;
}

.segment {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segment.active {
  background: var(--surface);
  color: var(--green-dark);
  box-shadow: 0 5px 14px rgba(32, 38, 33, 0.08);
}

.field-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

label:last-child,
.field-grid label {
  margin-bottom: 0;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

textarea {
  resize: vertical;
  min-height: 84px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--focus);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(36, 74, 155, 0.12);
}

.sticky-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 850;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--green);
  color: #ffffff;
  padding: 0 18px;
}

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

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--text);
  padding: 0 14px;
}

.ghost-button {
  min-height: 34px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--green-dark);
  padding: 0 11px;
  font-size: 13px;
}

.button-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  font-size: 13px;
  line-height: 1;
}

.secondary-button .button-icon {
  background: rgba(31, 122, 89, 0.12);
  color: var(--green-dark);
}

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

.icon-button {
  border-color: var(--line);
  background: #fbfcfb;
  color: var(--text);
  padding: 0 8px;
  font-size: 13px;
}

.icon-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  border-color: rgba(31, 122, 89, 0.45);
  background: #f1f7f3;
}

.output-box {
  width: 100%;
  min-height: 440px;
  max-height: 58vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  margin: 0;
  padding: 16px;
  color: var(--text);
  font-family:
    "Noto Sans KR",
    "Segoe UI",
    system-ui,
    sans-serif;
  font-size: 15px;
  line-height: 1.68;
  white-space: pre-wrap;
}

.output-box.loading {
  color: var(--muted);
}

.output-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.refine-box {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.full {
  width: 100%;
}

.draft-list {
  display: grid;
  gap: 8px;
  min-height: 44px;
}

.draft-item {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 10px;
  color: var(--text);
  text-align: left;
}

.draft-item:hover {
  border-color: rgba(215, 93, 73, 0.45);
  background: #fff7f4;
}

.draft-title {
  font-size: 13px;
  font-weight: 850;
}

.draft-preview {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-history {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .result-panel {
    position: static;
  }

  .output-box {
    min-height: 360px;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .field-grid.two,
  .field-grid.three {
    grid-template-columns: 1fr;
  }

  .segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sticky-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }
}
