:root {
  --bg: #fafcff;
  --surface: #ffffff;
  --text: #0a0c10;
  --muted: #4b5563;
  --border: #cbd5e1;
  --focus: #1a73e8;
  --error: #b00020;
  --info: #1559b3;
  --button-bg: color-mix(in oklab, var(--surface), black 3%);
  --button-hover-bg: color-mix(in oklab, var(--surface), black 7%);
  --button-border: var(--border);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b0d10;
  --surface: #0f1318;
  --text: #e8eef2;
  --muted: #9aa4b2;
  --border: #334155;
  --focus: #61a0ff;
  --error: #ff5b6e;
  --info: #8ab4ff;
  --button-bg: color-mix(in oklab, var(--surface), white 6%);
  --button-hover-bg: color-mix(in oklab, var(--surface), white 12%);
  --button-border: var(--border);
  color-scheme: dark;
}

html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: system-ui, Arial, sans-serif; }

form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 44rem;
  margin: 2rem auto; 
  padding: 0 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}


fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

legend {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

fieldset > div {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}


label {
  font-weight: 600;
}

label [aria-hidden="true"] {
  color: var(--error); 
  margin-left: 0.25rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="number"],
textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  background: color-mix(in oklab, var(--bg), black 3%);
}

textarea {
  resize: vertical;
}


output {
  display: block;
  font-size: 0.875rem;
  line-height: 1.3;
  margin-top: 0.125rem;
  min-height: 1.1em; 
}


fieldset > div output:first-of-type {
  color: var(--error);
}

fieldset > div output:last-of-type {
  color: var(--info); 
}

form > div {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

button[type="submit"],
button[type="reset"],
button {
  padding: 0.6rem 1rem;
  border: 1px solid var(--button-border);
  background: var(--button-bg);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  background: var(--button-hover-bg);
}

input:focus-visible,
textarea:focus-visible,
button:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

input:invalid,
textarea:invalid,
select:invalid {
  border-color: var(--error);
}

::placeholder {
  color: #6b7280; 
}

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

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.theme-toggle:hover{ background: color-mix(in oklab, var(--info), transparent 88%); }

/* View Transition API */
@supports (view-transition-name: root) {
  html { view-transition-name: root; }
  ::view-transition-old(root) { animation: fade-out .25s ease both; }
  ::view-transition-new(root) { animation: fade-in  .25s ease both; }
  @keyframes fade-out { from { opacity: 1 } to { opacity: 0 } }
  @keyframes fade-in  { from { opacity: 0 } to { opacity: 1 } }
}

header h1 {
  text-align: center;
  margin: 1rem auto 0.5rem;
}