:root {
  color-scheme: light dark;
  --bg: light-dark(#f7f7f5, #171717);
  --paper: light-dark(#ffffff, #222221);
  --soft: light-dark(#f0f0ed, #2c2c2a);
  --text: light-dark(#191918, #f4f4f1);
  --muted: light-dark(#6f6f69, #b8b8b1);
  --line: light-dark(#d8d8d2, #494946);
  --focus: #2563eb;
  --danger: light-dark(#9f2d2d, #ffaaa2);
  --danger-soft: light-dark(#fff1ef, #3a2321);
  --success: light-dark(#18794e, #6ee7b7);
  --shadow: 0 24px 70px light-dark(rgba(24, 24, 22, 0.09), rgba(0, 0, 0, 0.32));
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, light-dark(rgba(255,255,255,.9), rgba(255,255,255,.025)), transparent 38rem),
    var(--bg);
  font-size: 1rem;
  line-height: 1.5;
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: .75rem;
  left: .75rem;
  padding: .65rem .85rem;
  transform: translateY(-150%);
  border: 2px solid var(--focus);
  border-radius: .5rem;
  background: var(--paper);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  min-height: 4rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem clamp(1rem, 4vw, 3.5rem);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -.02em;
}

.brand-mark,
.empty-workspace svg {
  width: 1.75rem;
  height: 1.75rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.security-label {
  color: var(--muted);
  font-size: .875rem;
}

main {
  min-height: calc(100vh - 4rem);
}

.state-view {
  min-height: calc(100vh - 4rem);
}

.loading-view,
.error-view {
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 2rem;
  text-align: center;
}

.loading-view h1,
.error-view h1 {
  margin: 1.25rem 0 .35rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 580;
  letter-spacing: -.035em;
}

.loading-view p,
.error-view p {
  max-width: 34rem;
  margin: 0;
  color: var(--muted);
}

.loading-mark {
  width: 2.25rem;
  height: 2.25rem;
  border: 2px solid var(--line);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

.signed-out-view {
  display: grid;
  grid-template-columns: minmax(0, .82fr) minmax(26rem, 1.18fr);
  gap: clamp(2rem, 7vw, 7rem);
  align-items: center;
  max-width: 90rem;
  margin: 0 auto;
  padding: clamp(2.5rem, 7vw, 7rem) clamp(1.25rem, 6vw, 6rem);
}

.auth-copy {
  max-width: 38rem;
}

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

.auth-copy h1,
.workspace-heading h1 {
  margin: 0;
  font-size: clamp(2.5rem, 6vw, 5.2rem);
  font-weight: 520;
  line-height: .98;
  letter-spacing: -.065em;
}

.lead {
  max-width: 34rem;
  margin: 1.4rem 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.3rem);
}

.auth-actions,
.session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 2rem;
}

.button {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  padding: .7rem 1rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  background: var(--paper);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  font-weight: 620;
  transition: transform .15s ease, background-color .15s ease, border-color .15s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:focus-visible,
.brand:focus-visible,
.skip-link:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 72%, transparent);
  outline-offset: 3px;
}

.button-primary {
  border-color: var(--text);
  background: var(--text);
  color: var(--paper);
}

.button-secondary:hover:not(:disabled) {
  background: var(--soft);
}

.button-danger {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  color: var(--danger);
}

.button-danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.button:disabled,
.button[aria-disabled="true"] {
  opacity: .55;
  cursor: wait;
  transform: none;
}

.auth-note {
  max-width: 34rem;
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: .875rem;
}

.structure-preview {
  min-height: 31rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.preview-header {
  display: flex;
  gap: .45rem;
  height: 3.25rem;
  align-items: center;
  padding: 0 1rem;
  border-bottom: 1px solid var(--line);
}

.preview-header span {
  width: .6rem;
  height: .6rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--soft);
}

.preview-canvas {
  position: relative;
  min-height: 27.75rem;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 1.5rem 1.5rem;
}

.preview-canvas svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.2;
}

.node {
  position: absolute;
  z-index: 1;
  height: 4.5rem;
  border: 1px solid var(--text);
  border-radius: .6rem;
  background: var(--paper);
}

.node::before,
.node::after {
  position: absolute;
  left: .8rem;
  content: "";
  height: .38rem;
  border-radius: 999px;
  background: var(--line);
}

.node::before {
  top: 1rem;
  width: 54%;
  background: var(--text);
}

.node::after {
  top: 1.85rem;
  width: 72%;
}

.node-root {
  top: 2.4rem;
  left: 37%;
  width: 26%;
}

.node-a,
.node-b,
.node-c {
  top: 12.8rem;
  width: 24%;
}

.node-a { left: 8%; }
.node-b { left: 38%; background: light-dark(#e8f0fe, #243044); }
.node-c { right: 8%; }

.message {
  position: relative;
  z-index: 3;
  display: grid;
  gap: .1rem;
  max-width: 48rem;
  margin: 1rem auto -1rem;
  padding: .85rem 1rem;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  border-radius: .6rem;
  background: var(--danger-soft);
}

.message span {
  color: var(--muted);
  font-size: .9rem;
}

.workspace-view {
  max-width: 90rem;
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 4.5rem) clamp(1.25rem, 5vw, 5rem);
}

.onboarding {
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(22rem, 1.15fr);
  gap: clamp(2rem, 6vw, 6rem);
  margin-top: clamp(3rem, 7vw, 6rem);
  padding-top: clamp(2rem, 5vw, 4rem);
  border-top: 1px solid var(--line);
}

.onboarding h2,
.project-view h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.8rem);
  font-weight: 540;
  line-height: 1.05;
  letter-spacing: -.05em;
}

.onboarding-steps {
  display: grid;
  gap: 1rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: onboarding;
}

.onboarding-steps li {
  display: grid;
  grid-template-columns: 2rem 1fr;
  column-gap: .75rem;
  counter-increment: onboarding;
}

.onboarding-steps li::before {
  content: counter(onboarding);
  display: grid;
  width: 1.65rem;
  height: 1.65rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: .8rem;
  font-weight: 700;
}

.onboarding-steps span {
  grid-column: 2;
  color: var(--muted);
}

.onboarding-form {
  display: grid;
  gap: 1.4rem;
  padding: clamp(1.25rem, 4vw, 2rem);
  border: 1px solid var(--line);
  border-radius: .9rem;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

.field {
  display: grid;
  gap: .4rem;
}

.field label,
.start-options legend {
  font-weight: 650;
}

.optional,
.field-help {
  color: var(--muted);
  font-size: .85rem;
  font-weight: 400;
}

input[type="text"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: .75rem .8rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

textarea { resize: vertical; }

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.start-card:has(input:focus-visible) {
  outline: 3px solid color-mix(in srgb, var(--focus) 72%, transparent);
  outline-offset: 2px;
}

.field-error,
.form-error { color: var(--danger); }

.start-options {
  display: grid;
  gap: .7rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.start-card {
  display: flex;
  gap: .75rem;
  align-items: start;
  padding: .8rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  cursor: pointer;
}

.start-card:has(input:checked) {
  border-color: var(--text);
  background: var(--soft);
}

.start-card input { margin-top: .25rem; }
.start-card span,
.start-card small { display: block; }
.start-card small { margin-top: .15rem; color: var(--muted); }

.project-overview {
  margin-top: clamp(2rem, 5vw, 4rem);
  padding-top: clamp(2rem, 4vw, 3rem);
  border-top: 1px solid var(--line);
}

.overview-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.overview-header h2 { margin: 0; font-size: clamp(1.8rem, 4vw, 3rem); letter-spacing: -.045em; }
.project-filters { display: grid; grid-template-columns: minmax(14rem, 1fr) minmax(12rem, .45fr) auto; gap: 1rem; align-items: end; margin: 2rem 0; }
.archive-filter { display: flex; min-height: 2.9rem; align-items: center; gap: .55rem; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 1rem; margin: 0; padding: 0; list-style: none; }
.project-card { display: grid; grid-template-columns: auto 1fr; gap: 1rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--paper); }
.project-card h3 { margin: 0; font-size: 1.1rem; }
.project-card p { margin: .25rem 0 0; color: var(--muted); font-size: .875rem; }
.project-card .button { grid-column: 1 / -1; }
.project-icon { display: grid; width: 2.7rem; height: 2.7rem; place-items: center; border-radius: .65rem; background: var(--soft); font-size: 1.5rem; }
.list-state { display: grid; min-height: 11rem; place-content: center; justify-items: center; gap: .5rem; text-align: center; }
.list-state p { margin: 0; color: var(--muted); }
.list-error { color: var(--danger); }

.project-view {
  max-width: 72rem;
  margin: 0 auto;
  padding: clamp(2rem, 7vw, 6rem) clamp(1.25rem, 5vw, 5rem);
}

.back-link { display: inline-block; margin-bottom: 3rem; color: var(--muted); }
.project-description { max-width: 44rem; color: var(--muted); font-size: 1.1rem; }

.first-block-guide {
  display: flex;
  gap: 1rem;
  max-width: 44rem;
  margin-top: 3rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: .8rem;
  background: var(--paper);
}

.first-block-guide h2,
.first-block-guide p { margin: 0; }
.first-block-guide p { margin-top: .25rem; color: var(--muted); }
.guide-number { display: grid; min-width: 2rem; height: 2rem; place-items: center; border-radius: 50%; background: var(--text); color: var(--paper); font-weight: 700; }

@media (max-width: 760px) {
  .onboarding { grid-template-columns: 1fr; }
}

.workspace-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(20rem, 27rem);
  gap: clamp(2rem, 7vw, 6rem);
  align-items: start;
}

.workspace-heading h1 {
  font-size: clamp(2.75rem, 6vw, 5.5rem);
}

#welcome-message {
  margin-top: 1.2rem;
  color: var(--muted);
  font-size: 1.1rem;
}

.account-card {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: .8rem;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.account-identity {
  display: flex;
  gap: .85rem;
  align-items: center;
}

.account-identity h2 {
  margin: 0 0 .2rem;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.account-identity strong,
.account-identity span {
  display: block;
  overflow-wrap: anywhere;
}

.account-identity span {
  color: var(--muted);
  font-size: .9rem;
}

.avatar {
  display: grid !important;
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border-radius: .65rem;
  background: var(--text);
  color: var(--paper) !important;
  font-weight: 700;
}

.session-details {
  display: grid;
  gap: .55rem;
  margin: 1.15rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.session-details div {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: .75rem;
}

.session-details dt {
  color: var(--muted);
  font-size: .875rem;
}

.session-details dd {
  margin: 0;
  font-size: .875rem;
  text-align: right;
}

.status-dot {
  display: inline-block;
  width: .5rem;
  height: .5rem;
  margin-right: .3rem;
  border-radius: 50%;
  background: var(--success);
}

.session-actions {
  display: grid;
  grid-template-columns: 1fr;
  margin-top: 1.15rem;
}

.empty-workspace {
  display: grid;
  justify-items: center;
  max-width: 42rem;
  margin: clamp(3rem, 8vw, 8rem) auto 0;
  padding: 2.5rem 1.5rem;
  border: 1px dashed var(--line);
  border-radius: .8rem;
  text-align: center;
}

.empty-workspace svg {
  width: 2.25rem;
  height: 2.25rem;
}

.empty-workspace h2 {
  margin: 1rem 0 .3rem;
  font-size: 1.25rem;
  font-weight: 580;
}

.empty-workspace p {
  max-width: 30rem;
  margin: 0;
  color: var(--muted);
}

.error-symbol {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  border: 1px solid var(--danger);
  border-radius: 50%;
  color: var(--danger);
  font-weight: 750;
}

.error-view .button {
  margin-top: 1.5rem;
}

.noscript {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  padding: 1rem;
  border: 1px solid var(--danger);
  background: var(--paper);
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 860px) {
  .signed-out-view {
    grid-template-columns: 1fr;
    padding-top: 3rem;
  }

  .structure-preview {
    min-height: 24rem;
  }

  .preview-canvas {
    min-height: 20.75rem;
  }

  .workspace-heading {
    grid-template-columns: 1fr;
  }

  .account-card {
    max-width: 34rem;
  }

  .project-filters {
    grid-template-columns: 1fr 1fr;
  }

  .archive-filter {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .security-label {
    display: none;
  }

  .signed-out-view {
    padding-inline: 1rem;
  }

  .auth-copy h1 {
    font-size: clamp(2.4rem, 14vw, 3.7rem);
  }

  .auth-actions {
    display: grid;
  }

  .structure-preview {
    min-height: 20rem;
  }

  .preview-canvas {
    min-height: 16.75rem;
  }

  .node {
    height: 3.6rem;
  }

  .node-root {
    top: 1.8rem;
    left: 32%;
    width: 36%;
  }

  .node-a,
  .node-b,
  .node-c {
    top: 9.8rem;
    width: 28%;
  }

  .node-a { left: 3%; }
  .node-b { left: 36%; }
  .node-c { right: 3%; }

  .message {
    margin: .75rem .75rem -.5rem;
  }

  .session-details div {
    grid-template-columns: 1fr;
    gap: .1rem;
  }

  .session-details dd {
    text-align: left;
  }

  .overview-header,
  .project-filters {
    display: grid;
    grid-template-columns: 1fr;
  }

  .archive-filter {
    grid-column: auto;
  }
}

@media (pointer: coarse) {
  .button {
    min-height: 3rem;
  }
}

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