:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --bg-2: #fbfbfd;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-soft: rgba(255, 255, 255, 0.76);
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --surface-3: #ebebf0;
  --line: rgba(17, 24, 39, 0.08);
  --line-strong: rgba(17, 24, 39, 0.14);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --muted-2: #8a8a8f;
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.14);
  --positive: #1f9d55;
  --negative: #d92d20;
  --shadow-lg: 0 18px 50px rgba(15, 23, 42, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}

.hero {
  margin-bottom: 22px;
  padding: 34px 30px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(247, 247, 250, 0.94));
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 0.95;
  letter-spacing: -0.05em;
  font-weight: 700;
}

.hero .subtle {
  max-width: 780px;
  font-size: 17px;
  line-height: 1.65;
}

.grid { display: grid; gap: 20px; }
.two-col { grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); }
.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.four-col { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.five-col { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stack { display: grid; gap: 16px; }
.compact { gap: 12px; }

.subpanel {
  background: linear-gradient(180deg, rgba(250, 250, 252, 0.95), rgba(243, 244, 247, 0.95));
  box-shadow: none;
}

details > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 600;
}

details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: 'Show'; color: var(--muted); font-size: 12px; }
details[open] > summary::after { content: 'Hide'; }

.advanced-stack { margin-top: 14px; }
.compact-note { font-size: 13px; line-height: 1.5; }

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

input[type='checkbox'] {
  width: auto;
  margin-right: 8px;
  accent-color: var(--accent);
}

input,
textarea,
select,
button {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 13px 15px;
  font: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

input::placeholder,
textarea::placeholder { color: var(--muted-2); }

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(0, 113, 227, 0.55);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

textarea { resize: vertical; min-height: 48px; }
textarea#prompt {
  min-height: 184px;
  line-height: 1.58;
  background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
}

button {
  cursor: pointer;
  border: 0;
  font-weight: 600;
  background: linear-gradient(180deg, #1482f0 0%, var(--accent) 100%);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(0, 113, 227, 0.16);
}

button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }

button.secondary,
.template-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.actions.wrap { flex-wrap: wrap; }
.actions button { width: auto; min-width: 168px; }

#status {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
}

.subtle { color: var(--muted); }
h1, h2, p { margin-top: 0; }

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

.metric {
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f8f8fa 100%);
}

.metric .label { color: var(--muted); font-size: 12px; }
.metric .value {
  margin-top: 10px;
  font-size: clamp(24px, 2.8vw, 32px);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.strategy-card {
  min-height: 140px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f8f8fa 100%);
  white-space: pre-wrap;
}

.strategy-card.info { white-space: normal; }

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

.info-row {
  padding: 12px 13px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid rgba(17, 24, 39, 0.05);
}

.info-row .key {
  display: block;
  margin-bottom: 5px;
  color: var(--muted-2);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.info-row .val { font-size: 14px; color: var(--text); }
.info-divider { height: 1px; margin: 15px 0; background: rgba(17, 24, 39, 0.08); }
.info-lead,
.bullet-list { color: var(--muted); line-height: 1.64; }
.bullet-list { margin: 0; padding-left: 18px; }
.bullet-list li + li { margin-top: 8px; }

.error-card h3 {
  margin: 8px 0 10px;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.error-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(0, 113, 227, 0.08);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

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

.rewrite-list .rewrite-btn {
  justify-content: flex-start;
  text-align: left;
  font-size: 14px;
}

canvas {
  width: 100%;
  height: auto;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f6f6f9 100%);
}

.table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #ffffff;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { position: sticky; top: 0; z-index: 1; background: #fafafa; }
th,
td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid rgba(17, 24, 39, 0.06);
}
th {
  color: var(--muted-2);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
tbody tr:hover { background: rgba(17, 24, 39, 0.02); }

@media (max-width: 1180px) {
  .two-col,
  .four-col,
  .five-col,
  .metrics-grid.wide,
  .info-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .page { padding: 22px 14px 42px; }
  .panel, .hero { padding: 18px; border-radius: 22px; }
  .metrics-grid,
  .three-col { grid-template-columns: 1fr; }
  .actions button,
  #status { width: 100%; }
}
