:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --border: #d9d9d9;
  --text: #171717;
  --muted: #666666;
  --accent: #111111;
  --soft: #f5f5f5;
  --success-bg: #eef8f1;
  --success-text: #17643a;
  --error-bg: #fff1f0;
  --error-text: #9f1d16;
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

code,
pre {
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    monospace;
}

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

.header {
  margin-bottom: 20px;
}

.header h1 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.mode-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.mode-button,
.primary-button,
.secondary-button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
}

.info-card {
  padding: 16px;
  margin-bottom: 16px;
}

.info-card h2,
.panel-head h2,
.result-card h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.info-card ul {
  margin: 0 0 12px 18px;
  padding: 0;
  line-height: 1.6;
}

.info-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.panel,
.output {
  padding: 16px;
}

.panel.is-hidden {
  display: none;
}

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

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

.field span {
  font-size: 0.92rem;
  font-weight: 600;
}

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

input {
  padding: 10px 12px;
}

textarea {
  min-height: 300px;
  padding: 12px;
  line-height: 1.5;
  resize: vertical;
}

.grid-2 input {
  max-width: 180px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--muted);
}

.status[data-state="success"] {
  background: var(--success-bg);
  color: var(--success-text);
}

.status[data-state="error"] {
  background: var(--error-bg);
  color: var(--error-text);
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  margin-bottom: 16px;
}

.result-card + .result-card {
  margin-top: 0;
}

.recommendation,
.alternatives {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

.code-block {
  margin: 0;
  min-height: 220px;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafafa;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.preview {
  border: 1px solid var(--border);
  border-radius: 10px;
  background:
    linear-gradient(45deg, #f7f7f7 25%, transparent 25%),
    linear-gradient(-45deg, #f7f7f7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f7f7f7 75%),
    linear-gradient(-45deg, transparent 75%, #f7f7f7 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.preview-box {
  min-height: 320px;
  display: grid;
  place-items: center;
  padding: 20px;
}

.shape-preview {
  display: none;
  width: min(100%, 260px);
  aspect-ratio: var(--preview-ratio, 1 / 1);
  background: var(--preview-fill, #111);
  clip-path: var(--preview-clip, none);
}

.svg-preview {
  display: none;
  width: 100%;
}

.svg-preview svg {
  display: block;
  max-width: 100%;
  max-height: 260px;
  margin: 0 auto;
}

.alt-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fafafa;
}

.alt-card + .alt-card {
  margin-top: 10px;
}

.alt-card h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.alt-card p {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.5;
}

.alt-card pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

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

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