:root {
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --border: rgba(255, 255, 255, 0.55);
  --chrome-bg: rgba(255, 255, 255, 0.45);
  --chrome-backdrop: saturate(180%) blur(24px);
  --field-bg: rgba(255, 255, 255, 0.62);
  --field-out-bg: rgba(255, 255, 255, 0.75);
  --field-focus-bg: rgba(255, 255, 255, 0.75);
  --field-focus-border: rgba(0, 113, 227, 0.55);
  --field-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 12px 32px rgba(31, 45, 80, 0.1);
  --field-backdrop: saturate(160%) blur(22px);
  --accent: #0071e3;
  --focus-ring: rgba(0, 113, 227, 0.18);
  --focus-ring-strong: rgba(0, 113, 227, 0.3);
  --btn-bg: rgba(255, 255, 255, 0.55);
  --btn-hover-bg: rgba(255, 255, 255, 0.78);
  --btn-border-color: rgba(255, 255, 255, 0.55);
  --btn-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 6px 18px rgba(31, 45, 80, 0.08);
  --primary-bg: linear-gradient(180deg, #2b8ceb, #0071e3);
  --primary-hover-bg: linear-gradient(180deg, #3d97f0, #0077ed);
  --primary-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 8px 22px rgba(0, 113, 227, 0.35);
  --glow: #ff9500;
  --font-size: 1.0625rem;
  --line-height: 1.5;
  --space: 1.25rem;
  --radius: 22px;
}

body.theme-dark {
  --text: #f5f5f7;
  --text-secondary: #86868b;
  --border: rgba(255, 255, 255, 0.1);
  --chrome-bg: rgba(22, 22, 23, 0.8);
  --field-bg: #1d1d1f;
  --field-out-bg: #161617;
  --field-focus-bg: #1d1d1f;
  --field-focus-border: #0a84ff;
  --field-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
  --field-backdrop: none;
  --accent: #0a84ff;
  --focus-ring: rgba(10, 132, 255, 0.28);
  --focus-ring-strong: rgba(10, 132, 255, 0.4);
  --btn-bg: rgba(255, 255, 255, 0.12);
  --btn-hover-bg: rgba(255, 255, 255, 0.18);
  --btn-border-color: transparent;
  --btn-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
  --primary-bg: #0a84ff;
  --primary-hover-bg: #2997ff;
  --primary-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
  --radius: 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--text);
  background: #eef1f6;
  background-image: radial-gradient(
      42rem 42rem at 12% -8%,
      rgba(120, 170, 255, 0.35),
      transparent 60%
    ),
    radial-gradient(
      38rem 38rem at 105% 12%,
      rgba(190, 140, 255, 0.28),
      transparent 62%
    ),
    radial-gradient(
      46rem 40rem at 50% 115%,
      rgba(110, 220, 200, 0.25),
      transparent 60%
    );
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body.theme-dark {
  color-scheme: dark;
  background: #000000;
  background-image: none;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 3rem;
  background: var(--chrome-bg);
  backdrop-filter: var(--chrome-backdrop);
  -webkit-backdrop-filter: var(--chrome-backdrop);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space);
  width: 100%;
  max-width: 75rem;
  margin: 0 auto;
  padding: var(--space);
  align-content: start;
}

.field {
  width: 100%;
  min-height: 12rem;
  padding: 1.125rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field-bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
  backdrop-filter: var(--field-backdrop);
  -webkit-backdrop-filter: var(--field-backdrop);
  box-shadow: var(--field-shadow);
  transition: box-shadow 0.2s ease, border-color 0.2s ease,
    background 0.2s ease;
}

.field::placeholder {
  color: var(--text-secondary);
}

.field-input {
  order: 1;
}

.actions-input {
  order: 2;
}

.field-output {
  order: 3;
  background: var(--field-out-bg);
}

.actions-output {
  order: 4;
}

.field:focus,
.field:focus-visible {
  outline: none;
  border-color: var(--field-focus-border);
  background: var(--field-focus-bg);
  box-shadow: 0 0 0 4px var(--focus-ring), var(--field-shadow);
}

.field-output:read-only {
  cursor: default;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.action {
  min-height: 2.75rem;
  padding: 0.625rem 1.375rem;
  border: 1px solid var(--btn-border-color);
  border-radius: 980px;
  background: var(--btn-bg);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: var(--field-backdrop);
  -webkit-backdrop-filter: var(--field-backdrop);
  box-shadow: var(--btn-shadow);
  transition: background 0.2s ease, transform 0.1s ease, opacity 0.2s ease;
}

.action:active:not(:disabled) {
  transform: scale(0.97);
}

.action:hover:not(:disabled) {
  background: var(--btn-hover-bg);
}

#simplify-button {
  background: var(--primary-bg);
  border-color: transparent;
  color: #ffffff;
  box-shadow: var(--primary-shadow);
}

#simplify-button:hover:not(:disabled) {
  background: var(--primary-hover-bg);
}

.action:focus,
.action:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus-ring-strong);
}

.action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--chrome-bg);
  backdrop-filter: var(--chrome-backdrop);
  -webkit-backdrop-filter: var(--chrome-backdrop);
}

.site-footer p {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0.75rem;
  max-width: 75rem;
  margin: 0 auto;
  padding: 1rem var(--space);
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
}

.footer-brand {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  cursor: pointer;
  color: var(--glow);
  text-shadow: 0 0 6px rgba(255, 149, 0, 0.75),
    0 0 14px rgba(255, 149, 0, 0.45);
  transition: text-shadow 0.2s ease;
}

.footer-brand:hover {
  text-shadow: 0 0 8px rgba(255, 149, 0, 0.95),
    0 0 20px rgba(255, 149, 0, 0.65);
}

.footer-brand:focus-visible {
  outline: none;
  border-radius: 4px;
  box-shadow: 0 0 0 3px var(--focus-ring-strong);
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.footer-link:focus-visible {
  outline: none;
  border-radius: 4px;
  box-shadow: 0 0 0 3px var(--focus-ring-strong);
}

@media (min-width: 48rem) {
  .app {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr auto;
    align-content: stretch;
  }

  .field {
    min-height: calc(100vh - 12rem);
  }

  .field-input,
  .field-output,
  .actions-input,
  .actions-output {
    order: initial;
  }

  .field-input {
    grid-column: 1;
    grid-row: 1;
  }

  .field-output {
    grid-column: 2;
    grid-row: 1;
  }

  .actions-input {
    grid-column: 1;
    grid-row: 2;
  }

  .actions-output {
    grid-column: 2;
    grid-row: 2;
  }
}
