:root {
  color-scheme: light dark;
  --ink: #171522;
  --paper: #fffaf0;
  --surface: #ffffff;
  --accent: #6b38d1;
  --accent-strong: #482099;
  --muted: #645f72;
  --line: #d8cfe8;
  --success: #176b45;
  --danger: #a32638;
  --focus: #006bd6;

  font-family: "Noto Sans", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(135deg, #f5edff 0%, var(--paper) 55%, #e8f8f0 100%);
}

button, input, textarea, select { font: inherit; }
button, input, textarea, select { min-height: 2.75rem; }

.skip-link {
  position: fixed;
  z-index: 20;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.75rem 1rem;
  color: white;
  background: var(--accent-strong);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

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

.site-header, main, footer, .status-region {
  width: min(72rem, calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 2rem 1rem;
}

h1, h2, h3 { line-height: 1.15; }
h1 { margin: 0; font-size: clamp(2rem, 6vw, 4rem); }
.eyebrow { margin: 0 0 0.25rem; color: var(--accent-strong); font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
nav { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.step-tab, .button {
  border: 2px solid var(--accent);
  border-radius: 999px;
  padding: 0.65rem 1.1rem;
  color: var(--accent-strong);
  background: var(--surface);
  font-weight: 750;
  cursor: pointer;
}
.step-tab[aria-current="page"], .button.primary {
  color: white;
  background: var(--accent-strong);
}
button:disabled { cursor: not-allowed; opacity: 0.55; }

main {
  min-height: 32rem;
  padding-block: 1rem;
}
.view-heading { max-width: 46rem; margin-bottom: 1.5rem; }
.view-heading p { color: var(--muted); font-size: 1.05rem; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); gap: 1rem; }
.card {
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: clamp(1rem, 3vw, 1.75rem);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 0.75rem 2rem rgb(50 30 80 / 10%);
}
.card h3 { margin-top: 0; }

.field { display: grid; gap: 0.4rem; margin-block: 1rem; }
.field label, legend { font-weight: 750; }
.field-help { margin: 0; color: var(--muted); font-size: 0.9rem; }
input, textarea, select {
  width: 100%;
  border: 1px solid #81758e;
  border-radius: 0.5rem;
  padding: 0.7rem;
  color: var(--ink);
  background: var(--surface);
}
textarea { min-height: 9rem; resize: vertical; }
fieldset { border: 0; margin: 1rem 0; padding: 0; }
.choice-row { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.5rem; }
.choice-row label { display: inline-flex; align-items: center; gap: 0.5rem; }
.choice-row input { width: auto; min-height: auto; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.compact-fields { display: grid; gap: 0.75rem; }

.project-summary { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; padding: 0; list-style: none; color: var(--muted); }
.project-summary strong { color: var(--ink); }
.diff-list { display: grid; gap: 1rem; }
.diff-item { border-left: 0.3rem solid var(--accent); padding-left: 1rem; }
.diff-item p { white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-label { color: var(--muted); font-weight: 750; }
.notice { border-radius: 0.5rem; padding: 0.8rem 1rem; background: #eee7ff; color: #2c174f; }
.status-region { min-height: 3rem; padding: 0.75rem 1rem; font-weight: 700; }
.status-region[data-tone="error"] { color: var(--danger); }
.status-region[data-tone="success"] { color: var(--success); }
footer { border-top: 1px solid var(--line); padding-block: 1rem 2rem; color: var(--muted); }

@media (max-width: 42rem) {
  .site-header { align-items: start; flex-direction: column; }
  nav, .step-tab { width: 100%; }
}

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

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f6f1ff;
    --paper: #17131f;
    --surface: #241d2e;
    --accent: #c2a5ff;
    --accent-strong: #b28cff;
    --muted: #c7bfd1;
    --line: #544762;
    --success: #57d49a;
    --danger: #ff9eaa;
    --focus: #62b4ff;
  }
  body { background: linear-gradient(135deg, #21162e, var(--paper) 60%, #12261f); }
  .step-tab[aria-current="page"], .button.primary { color: #16101f; }
  .notice { color: #f6f1ff; background: #392858; }
}


.job-card { display: grid; align-content: start; }
.job-state { font-weight: 800; text-transform: capitalize; }
.state-accepted { color: var(--success); }
.state-failed, .state-cancelled { color: var(--danger); }
.state-validating, .staged-raster { border-color: var(--accent); }
.accepted-raster { border: 2px solid var(--success); }
.warning { border-left: 0.3rem solid #9b6500; }
.raster-preview {
  display: block;
  width: 100%;
  max-height: 38rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  object-fit: contain;
  background: var(--surface);
}
dialog {
  width: min(34rem, calc(100% - 2rem));
  border: 2px solid var(--accent);
  border-radius: 1rem;
  padding: 1.5rem;
  color: var(--ink);
  background: var(--surface);
}
dialog::backdrop { background: rgb(20 12 32 / 70%); }
.revision-label { font-weight: 750; }

#studio-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 1rem;
}

#activity-drawer {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 0.75rem 2rem rgb(50 30 80 / 10%);
  padding: 1rem;
  min-width: 320px;
  max-width: 720px;
  resize: horizontal;
  overflow: auto;
}

#activity-drawer[data-collapsed="true"] {
  width: auto !important;
  min-width: 0;
  max-width: none;
  resize: none;
  overflow: hidden;
  padding: 0.5rem 0.75rem;
}

#activity-drawer[data-collapsed="true"] .activity-header { margin-bottom: 0; }

.activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.activity-toggle {
  border: 0;
  background: transparent;
  font-weight: 750;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  color: var(--accent-strong);
}

.activity-resize {
  flex: 1;
  min-width: 8rem;
  cursor: ew-resize;
}

.activity-list {
  display: grid;
  gap: 0.5rem;
  max-height: 60vh;
  overflow-y: auto;
}

.activity-card {
  border-left: 0.3rem solid var(--accent);
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border-radius: 0.5rem;
  display: grid;
  gap: 0.25rem;
}

.activity-field {
  display: flex;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.activity-label {
  color: var(--muted);
  font-weight: 750;
  min-width: 4.5rem;
  text-transform: lowercase;
}

.activity-value { word-break: break-word; }

@media (max-width: 63.99rem) {
  body { overflow-y: auto; }
  #studio-shell {
    grid-template-columns: minmax(0, 1fr);
    width: min(72rem, calc(100% - 2rem));
    margin-inline: auto;
  }
  #studio-shell > main { width: 100%; }
  #activity-drawer {
    width: 100% !important;
    min-width: 0;
    max-width: none;
    resize: none;
  }
  .compact-fields { grid-template-columns: minmax(0, 1fr); }
}

@media (min-width: 64rem) and (min-height: 42rem) {
  html,
  body { height: 100%; }

  body {
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
  }

  .site-header {
    align-items: center;
    padding-block: 0.65rem 0.45rem;
  }
  h1 { font-size: clamp(2rem, 4vw, 3rem); }
  .eyebrow { font-size: 0.8rem; }
  .step-tab {
    min-height: 2.35rem;
    padding: 0.5rem 0.9rem;
  }

  #studio-shell {
    min-height: 0;
    height: 100%;
    width: min(92rem, calc(100% - 2rem));
    margin-inline: auto;
    align-items: stretch;
  }

  #studio-shell > main {
    width: 100%;
    margin: 0;
  }

  main {
    min-height: 0;
    height: 100%;
    overflow: auto;
    padding-block: 0.4rem;
  }

  .start-view {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }

  .start-view .view-heading { margin-bottom: 0.55rem; }
  .start-view .view-heading h2 { margin-block: 0.15rem; }
  .start-view .view-heading p {
    margin: 0.2rem 0;
    font-size: 0.95rem;
  }

  .start-view .card-grid {
    min-height: 0;
    height: 100%;
    grid-template-columns: minmax(0, 1.15fr) minmax(20rem, 0.85fr);
    align-items: stretch;
  }

  .start-view .card {
    min-height: 0;
    padding: 0.75rem 1rem;
    overflow: auto;
  }
  .start-view .card h3 { margin-bottom: 0.45rem; }

  .start-create-card {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .start-create-form {
    display: grid;
    align-content: start;
    gap: 0.25rem;
    min-height: 0;
  }

  .start-create-form .field,
  .start-create-form fieldset { margin-block: 0.2rem; }
  .start-create-form .field-help { font-size: 0.78rem; }
  .start-create-form textarea {
    min-height: 5rem;
    height: 5.5rem;
    resize: none;
  }
  .start-create-form .choice-row { margin-top: 0.2rem; }
  .start-create-form .actions { margin-top: 0.25rem; }

  .compact-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }
  .compact-fields .field { margin-block: 0.1rem; }

  .status-region {
    min-height: 2rem;
    padding-block: 0.35rem;
  }
  footer {
    padding-block: 0.35rem 0.6rem;
    font-size: 0.85rem;
  }
  footer p { margin: 0.2rem 0; }

  #activity-drawer { align-self: start; }
}
