:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #eef2f5;
  --text: #1b2028;
  --muted: #667085;
  --line: #d6dde5;
  --accent: #0f766e;
  --accent-2: #164e63;
  --danger: #b42318;
  --canvas: #fbfcfd;
  --wire: #26313f;
  --selected: #eab308;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(520px, 1fr) 340px;
  height: 100vh;
  width: 100vw;
  min-height: 0;
  overflow: hidden;
}

.sidebar,
.netlist-panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: auto;
  min-height: 0;
}

.netlist-panel {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent-2);
  color: white;
  font-weight: 800;
  font-size: 15px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 16px;
  line-height: 1.2;
}

.brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.tool-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.tool-section h2,
.panel-head h2 {
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #344054;
}

.component-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.component-button,
.tool-button,
.primary-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.component-button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  font-weight: 700;
  font-size: 13px;
}

.tool-button,
.primary-button {
  width: 100%;
  margin-top: 8px;
  text-align: left;
  padding: 8px 11px;
}

.field-label {
  display: block;
  margin: 9px 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field-control {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 7px 9px;
}

.save-status {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  margin: 4px 0 6px;
  color: #344054;
  font-size: 13px;
  cursor: pointer;
}

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

.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 700;
}

.danger-button {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--danger);
}

.component-button.active,
.tool-button.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.14);
}

.component-button:hover,
.tool-button:hover,
.primary-button:hover {
  filter: brightness(0.98);
}

.inspector {
  min-height: 88px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.workspace {
  display: grid;
  grid-template-rows: 52px 1fr;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.status {
  color: var(--muted);
  font-size: 13px;
}

.canvas-wrap {
  overflow: auto;
  padding: 18px;
  min-width: 0;
  min-height: 0;
}

#circuitCanvas {
  display: block;
  width: 1600px;
  height: 1000px;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(27, 32, 40, 0.08);
  cursor: crosshair;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px 8px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
}

.panel-head span {
  color: var(--muted);
  font-size: 12px;
}

#netlistOutput {
  margin: 0;
  padding: 14px 18px 24px;
  white-space: pre-wrap;
  color: #26313f;
  font: 12px/1.55 Consolas, "SFMono-Regular", Menlo, monospace;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 240px minmax(460px, 1fr);
  }

  .netlist-panel {
    display: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 45vh) minmax(0, 55vh);
    height: 100vh;
    min-height: 0;
  }

  .sidebar {
    max-height: none;
  }

  .workspace {
    min-height: 0;
  }

  .topbar {
    align-items: flex-start;
    gap: 8px;
    flex-direction: column;
    height: auto;
    padding: 10px 12px;
  }
}
