:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-muted: #eef1f4;
  --text: #1f252b;
  --muted: #5f6872;
  --border: #cfd5dc;
  --accent: #1f5fa9;
  --focus: #2f7bd3;
  --success: #2d7d46;
  --shadow: 0 14px 40px rgba(20, 28, 36, 0.16);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 17px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16191d;
  --surface: #20252a;
  --surface-muted: #292f35;
  --text: #f0f2f4;
  --muted: #b8c0c8;
  --border: #46505a;
  --accent: #7db8ff;
  --focus: #8bc1ff;
  --success: #78c78d;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    color-scheme: dark;
    --bg: #16191d;
    --surface: #20252a;
    --surface-muted: #292f35;
    --text: #f0f2f4;
    --muted: #b8c0c8;
    --border: #46505a;
    --accent: #7db8ff;
    --focus: #8bc1ff;
    --success: #78c78d;
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

button, input, select, textarea { font: inherit; }
button, select { color: inherit; }

a { color: var(--accent); }

.shell {
  width: min(1120px, calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-row {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.appearance-control {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--muted);
  font-size: .94rem;
}

.appearance-control select {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  padding: .38rem .55rem;
}

.main-content { padding-block: 3rem; }

.intro-panel {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  padding: clamp(1.4rem, 3vw, 2.4rem);
}

.eyebrow {
  margin: 0 0 .35rem;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.08; }
h2 { margin: 0; font-size: 1.15rem; }
.lede { color: var(--muted); font-size: 1.08rem; }

.status-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-top: 1.5rem;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-muted);
}

.status-dot {
  width: .65rem;
  height: .65rem;
  border-radius: 50%;
  background: var(--success);
  flex: 0 0 auto;
}

.site-footer {
  padding-block: 2rem;
  color: var(--muted);
  font-size: .9rem;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, .42);
}

.dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  transform: translate(-50%, -50%);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dialog-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
  cursor: move;
  user-select: none;
}

.dialog-body { padding: 1rem; }

.icon-button {
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  padding: .2rem .5rem;
  cursor: pointer;
}

.icon-button:hover { border-color: var(--border); }

.header-actions {
  display: flex;
  align-items: center;
  gap: .9rem;
}

.form-panel {
  width: min(620px, 100%);
  margin-inline: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  padding: clamp(1.4rem, 3vw, 2.2rem);
}

.stack-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.stack-form label {
  display: grid;
  gap: .35rem;
  font-weight: 700;
}

.stack-form input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  padding: .65rem .72rem;
}

.field-help,
.form-footer {
  color: var(--muted);
  font-size: .94rem;
}

.field-help { margin: -.5rem 0 0; }
.form-footer { margin: 1.4rem 0 0; }

.notice {
  margin: 1.2rem 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-muted);
  padding: .8rem 1rem;
}

.notice-error { border-color: #a94442; }

.primary-button,
.secondary-button {
  width: fit-content;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .58rem .85rem;
  cursor: pointer;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

@media (max-width: 700px) {
  .header-row,
  .header-actions {
    align-items: flex-start;
  }
  .header-row {
    padding-block: .8rem;
  }
  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}
