:root {
  color-scheme: light;
  --navy: #173b57;
  --green: #1f7a6a;
  --green-soft: #e9f6f1;
  --coral: #ef6958;
  --ink: #163047;
  --muted: #667b8d;
  --line: #d8e2e8;
  --surface: #ffffff;
  --background: #f3f6f7;
  --shadow: 0 18px 55px rgba(23, 59, 87, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--background);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(31, 122, 106, 0.2); outline-offset: 2px; }
[hidden] { display: none !important; }

.topbar {
  height: 64px;
  padding: 0 clamp(16px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(216, 226, 232, 0.88);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
}
.brand, .topbar-actions { display: flex; align-items: center; }
.brand { gap: 10px; }
.brand-mark {
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  color: white;
  background: var(--navy);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .08em;
  user-select: none;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.topbar-actions { gap: 12px; }
.topbar-note { color: var(--muted); font-size: 11px; }
.log-link {
  min-height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #b9d9cf;
  border-radius: 10px;
  color: var(--green);
  background: #f2faf7;
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}

.page-shell { width: min(1320px, calc(100% - 32px)); margin: 24px auto 56px; }
.page-heading {
  padding: 4px 4px 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}
.eyebrow { color: var(--green); font-size: 10px; font-weight: 850; letter-spacing: .1em; }
h1 { margin: 7px 0 0; color: var(--navy); font-size: clamp(27px, 3.5vw, 40px); letter-spacing: -.035em; }
.page-heading p { max-width: 780px; margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.heading-actions { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.heading-actions strong { color: var(--green); font-size: 12px; }
.text-button, .clear-group { padding: 0; border: 0; color: var(--green); background: transparent; font-size: 11px; font-weight: 750; }
.text-button:disabled, .clear-group:disabled { opacity: .38; cursor: default; }

.configuration-card, .result-panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.configuration-card { padding: 4px clamp(18px, 3vw, 34px) 22px; }
.field-group { padding: 22px 0; border-bottom: 1px solid #e7edef; scroll-margin: 20px; }
.field-group.invalid { margin: 8px -12px; padding: 18px 12px; border: 1px solid #ef9d92; border-radius: 14px; background: #fff8f6; }
.group-header { margin-bottom: 13px; display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.group-title-row { display: flex; align-items: center; gap: 7px; }
.group-title-row h2 { margin: 0; color: var(--navy); font-size: 17px; letter-spacing: -.015em; }
.group-header p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.group-header p span { color: #8da0ac; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; }
.rule-badge, .mode-badge { padding: 3px 7px; border-radius: 99px; font-size: 9px; font-weight: 800; }
.rule-badge.required { color: #b84d40; background: #fff0ed; }
.rule-badge.optional, .mode-badge { color: #657985; background: #edf2f4; }

.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-pill {
  min-height: 34px;
  padding: 6px 13px;
  border: 1px solid #aebdc6;
  border-radius: 999px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}
.choice-pill:hover { border-color: var(--green); color: var(--green); transform: translateY(-1px); }
.choice-pill.selected { border-color: var(--green); color: white; background: var(--green); box-shadow: 0 4px 12px rgba(31, 122, 106, .17); }

.generate-bar { padding-top: 20px; display: flex; align-items: center; justify-content: flex-end; gap: 16px; }
.validation-message { margin: 0 auto 0 0; color: #bd4d40; font-size: 12px; font-weight: 700; }
.primary-button {
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 11px;
  color: white;
  background: var(--coral);
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(239, 105, 88, .2);
}
.primary-button:hover { background: #df5949; }

.result-panel { margin-top: 16px; padding: 22px; }
.result-copy h2 { margin: 5px 0 0; color: var(--navy); font-size: 22px; }
.result-copy p { margin: 5px 0 14px; color: var(--muted); font-size: 11px; }
.output-box { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: stretch; }
.output-box textarea {
  width: 100%;
  min-height: 76px;
  padding: 13px;
  resize: vertical;
  border: 1px solid #b9cbd4;
  border-radius: 11px;
  outline: none;
  color: var(--navy);
  background: #f8fafb;
  font: 11px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.copy-status { min-height: 16px; margin: 7px 0 0; color: var(--green); font-size: 11px; font-weight: 700; }
.restart-button {
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid #c7d3d9;
  border-radius: 11px;
  color: var(--navy);
  background: white;
  font-weight: 800;
}
.restart-button:hover { border-color: var(--green); color: var(--green); background: #f5faf8; }

@media (max-width: 720px) {
  .topbar { height: 58px; padding: 0 12px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 10px; }
  .brand strong { font-size: 13px; }
  .brand small, .topbar-note { display: none; }
  .page-shell { width: calc(100% - 16px); margin-top: 14px; }
  .page-heading { padding: 2px 4px 14px; display: block; }
  .page-heading p { font-size: 12px; }
  .heading-actions { margin-top: 12px; justify-content: space-between; }
  .configuration-card, .result-panel { border-radius: 16px; }
  .configuration-card { padding: 0 14px 16px; }
  .field-group { padding: 18px 0; }
  .group-header { margin-bottom: 11px; }
  .group-title-row { flex-wrap: wrap; }
  .group-title-row h2 { font-size: 15px; }
  .group-header p { line-height: 1.5; }
  .clear-group { flex: 0 0 auto; }
  .pill-list { gap: 7px; }
  .choice-pill { min-height: 32px; padding: 6px 11px; font-size: 11px; }
  .generate-bar { position: sticky; bottom: 0; z-index: 3; margin: 0 -14px -16px; padding: 12px 14px; border-top: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(12px); }
  .validation-message { font-size: 10px; }
  .output-box { grid-template-columns: 1fr; }
  .output-box textarea { grid-column: 1 / -1; }
  .output-box .primary-button, .output-box .restart-button { min-height: 44px; }
  .output-box { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
