:root {
  color-scheme: light;
  --bg: #f3f3f1;
  --surface: #faf9f6;
  --ink: #5b5852;
  --text: #54514b;
  --muted: #6f6b63;
  --faint: #c9c8c1;
  --line: rgba(91, 88, 82, 0.14);
  --line-strong: rgba(91, 88, 82, 0.24);
  --panel: #111111;
  --panel-soft: #171717;
  --card: rgba(250, 249, 246, 0.86);
  --accent: #daab7f;
  --accent-soft: rgba(218, 171, 127, 0.16);
  --blue: #336cff;
  --teal: #0f766e;
  --red: #dc2626;
  --green: #15803d;
  --shadow: 0 24px 60px rgba(25, 25, 25, 0.08);
  --font-main: "Farabee Straight", "Arial Narrow", Arial, sans-serif;
  --workspace-bg: #faf9f6;
  --workspace-grid: rgba(91, 88, 82, 0.08);
  --topbar-bg: rgba(250, 249, 246, 0.94);
  --topbar-text: #5b5852;
  --topbar-muted: rgba(64, 61, 56, 0.9);
  --legend-bg: rgba(250, 249, 246, 0.96);
  --legend-text: rgba(64, 61, 56, 0.92);
}

body.theme-dark {
  --bg: #0f0f0f;
  --surface: #151515;
  --ink: #f4f4f1;
  --text: rgba(244, 244, 241, 0.82);
  --muted: rgba(244, 244, 241, 0.48);
  --line: rgba(244, 244, 241, 0.11);
  --line-strong: rgba(244, 244, 241, 0.22);
  --card: rgba(23, 23, 23, 0.92);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  --workspace-bg: #121212;
  --workspace-grid: rgba(244, 244, 241, 0.055);
  --topbar-bg: rgba(17, 17, 17, 0.94);
  --topbar-text: #f4f4f1;
  --topbar-muted: rgba(244, 244, 241, 0.52);
  --legend-bg: rgba(17, 17, 17, 0.94);
  --legend-text: rgba(244, 244, 241, 0.64);
}

body.theme-light {
  --bg: #f3f3f1;
  --surface: #faf9f6;
  --ink: #5b5852;
  --text: #54514b;
  --muted: #6f6b63;
  --line: rgba(91, 88, 82, 0.14);
  --line-strong: rgba(91, 88, 82, 0.24);
  --card: rgba(250, 249, 246, 0.86);
  --shadow: 0 24px 60px rgba(25, 25, 25, 0.08);
  --workspace-bg: #faf9f6;
  --workspace-grid: rgba(91, 88, 82, 0.08);
  --topbar-bg: rgba(250, 249, 246, 0.94);
  --topbar-text: #5b5852;
  --topbar-muted: rgba(64, 61, 56, 0.9);
  --legend-bg: rgba(250, 249, 246, 0.96);
  --legend-text: rgba(64, 61, 56, 0.92);
}

@font-face {
  font-family: "Farabee Straight";
  src:
    local("Farabee Straight Regular"),
    local("Farabee Straight"),
    url("https://161.104.16.64.sslip.io/assets/fonts/Farabee%20font/Farabee%20Straight%20Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Farabee Straight";
  src:
    local("Farabee Straight Bold"),
    url("https://161.104.16.64.sslip.io/assets/fonts/Farabee%20font/Farabee%20Straight%20Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
}

button,
input,
select {
  font: inherit;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 352px minmax(0, 1fr);
  height: 100vh;
  background: var(--bg);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding: 18px;
  background: var(--panel);
  color: rgba(244, 244, 241, 0.82);
  border-right: 1px solid rgba(244, 244, 241, 0.1);
}

body.theme-light .sidebar {
  background: rgba(250, 249, 246, 0.96);
  color: rgba(45, 43, 39, 0.92);
  border-right-color: var(--line);
}

body.theme-light .brand h1 {
  color: var(--ink);
}

body.theme-light .brand p {
  color: rgba(64, 61, 56, 0.86);
}

.brand {
  padding: 3px 0 8px;
}

.brand h1 {
  margin: 0;
  color: #f4f4f1;
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand p {
  margin: 8px 0 0;
  color: rgba(244, 244, 241, 0.48);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.panel {
  position: relative;
  padding: 13px;
  border: 1px solid rgba(244, 244, 241, 0.1);
  background: var(--panel-soft);
  color: rgba(244, 244, 241, 0.8);
}

body.theme-light .panel {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.58);
  color: rgba(45, 43, 39, 0.92);
}

body.theme-light .panel::before,
body.theme-light .panel::after {
  border-color: rgba(91, 88, 82, 0.38);
}

body.theme-light .panel h2 {
  color: var(--ink);
}

.panel::before,
.panel::after {
  content: "";
  position: absolute;
  top: -1px;
  width: 12px;
  height: 12px;
  border-color: rgba(244, 244, 241, 0.44);
  border-style: solid;
  pointer-events: none;
}

.panel::before {
  left: -1px;
  border-width: 2px 0 0 2px;
}

.panel::after {
  right: -1px;
  border-width: 2px 2px 0 0;
}

.panel h2 {
  margin: 0 0 11px;
  color: #f4f4f1;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.counter {
  display: inline-grid;
  min-width: 25px;
  height: 22px;
  place-items: center;
  border: 1px solid rgba(218, 171, 127, 0.54);
  background: rgba(218, 171, 127, 0.13);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.file-drop {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px dashed rgba(244, 244, 241, 0.22);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
}

body.theme-light .file-drop {
  border-color: rgba(91, 88, 82, 0.2);
  background: rgba(255, 255, 255, 0.44);
}

body.theme-light .file-drop:hover,
body.theme-light .file-drop:focus-within {
  border-color: rgba(218, 171, 127, 0.72);
  background: rgba(218, 171, 127, 0.12);
}

body.theme-light .file-drop__icon {
  border-color: var(--line);
  background: var(--ink);
  color: var(--surface);
}

body.theme-light .file-drop strong {
  color: var(--ink);
}

body.theme-light .file-drop small,
body.theme-light .hint,
body.theme-light .point-info {
  color: rgba(64, 61, 56, 0.86);
}

.file-drop:hover,
.file-drop:focus-within {
  border-color: rgba(218, 171, 127, 0.58);
  background: rgba(218, 171, 127, 0.08);
}

.file-drop__icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(244, 244, 241, 0.18);
  background: #0d0d0d;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.file-drop strong {
  display: block;
  color: #f4f4f1;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.file-drop small,
.hint,
.point-info {
  display: block;
  color: rgba(244, 244, 241, 0.46);
  font-size: 0.7rem;
  line-height: 1.25;
}

#fileInput,
#projectInput {
  display: none;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.grid-2 h2,
.wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: rgba(244, 244, 241, 0.52);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

body.theme-light label {
  color: rgba(64, 61, 56, 0.9);
}

input,
select {
  width: 100%;
  height: 34px;
  padding: 0 9px;
  border: 1px solid rgba(244, 244, 241, 0.14);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.025);
  color: #f4f4f1;
  outline: none;
}

body.theme-light input,
body.theme-light select {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: #2d2b27;
}

body.theme-light input::placeholder {
  color: rgba(64, 61, 56, 0.62);
}

select option {
  color: #111;
}

input:focus,
select:focus {
  border-color: rgba(218, 171, 127, 0.7);
  box-shadow: 0 0 0 1px rgba(218, 171, 127, 0.18);
}

input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
  box-shadow: none;
}

input::placeholder {
  color: rgba(244, 244, 241, 0.34);
  opacity: 1;
}

.inline-value {
  float: right;
  color: var(--accent);
  font-weight: 700;
}

.compact {
  margin-top: 12px;
}

.nudge-pad {
  display: grid;
  grid-template-columns: repeat(3, 38px);
  gap: 6px;
  justify-content: center;
  margin-top: 12px;
}

.nudge-pad button,
.view-actions button,
.tool-tabs button {
  border: 1px solid rgba(244, 244, 241, 0.14);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.025);
  color: rgba(244, 244, 241, 0.82);
  cursor: pointer;
  font-weight: 700;
}

body.theme-light .nudge-pad button {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
}

body.theme-light .nudge-pad button:hover,
body.theme-light .nudge-pad button:focus-visible {
  border-color: rgba(218, 171, 127, 0.72);
  background: rgba(218, 171, 127, 0.16);
}

.nudge-pad button {
  width: 38px;
  height: 32px;
}

.nudge-pad button:hover,
.view-actions button:hover,
.tool-tabs button:hover {
  border-color: rgba(218, 171, 127, 0.58);
  background: rgba(218, 171, 127, 0.12);
  color: #f4f4f1;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: #f4f4f1;
  color: #111111;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.button:hover,
.button:focus-visible {
  background: var(--accent);
  color: #111111;
}

.button.secondary {
  width: 100%;
  margin-top: 9px;
  border: 1px solid rgba(244, 244, 241, 0.14);
  background: transparent;
  color: rgba(244, 244, 241, 0.82);
}

body.theme-light .button.secondary {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.58);
  color: #2d2b27;
}

body.theme-light .button.secondary.active,
body.theme-light .button.secondary:hover,
body.theme-light .button.secondary:focus-visible {
  border-color: rgba(218, 171, 127, 0.72);
  background: rgba(218, 171, 127, 0.16);
  color: #2d2b27;
}

body.theme-light .counter,
body.theme-light .inline-value {
  color: #4f3826;
}

.button-row .button.secondary {
  margin-top: 0;
}

.button.secondary.active,
.button.secondary:hover,
.button.secondary:focus-visible {
  border-color: rgba(218, 171, 127, 0.58);
  background: rgba(218, 171, 127, 0.12);
  color: #f4f4f1;
}

.button.success {
  width: 100%;
  background: var(--accent);
  color: #111111;
}

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

.button.danger {
  width: 100%;
  border: 1px solid rgba(220, 38, 38, 0.46);
  background: rgba(220, 38, 38, 0.12);
  color: #6f1616;
}

.button.danger:hover,
.button.danger:focus-visible {
  background: rgba(220, 38, 38, 0.24);
}

.wide-action {
  margin-top: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.hidden {
  display: none;
}

.workspace {
  position: relative;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
  min-width: 0;
  background: var(--workspace-bg);
}

.workspace-logo {
  position: absolute;
  top: 68px;
  right: 22px;
  z-index: 8;
  color: var(--topbar-text);
  font-size: clamp(1.25rem, 2.4vw, 2.8rem);
  font-weight: 700;
  line-height: 0.84;
  letter-spacing: 0.03em;
  text-decoration: none;
  text-transform: uppercase;
  opacity: 0.14;
  mix-blend-mode: multiply;
  transition:
    opacity 180ms ease,
    color 180ms ease;
  pointer-events: auto;
}

body.theme-dark .workspace-logo {
  color: #f4f4f1;
  opacity: 0.18;
  mix-blend-mode: normal;
}

.workspace-logo:hover,
.workspace-logo:focus-visible {
  color: var(--accent);
  opacity: 0.9;
  outline: none;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  color: var(--topbar-text);
}

.tool-tabs {
  display: none;
  gap: 6px;
}

.tool-tabs button,
.view-actions button {
  height: 32px;
  min-width: 36px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--topbar-text);
}

.tool-tabs button {
  padding: 0 12px;
}

.tool-tabs .active {
  background: var(--ink);
  color: var(--surface);
}

.status {
  overflow: hidden;
  color: var(--topbar-muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.view-actions {
  display: flex;
  gap: 6px;
}

.theme-toggle {
  min-width: 82px !important;
  padding: 0 12px;
  color: var(--accent) !important;
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

body.theme-light .theme-toggle {
  color: #2d2b27 !important;
}

canvas {
  width: 100%;
  height: 100%;
  cursor: default;
}

canvas.panning {
  cursor: grabbing;
}

.legend {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  gap: 14px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  background: var(--legend-bg);
  box-shadow: var(--shadow);
  color: var(--legend-text);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 5px;
  border-radius: 50%;
  vertical-align: -1px;
}

.dot.base { background: #111111; }
.dot.preview { background: var(--teal); }
.dot.rule { background: var(--blue); }
.dot.selected { background: var(--red); }

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(244, 244, 241, 0.1);
  }

  .workspace {
    height: 70vh;
  }
}
