:root {
  color-scheme: light;
  --page: #f3f6fb;
  --surface: #ffffff;
  --surface-muted: #f0f5f7;
  --border: #d5dee8;
  --border-strong: #b5c5d8;
  --text: #172033;
  --muted: #5b667a;
  --primary: #0f766e;
  --primary-hover: #0b5f59;
  --primary-soft: #d9f4f1;
  --danger: #b42318;
  --focus: #2563eb;
  --shadow: 0 20px 55px rgba(42, 57, 85, 0.12);
  --shadow-soft: 0 10px 30px rgba(42, 57, 85, 0.1);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.1), transparent 360px),
    linear-gradient(180deg, #eef7f5 0, rgba(238, 247, 245, 0) 340px),
    var(--page);
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

.page-shell {
  width: min(100% - 32px, 980px);
  margin: 0 auto;
  padding: 40px 0;
}

.page-header {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 6vw, 3.25rem);
  line-height: 1.12;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.125rem;
  line-height: 1.35;
}

.intro,
.section-heading p {
  color: var(--muted);
}

.intro {
  max-width: 680px;
  margin-bottom: 0;
}

.tool-panel {
  margin-top: 16px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.result-panel {
  margin-top: 20px;
}

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

.section-heading p {
  margin-bottom: 0;
}

.field-group,
.template-block {
  display: grid;
  gap: 8px;
}

.field-group {
  margin-bottom: 18px;
}

label {
  font-weight: 700;
}

textarea,
input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

textarea,
input {
  padding: 12px 16px;
}

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

textarea::placeholder {
  color: #7b8798;
}

textarea:focus,
input:focus,
button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  outline-offset: 2px;
  border-color: var(--focus);
}

.template-grid {
  display: grid;
  gap: 18px;
  margin-bottom: 24px;
}

.combo-field {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: stretch;
  min-height: 48px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #ffffff;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.combo-field:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.combo-field input {
  min-height: 46px;
  border: 0;
  border-radius: 10px 0 0 10px;
  box-shadow: none;
}

.combo-field input:focus {
  outline: 0;
}

.combo-button {
  min-width: 64px;
  min-height: 46px;
  border: 0;
  border-left: 1px solid var(--border);
  background: #f8fbfc;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    color 160ms ease;
}

.combo-button:hover {
  background: var(--primary-soft);
  color: #0a504b;
}

.combo-button[aria-expanded="true"] {
  background: var(--primary-soft);
  color: #0a504b;
}

.clear-button {
  border-radius: 0 10px 10px 0;
  color: var(--muted);
}

.preset-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: -1px;
  right: -1px;
  width: auto;
  max-height: 240px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.preset-option {
  display: block;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.preset-option:hover,
.preset-option:focus-visible {
  background: var(--surface-muted);
}

.preset-option[aria-selected="true"] {
  background: var(--primary-soft);
  color: #0a504b;
  font-weight: 700;
}

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

.button {
  min-height: 48px;
  min-width: 120px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 20px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button.primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.2);
}

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

.button.secondary {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: #0a504b;
}

.button.secondary:hover {
  border-color: var(--primary-hover);
  background: #c4ece8;
}

.button.ghost {
  border-color: var(--border);
  background: var(--surface-muted);
  color: var(--text);
}

.button.ghost:hover {
  border-color: var(--border-strong);
  background: #e4ecf5;
}

.status {
  min-height: 24px;
  margin: 16px 0 0;
  color: var(--muted);
  font-weight: 600;
}

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

.status.success {
  color: var(--primary-hover);
}

#resultOutput {
  background: #f9fbfd;
}

@media (min-width: 760px) {
  .page-shell {
    padding: 56px 0;
  }

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

@media (max-width: 520px) {
  .page-shell {
    width: min(100% - 24px, 980px);
    padding: 28px 0;
  }

  .tool-panel {
    padding: 18px;
  }

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

  .combo-field input,
  .combo-button,
  .clear-button {
    border-radius: 0;
  }

  .combo-field input {
    border-radius: 10px 10px 0 0;
  }

  .combo-button {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .clear-button {
    border-radius: 0 0 10px 10px;
  }

  .preset-menu {
    width: auto;
  }

  .actions {
    display: grid;
  }

  .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
