:root {
  color-scheme: light dark;
  --bg: #f7f4ef;
  --surface: #fffdf8;
  --surface-strong: #f0eadf;
  --text: #211f1b;
  --muted: #6d665b;
  --line: #d8d0c2;
  --accent: #12685d;
  --accent-strong: #0a4d45;
  --danger: #9d2b2b;
  --shadow: 0 16px 40px rgba(32, 28, 22, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171715;
    --surface: #22211e;
    --surface-strong: #2d2b26;
    --text: #f2eee6;
    --muted: #b9b0a2;
    --line: #48443c;
    --accent: #53c4b4;
    --accent-strong: #87d9cf;
    --danger: #ff8f8f;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.32);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Pretendard, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

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

.app-shell {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 16px;
  gap: 16px;
  max-width: 1600px;
  margin-left: auto;
  margin-right: auto;
}

.toolbar {
  display: grid;
  grid-template-columns: auto 120px 220px 180px;
  gap: 16px;
  align-items: end;
  margin-bottom: 0;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.theme-toggle:hover {
  background-color: var(--surface-strong);
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

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

.editor-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}

.panel-head {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  color: var(--muted);
  font-weight: 700;
}

.actions {
  display: flex;
  gap: 8px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  flex: 1;
  min-height: 100px;
  resize: none;
  border: 0;
  border-radius: 0 0 8px 8px;
  padding: 16px;
  background: transparent;
  line-height: 1.72;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

fieldset {
  display: grid;
  gap: 10px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

fieldset label,
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

input[type="radio"],
input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

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

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.primary-button {
  min-height: 52px;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

@media (prefers-color-scheme: dark) {
  .primary-button {
    color: #0b1c19;
  }
}

.status {
  min-height: 48px;
  margin: auto 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.status.error {
  color: var(--danger);
}

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

  .editor-panel {
    min-height: 420px;
  }

  textarea {
    min-height: 340px;
  }
}

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

  .toolbar {
    gap: 12px;
  }


  .panel-head {
    min-height: 64px;
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 14px;
  }

  .actions {
    width: 100%;
  }

  .actions button {
    flex: 1;
  }
}
