.archive-layout[data-theory-expanded] { grid-template-columns: minmax(0, 1fr); }
.archive-layout[data-theory-expanded] > :is(.library, .inspector) { display: none; }
.archive-layout[data-theory-expanded] .theory-canvas { block-size: clamp(345px, 64svh, 750px); }

.theory-shell {
  --theory-bg: #f7efdf;
  --theory-surface: #faf2e4;
  --theory-ink: #10111b;
  --theory-muted: #51505b;
  --theory-border: #aaa297;
  --theory-accent: #2335a2;
  --theory-project: #8c9cff;
  --theory-note: #c5aaff;
  --theory-work-log: #bbce9d;
  --theory-theory: #ffac83;
  --theory-glow: #d9dafa;
  --theory-glow-end: #ebe0d6;
  --theory-edge: #767c9d;
  --theory-grid: #9396a6;
  container: theory / inline-size;
  min-inline-size: 0;
  color-scheme: light;
  background: var(--theory-bg);
  color: var(--theory-ink);
}
.theory-shell[data-theme="paper"] {
  --theory-bg: #f0e7d7;
  --theory-surface: #fcf6e9;
  --theory-ink: #202238;
  --theory-muted: #3f445f;
  --theory-border: #afa68f;
  --theory-accent: #263db2;
  --theory-project: #2948bf;
  --theory-note: #655781;
  --theory-work-log: #47634f;
  --theory-theory: #a0442e;
  --theory-glow: #c2cbff;
  --theory-glow-end: #f3c9ac;
  --theory-edge: #636e99;
  --theory-grid: #656886;
  color-scheme: light;
}
.theory-shell[data-theme="afterhours"] {
  color-scheme: dark;
  --theory-bg: #181320;
  --theory-surface: #221b30;
  --theory-ink: #fff0e3;
  --theory-muted: #d2bfda;
  --theory-border: #5a4466;
  --theory-accent: #ffb9d0;
  --theory-project: #8a9dff;
  --theory-note: #e1b4ff;
  --theory-work-log: #83dfcf;
  --theory-theory: #ffa0a6;
  --theory-glow: #563075;
  --theory-glow-end: #783e47;
  --theory-edge: #a888aa;
  --theory-grid: #c499c7;
}
.theory-shell[data-theme="moss"] {
  color-scheme: dark;
  --theory-bg: #1b241a;
  --theory-surface: #252e22;
  --theory-ink: #f4efdc;
  --theory-muted: #c9cfb8;
  --theory-border: #4e5945;
  --theory-accent: #d7e9a9;
  --theory-project: #d9e694;
  --theory-note: #e5d7b8;
  --theory-work-log: #8cc8a4;
  --theory-theory: #ffbe91;
  --theory-glow: #3f6040;
  --theory-glow-end: #51442f;
  --theory-edge: #8d9f7e;
  --theory-grid: #b7c5a7;
}
.theory-shell :focus-visible { outline-color: var(--theory-accent); }
.theory-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .45rem .8rem;
  padding: .66rem clamp(.7rem, 2cqw, .95rem);
  background: var(--theory-surface);
  border-bottom: 1px solid var(--theory-border);
}
.theory-title { min-inline-size: 0; }
.theory-title h2 {
  line-height: 1.16;
  font-size: clamp(1rem, 2.9cqw, 1.21rem);
  letter-spacing: -.02em;
}
.theory-title :is(.meta, p) {
  margin-top: .17rem;
  color: var(--theory-muted);
  font: .66rem/1.3 var(--mono);
}
.theory-tools, .theory-inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem;
}
.theory-tools { margin-inline-start: auto; }
.theory-shell :is(.theory-tool, .theory-inline-actions a) {
  display: inline-flex;
  gap: .3rem;
  min-block-size: 2.25rem;
  min-inline-size: 2.25rem;
  padding: .33rem .58rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--theory-border);
  border-radius: .27rem;
  background: var(--theory-surface);
  color: var(--theory-ink);
  font-size: .75rem;
  font-weight: 680;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}
.theory-icon { flex: none; width: 1rem; height: 1rem; }
.theory-shell :is(.theory-tool, .theory-inline-actions a):hover {
  border-color: var(--theory-accent);
  background: color-mix(in srgb, var(--theory-accent) 10%, var(--theory-surface));
}
.theory-shell .theory-tool[aria-pressed="true"],
.theory-shell [data-theory-action="studio"] {
  border-color: var(--theory-accent);
  background: var(--theory-accent);
  color: var(--theory-bg);
}
.theory-shell [data-theory-action="studio"]:hover {
  background: var(--theory-ink);
  color: var(--theory-bg);
}
.theory-tools :is(output, .theory-zoom) {
  min-inline-size: 4ch;
  color: var(--theory-muted);
  font: .64rem/1.2 var(--mono);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.theory-stage { position: relative; min-inline-size: 0; }
.theory-canvas {
  position: relative;
  z-index: 0;
  block-size: clamp(345px, 70cqw, 460px);
  overflow: hidden;
  touch-action: pan-y;
  cursor: grab;
  background:
    radial-gradient(circle, color-mix(in srgb, var(--theory-grid) 36%, transparent) .68px, transparent 1.12px) center / 17px 17px,
    radial-gradient(ellipse at 25% 26%, color-mix(in srgb, var(--theory-glow) 66%, transparent), transparent 66%),
    radial-gradient(ellipse at 84% 84%, color-mix(in srgb, var(--theory-glow-end) 53%, transparent), transparent 62%),
    var(--theory-bg);
}
.theory-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid color-mix(in srgb, var(--theory-border) 58%, transparent);
  pointer-events: none;
}
.theory-canvas[data-gesturing], .theory-canvas[data-gesturing] .theory-node { cursor: grabbing; user-select: none; }
.theory-viewport, .theory-edges { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; }
.theory-viewport { touch-action: pan-y; }
.theory-edges { overflow: visible; pointer-events: none; }
.theory-edge {
  stroke: var(--theory-edge);
  stroke-width: 1.1px;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  opacity: .71;
}
.theory-edge[data-related] {
  stroke: var(--theory-accent);
  stroke-width: 1.55px;
  opacity: .95;
}

.theory-shell [data-type="project"] { --theory-node-color: var(--theory-project); --theory-shape: 25%; }
.theory-shell [data-type="note"] { --theory-node-color: var(--theory-note); }
.theory-shell [data-type="work-log"] { --theory-node-color: var(--theory-work-log); }
.theory-shell [data-type="theory"] { --theory-node-color: var(--theory-theory); --theory-shape: 18%; --theory-angle: 45deg; }
.theory-node {
  position: absolute;
  inset: 0 auto auto 0;
  transform: translate(var(--node-x), var(--node-y)) translate(-50%, -50%);
  z-index: 1;
  display: grid;
  place-items: center;
  inline-size: max(44px, calc(var(--node-size, 14px) + 12px));
  block-size: max(44px, calc(var(--node-size, 14px) + 12px));
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  touch-action: none;
  cursor: grab;
  user-select: none;
}
.theory-node-dot {
  position: relative;
  display: block;
  inline-size: var(--node-size, 14px);
  block-size: var(--node-size, 14px);
  border: 1px solid color-mix(in srgb, var(--theory-ink) 43%, transparent);
  border-radius: var(--theory-shape, 100%);
  background: var(--theory-node-color, var(--theory-note));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--theory-node-color, var(--theory-note)) 17%, transparent),
    0 0 14px color-mix(in srgb, var(--theory-node-color, var(--theory-note)) 22%, transparent);
  rotate: var(--theory-angle, 0deg);
  pointer-events: none;
}
.theory-node[data-emphasis="4"] .theory-node-dot,
.theory-node[data-emphasis="5"] .theory-node-dot {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--theory-node-color, var(--theory-note)) 22%, transparent),
    0 0 18px color-mix(in srgb, var(--theory-node-color, var(--theory-note)) 36%, transparent);
}
.theory-node[data-isolated]:not(:is([data-selected], :hover, :focus-visible)) .theory-node-dot { opacity: .8; }
.theory-node[data-related] { z-index: 2; }
.theory-node[data-selected], .theory-node[aria-pressed="true"] { z-index: 3; }
.theory-node:is([data-selected], [aria-pressed="true"]) .theory-node-dot {
  outline: 1px solid var(--theory-accent);
  outline-offset: 5px;
}
.theory-node:is(:hover, :focus-visible) {
  z-index: 4;
  border-color: var(--theory-accent);
  background: color-mix(in srgb, var(--theory-accent) 12%, transparent);
}
.theory-node[data-pinned] .theory-node-dot::after {
  content: "";
  display: block;
  position: absolute;
  inset: -4px -4px auto auto;
  inline-size: 7px;
  block-size: 7px;
  border: 1.5px solid var(--theory-bg);
  border-radius: 1px;
  background: var(--theory-ink);
}
.theory-node-label {
  position: absolute;
  left: calc(50% + var(--label-x, 0px));
  top: calc(50% + var(--label-y, 28px));
  transform: translate(-50%, -50%);
  display: -webkit-box;
  inline-size: max-content;
  max-inline-size: min(142px, 32cqw);
  padding: .16rem .22rem;
  overflow: hidden;
  visibility: hidden;
  border-radius: .22rem;
  background: color-mix(in srgb, var(--theory-bg) 85%, transparent);
  color: var(--theory-ink);
  font: 510 .67rem/1.24 var(--mono);
  text-align: center;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  pointer-events: none;
}
.theory-node-label.is-label-visible, .theory-node.is-label-visible .theory-node-label { visibility: visible; }
.theory-node:is([data-selected], [aria-pressed="true"], :focus-visible) .theory-node-label {
  background: var(--theory-bg);
  color: var(--theory-ink);
  font-weight: 650;
}
.theory-help, .theory-hint {
  color: var(--theory-muted);
  font-size: .73rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.theory-help {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  column-gap: .75rem;
  padding: .47rem clamp(.7rem, 2cqw, .95rem) .17rem;
}
.theory-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .23rem .8rem;
  padding: .34rem clamp(.7rem, 2cqw, .95rem) .56rem;
  color: var(--theory-muted);
  font: .66rem/1.35 var(--mono);
}
.theory-legend > span { display: inline-flex; align-items: center; gap: .34rem; }
.theory-legend :is(i, .dot) {
  display: inline-block;
  inline-size: .52rem;
  block-size: .52rem;
  border-radius: var(--theory-shape, 100%);
  background: var(--theory-node-color, var(--theory-note));
  transform: rotate(var(--theory-angle, 0deg));
}
.theory-selection {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .75fr);
  align-items: center;
  gap: .45rem 1rem;
  padding: .55rem clamp(.7rem, 2cqw, .95rem);
  background: color-mix(in srgb, var(--theory-surface) 45%, var(--theory-bg));
  border-top: 1px solid var(--theory-border);
}
.theory-selection > div {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .3rem .55rem;
  min-inline-size: 0;
  overflow-wrap: anywhere;
}
.theory-selection strong { font-size: .79rem; }
.theory-drawer {
  border-top: 1px solid var(--theory-border);
  background: var(--theory-surface);
}
.theory-drawer > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .55rem;
  min-block-size: 2.75rem;
  padding: .51rem clamp(.7rem, 2cqw, .95rem);
  list-style: none;
  font-size: .84rem;
  font-weight: 690;
}
.theory-drawer > summary::-webkit-details-marker { display: none; }
.theory-drawer > summary::after {
  content: "";
  flex: none;
  inline-size: .44rem;
  block-size: .44rem;
  margin-inline-end: .16rem;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-25%) rotate(45deg);
}
.theory-drawer[open] > summary::after { transform: translateY(25%) rotate(225deg); }
.theory-drawer > summary:hover {
  background: color-mix(in srgb, var(--theory-accent) 7%, var(--theory-surface));
}
.theory-drawer > summary:focus-visible, .theory-node:focus-visible { outline-offset: -3px; }
.theory-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: .85rem clamp(.8rem, 4cqw, 1.35rem);
  padding: .75rem clamp(.7rem, 2cqw, .95rem) 1rem;
}
.theory-controls > * { min-inline-size: 0; }
.theory-controls > section {
  display: grid;
  align-content: start;
  gap: .62rem;
}
.theory-controls > section h3 { font-size: .96rem; }
.theory-range-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .33rem clamp(.5rem, 2cqw, 1.1rem);
  padding: .4rem clamp(.7rem, 2cqw, .95rem) .29rem;
  background: var(--theory-surface);
  border-bottom: 1px solid var(--theory-border);
}
.theory-range-grid .theory-range { min-width: 0; }
.theory-feedback {
  padding: 0 clamp(.7rem, 2cqw, .95rem) .8rem;
  color: var(--theory-ink);
  font-size: .8rem;
}
.theory-feedback:empty { padding: 0; }
.theory-controls > :is(.theory-presets, .theory-style-options, .theory-hint, .theory-custom, .theory-library, .theory-inline-actions) {
  grid-column: 1 / -1;
}
.theory-range {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .12rem .5rem;
  font-size: .78rem;
}
.theory-range output { color: var(--theory-accent); font: 630 .72rem/1.3 var(--mono); }
.theory-range :is(input[type="range"], .theory-hint) { grid-column: 1 / -1; }
.theory-range input[type="range"], .theory-importance input[type="range"] {
  inline-size: 100%;
  block-size: 1.6rem;
  margin: 0;
  accent-color: var(--theory-accent);
  cursor: pointer;
}
.theory-range .theory-hint { font-size: .7rem; }
.theory-style-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem .7rem;
  padding-block: .25rem;
}
.theory-style-options label { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; }
.theory-style-options input[type="checkbox"] { accent-color: var(--theory-accent); }
.theory-presets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.3rem), 1fr));
  gap: .38rem;
  min-inline-size: 0;
}
.theory-presets > :is(h3, h4, p, legend) { grid-column: 1 / -1; }
.theory-preset {
  display: grid;
  gap: .32rem;
  min-inline-size: 0;
  padding: .47rem .54rem;
  border: 1px solid var(--theory-border);
  border-radius: .28rem;
  background: var(--theory-bg);
  color: var(--theory-ink);
  text-align: start;
  font-size: .76rem;
  font-weight: 690;
  line-height: 1.25;
}
.theory-preset:is(:hover, [aria-pressed="true"]) { border-color: var(--theory-accent); }
.theory-preset[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--theory-accent); }
.theory-preset :is(small, .meta) { color: var(--theory-muted); font-size: .67rem; font-weight: 450; }
.theory-swatches {
  display: flex;
  gap: .19rem;
  align-items: center;
  align-self: flex-start;
}
.theory-swatches > span {
  inline-size: .77rem;
  block-size: .64rem;
  border: 1px solid color-mix(in srgb, #9091a1 45%, transparent);
  border-radius: .13rem;
  background: var(--swatch, var(--theory-accent));
}
.theory-custom, .theory-library {
  display: grid;
  min-inline-size: 0;
  gap: .63rem;
  padding: .75rem;
  border: 1px solid var(--theory-border);
  border-radius: .25rem;
  background: var(--theory-bg);
}
.theory-custom :is(h3, h4), .theory-library :is(h3, h4) { font-size: .9rem; letter-spacing: -.012em; }
.theory-custom :is(input, select):not([type="range"]), .theory-style-options select, .theory-saved input[type="text"] {
  max-inline-size: 100%;
  color: var(--theory-ink);
  background: var(--theory-surface);
  border: 1px solid var(--theory-border);
  border-radius: .24rem;
}
.theory-custom :is(input[type="text"], select), .theory-style-options select,
.theory-saved input[type="text"] { min-block-size: 2.3rem; padding: .28rem .46rem; }
.theory-custom input[type="color"] { inline-size: 2.4rem; block-size: 2.15rem; padding: .19rem; cursor: pointer; }
.theory-saved {
  display: grid;
  gap: .47rem;
  min-inline-size: 0;
  padding-block-start: .65rem;
  border-block-start: 1px solid var(--theory-border);
  overflow-wrap: anywhere;
}
.theory-saved input[type="text"] { display: block; inline-size: 100%; margin-block-start: .23rem; }
.theory-saved ul { display: grid; gap: .35rem; padding: 0; margin: 0; list-style: none; }
.theory-saved li { display: flex; flex-wrap: wrap; gap: .25rem; justify-content: space-between; }
.theory-saved li button:first-child { white-space: normal; }
.theory-studio-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .45rem;
  padding: .62rem;
  border: 1px solid var(--theory-border);
  border-radius: .27rem;
  background: color-mix(in srgb, var(--theory-accent) 7%, var(--theory-bg));
}
.theory-studio-cta > div { flex: 1 1 12rem; }
.theory-studio-cta strong { font-size: .81rem; }
.theory-studio-cta p { margin-top: .18rem; }
.theory-preset[aria-disabled="true"] small { color: var(--theory-accent); }
.theory-importance {
  --theory-accent: var(--blue-deep);
  display: grid;
  gap: .24rem;
  min-inline-size: 0;
  margin-block: .8rem;
  padding: .61rem .63rem;
  border: 1px solid var(--line);
  border-radius: .31rem;
  background: var(--paper);
  color: var(--ink);
}
.theory-importance :is(.theory-hint, .meta) { color: var(--muted); }
.theory-importance :focus-visible { outline-color: var(--blue); }

@container theory (max-width: 440px) {
  .theory-toolbar { gap: .43rem; }
  .theory-range-grid .theory-range { gap: .05rem .2rem; font-size: .7rem; }
  .theory-range-grid output { font-size: .66rem; }
  .theory-tools { margin-inline-start: 0; }
  .theory-tools .theory-tool { min-block-size: 2.75rem; }
  .theory-legend { gap: .28rem .6rem; }
  .theory-controls { grid-template-columns: minmax(0, 1fr); }
  .theory-selection { grid-template-columns: 1fr; }
}
@container theory (max-width: 355px) {
  .theory-canvas { block-size: 340px; }
}
@media (prefers-reduced-motion: no-preference) {
  .theory-shell :is(.theory-tool, .theory-preset) { transition: background-color .18s ease, border-color .18s ease; }
  .theory-drawer > summary::after { transition: transform .18s ease; }
}
@media (forced-colors: active) {
  .theory-node-dot, .theory-legend :is(i, .dot) { color: ButtonText; background: ButtonText; }
  .theory-edge { stroke: CanvasText; }
  .theory-edge[data-related] { stroke: Highlight; }
}
