:root {
  color-scheme: light;
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #edf2ef;
  --ink: #17211f;
  --muted: #5e6b68;
  --line: #cad4cf;
  --primary: #24413f;
  --primary-2: #2f6f62;
  --accent: #d8642a;
  --accent-2: #ad7f19;
  --good: #2f7d48;
  --warn: #a06418;
  --bad: #b33b32;
  --info: #1d6f8f;
  --focus: #1f8f73;
  --shadow: 0 14px 36px rgba(23, 33, 31, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(36, 65, 63, 0.08), rgba(36, 65, 63, 0) 260px),
    var(--bg);
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(31, 143, 115, 0.35);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(202, 212, 207, 0.9);
  background: rgba(244, 246, 244, 0.92);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  flex: 0 0 auto;
}

.brand-title {
  font-size: 1rem;
  font-weight: 760;
  line-height: 1.05;
  white-space: nowrap;
}

.brand-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions,
.toolbar,
.button-row,
.compact-row,
.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.main {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 20px 0 34px;
  flex: 1;
}

.screen-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.72fr);
  gap: 16px;
  align-items: start;
}

.panel,
.tile,
.room-nav,
.workbench,
.modal-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.panel-title {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.7rem);
  letter-spacing: 0;
  line-height: 1.12;
}

.panel-kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
  text-transform: uppercase;
}

.copy {
  color: var(--muted);
  line-height: 1.55;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.field label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  padding: 10px 12px;
}

.field textarea {
  min-height: 116px;
  resize: vertical;
  line-height: 1.45;
}

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 760;
  line-height: 1.1;
  text-align: center;
  max-width: 100%;
}

.button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

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

.button.good {
  background: var(--good);
  color: #fff;
}

.button.warn {
  background: #fff5df;
  color: #6f440b;
  border-color: #ebcf9c;
}

.button.bad {
  background: #fff1ef;
  color: #85251f;
  border-color: #efc2bc;
}

.button.ghost {
  background: transparent;
  border-color: var(--line);
}

.button.icon-only {
  width: 42px;
  padding: 0;
}

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

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  min-width: 0;
}

.metric-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  text-transform: uppercase;
}

.metric-value {
  margin-top: 5px;
  font-size: 1.1rem;
  font-weight: 820;
  overflow-wrap: anywhere;
}

.tile-list {
  display: grid;
  gap: 10px;
}

.tile {
  padding: 13px;
}

.tile-title {
  margin: 0 0 5px;
  font-weight: 820;
  font-size: 1rem;
}

.tile-meta,
.small {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 4px 9px;
  background: #fff;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 760;
  white-space: nowrap;
}

.badge.good {
  color: #16502a;
  background: #e8f5ec;
  border-color: #b9dec5;
}

.badge.warn {
  color: #71430a;
  background: #fff1d2;
  border-color: #e7c178;
}

.badge.bad {
  color: #812720;
  background: #ffefed;
  border-color: #ecb7b1;
}

.badge.info {
  color: #124d63;
  background: #e5f5fa;
  border-color: #add8e4;
}

.location-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(47, 111, 98, 0.1), rgba(216, 100, 42, 0.08)),
    #fff;
}

.location-pin {
  width: 76px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(36, 65, 63, 0.96), rgba(47, 111, 98, 0.92)),
    var(--primary);
}

.location-pin svg {
  width: 38px;
  height: 38px;
}

.room-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.room-nav {
  position: sticky;
  top: 82px;
  padding: 10px;
}

.component-button {
  width: 100%;
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 9px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  text-align: left;
  cursor: pointer;
}

.component-button:hover,
.component-button.active {
  background: var(--surface-2);
}

.component-button.active {
  border-color: var(--line);
}

.component-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--line);
}

.component-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 760;
}

.workbench {
  min-width: 0;
  padding: 16px;
}

.component-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.component-head h2 {
  margin: 0;
  font-size: clamp(1.18rem, 2vw, 1.55rem);
  letter-spacing: 0;
}

.story-block,
.instruction-block {
  border-left: 4px solid var(--primary-2);
  padding: 14px;
  background: #f7faf8;
  line-height: 1.62;
  border-radius: 0 8px 8px 0;
}

.answer-form {
  display: grid;
  gap: 10px;
  max-width: 620px;
}

.choice-grid {
  display: grid;
  gap: 9px;
  max-width: 680px;
}

.choice {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  text-align: left;
}

.choice.selected {
  border-color: var(--primary-2);
  background: #edf7f2;
}

.checklist {
  display: grid;
  gap: 8px;
}

.check-item {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-item input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 14px;
  align-items: start;
}

.canvas-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.draw-canvas {
  display: block;
  width: 100%;
  height: min(48vh, 430px);
  min-height: 280px;
  touch-action: none;
  background:
    linear-gradient(var(--surface-2) 1px, transparent 1px),
    linear-gradient(90deg, var(--surface-2) 1px, transparent 1px),
    #fff;
  background-size: 24px 24px;
}

.swatches {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.swatch {
  width: 32px;
  height: 32px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.swatch.active {
  box-shadow: 0 0 0 3px rgba(31, 143, 115, 0.35);
}

.sticky-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.sticky {
  border: 1px solid #e2cd8d;
  border-radius: 8px;
  background: #fff7d7;
  padding: 10px;
}

.sticky textarea {
  width: 100%;
  min-height: 86px;
  border: 0;
  background: transparent;
  resize: vertical;
  padding: 0;
}

.super-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 14px;
  align-items: start;
}

.dashboard-table {
  display: grid;
  gap: 10px;
}

.team-row {
  display: grid;
  grid-template-columns: minmax(145px, 1fr) minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.audit-log {
  display: grid;
  gap: 8px;
  max-height: 430px;
  overflow: auto;
}

.audit-line {
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  line-height: 1.45;
}

.audit-time {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

.toast-root,
#toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 100;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: min(360px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-left: 5px solid var(--primary-2);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 12px;
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 33, 31, 0.42);
}

.modal-panel {
  width: min(560px, 100%);
  padding: 18px;
  box-shadow: var(--shadow);
}

.celebration {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  overflow: hidden;
}

.celebration-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(500px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 22px;
  text-align: center;
}

.celebration-card h2 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 8vw, 4rem);
  letter-spacing: 0;
}

.confetti {
  position: absolute;
  top: -18px;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  animation: confetti-fall 1.9s linear forwards;
}

@keyframes confetti-fall {
  to {
    transform: translateY(calc(100vh + 40px)) rotate(620deg);
  }
}

.hidden {
  display: none !important;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
}

@media (max-width: 900px) {
  .screen-grid,
  .room-layout,
  .workspace-grid,
  .super-grid {
    grid-template-columns: 1fr;
  }

  .room-nav {
    position: static;
    display: flex;
    overflow-x: auto;
    gap: 8px;
  }

  .component-button {
    min-width: 220px;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .team-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar-inner,
  .main {
    width: min(100% - 20px, 1180px);
  }

  .topbar-inner {
    min-height: 58px;
  }

  .brand-subtitle {
    display: none;
  }

  .top-actions {
    justify-content: flex-end;
  }

  .button {
    min-height: 44px;
  }

  .panel,
  .workbench,
  .modal-panel {
    padding: 14px;
  }

  .location-band {
    grid-template-columns: 1fr;
  }

  .location-pin {
    width: 58px;
  }

  .draw-canvas {
    min-height: 260px;
  }
}
