:root {
  --bg: #9ea7b3;
  --panel: #d4d0c8;
  --panel-light: #f1efe8;
  --panel-dark: #7d7a73;
  --ink: #111111;
  --muted: #333333;
  --line: #808080;
  --accent: #0a246a;
  --accent-strong: #0a246a;
  --danger: #8b0000;
  --tag: #ef233c;
  --grid: rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Tahoma, Verdana, Arial, sans-serif;
  font-size: 11px;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 224px minmax(520px, 1fr) 318px;
  min-height: 100vh;
  border: 1px solid #404040;
}

.toolbox,
.inspector {
  background: var(--panel);
  border-color: #ffffff #808080 #808080 #ffffff;
  border-style: solid;
  padding: 8px;
}

.toolbox {
  border-width: 0 1px 0 0;
  overflow-y: auto;
}

.inspector {
  border-width: 0 0 0 1px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -8px -8px 8px;
  padding: 4px 8px;
  border-bottom: 1px solid #0a246a;
  background: linear-gradient(90deg, #0a246a, #a6caf0);
  color: #ffffff;
}

.brand-mark {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid #ffffff;
  border-radius: 0;
  background: #d4d0c8;
  color: #0a246a;
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 12px;
  line-height: 1.1;
}

.brand p,
#selectionStatus {
  color: inherit;
  font-size: 10px;
}

.tool-section {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
  padding: 8px 6px 6px;
  border: 1px solid;
  border-color: #808080 #ffffff #ffffff #808080;
  background: #c8c4bc;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}

.tool-section h2,
.panel-heading h2 {
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #111111;
  font-weight: 700;
}

.mode-button,
.tool-button,
.secondary-button,
.export-button,
.mini-button {
  border: 1px solid;
  border-color: #ffffff #404040 #404040 #ffffff;
  border-radius: 0;
  min-height: 24px;
  cursor: pointer;
}

.mode-button {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 3px;
  background: var(--panel);
  color: var(--ink);
  padding: 2px 4px;
  font-size: 10px;
  line-height: 1.1;
  text-align: left;
}

.mode-button span {
  font-family: "Courier New", monospace;
  font-size: 15px;
  line-height: 1;
  text-align: center;
}

.mode-button.active {
  border-color: #404040 #ffffff #ffffff #404040;
  background: #ffffff;
  color: #0a246a;
}

.tool-button {
  text-align: left;
  background: var(--panel);
  color: var(--ink);
  padding: 0 7px;
}

.mode-button:hover,
.tool-button:hover,
.secondary-button:hover {
  background: #e8e5dc;
}

.secondary-button {
  background: var(--panel);
}

.file-input {
  display: none;
}

.secondary-button.danger {
  color: var(--danger);
}

.workbench {
  display: grid;
  grid-template-rows: 42px minmax(0, 1fr) 148px;
  min-width: 0;
  min-height: 0;
  background: #808080;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 4px 8px;
  background: var(--panel);
  border-color: #ffffff #808080 #808080 #ffffff;
  border-style: solid;
  border-width: 0 0 1px 0;
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.screen-strip {
  display: grid;
  grid-template-rows: 22px 14px;
  gap: 1px;
  min-width: 0;
  overflow: hidden;
}

.screen-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.screen-tabs {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.screen-tabs::-webkit-scrollbar {
  display: none;
}

.screen-tab,
.screen-add {
  border: 1px solid;
  border-color: #ffffff #404040 #404040 #ffffff;
  border-radius: 0;
  min-height: 22px;
  background: var(--panel);
  color: #111111;
  cursor: pointer;
  font: inherit;
  padding: 1px 10px;
  white-space: nowrap;
  flex: 0 0 auto;
  height: 22px;
  line-height: 16px;
}

.screen-tab.active {
  border-color: #404040 #ffffff #ffffff #404040;
  background: #ffffff;
  color: #0a246a;
  font-weight: 700;
}

.screen-add {
  width: 26px;
  padding: 2px 0;
  font-weight: 700;
}

#selectionStatus {
  line-height: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-button {
  min-height: 14px;
  height: 14px;
  padding: 0 5px;
  background: var(--panel);
  color: #111111;
  font-size: 10px;
  line-height: 10px;
  white-space: nowrap;
}

.mini-button.danger {
  color: var(--danger);
}

.export-button {
  border-color: #ffffff #404040 #404040 #ffffff;
  background: var(--panel);
  color: #111111;
  font-weight: 400;
  padding: 0 10px;
}

.export-button:hover {
  background: #e8e5dc;
}

.export-button:active,
.tool-button:active,
.secondary-button:active,
.mode-button:active,
.mini-button:active {
  border-color: #404040 #ffffff #ffffff #404040;
}

.canvas-wrap {
  overflow: auto;
  padding: 12px;
  background: #8f98a3;
}

.canvas {
  position: relative;
  width: 960px;
  height: 640px;
  margin: 0 auto;
  background-color: #fbfbfb;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 16px 16px;
  border: 1px solid;
  border-color: #404040 #ffffff #ffffff #404040;
  box-shadow: none;
}

.canvas.shape-mode,
.canvas.arrow-mode {
  cursor: crosshair;
}

.element {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  border: 1px solid #606060;
  background: #eeeeee;
  color: #111111;
  user-select: none;
  cursor: move;
  overflow: visible;
  font-size: 12px;
}

.element.selected {
  outline: 1px dotted #000000;
  outline-offset: 2px;
}

.element.button {
  border-color: #006060;
  border-radius: 0;
  background: #008080;
  color: white;
  font-weight: 700;
}

.element.input,
.element.textarea {
  justify-content: flex-start;
  padding-left: 8px;
  border-radius: 0;
  background: white;
  color: #333366;
}

.element.textarea {
  align-items: flex-start;
  padding-top: 12px;
}

.element.container {
  border-style: dashed;
  border-color: #404040;
  border-radius: 0;
  background: rgba(192, 192, 192, 0.28);
  color: #333333;
}

.element.label {
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  color: #111827;
  font-weight: 700;
}

.element.placeholder {
  border-style: dashed;
  border-radius: 0;
  background:
    linear-gradient(135deg, transparent calc(50% - 1px), #808080 50%, transparent calc(50% + 1px)),
    linear-gradient(45deg, transparent calc(50% - 1px), #808080 50%, transparent calc(50% + 1px)),
    #e8e8e8;
  color: #222222;
}

.element.checkbox,
.element.radio {
  justify-content: flex-start;
  gap: 8px;
  border-color: transparent;
  background: transparent;
  color: #111111;
  font-weight: 400;
}

.element.checkbox::before,
.element.radio::before {
  content: "";
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  margin-left: 4px;
  border: 1px solid;
  border-color: #404040 #ffffff #ffffff #404040;
  background: #ffffff;
}

.element.radio::before {
  border-radius: 50%;
}

.element.toggle {
  justify-content: flex-start;
  padding-left: 48px;
  border-color: #404040;
  background: #d4d0c8;
}

.element.toggle::before {
  content: "";
  position: absolute;
  left: 8px;
  width: 34px;
  height: 16px;
  border: 1px solid;
  border-color: #404040 #ffffff #ffffff #404040;
  background: #ffffff;
}

.element.toggle::after {
  content: "";
  position: absolute;
  left: 10px;
  width: 13px;
  height: 12px;
  border: 1px solid #808080;
  background: #c0c0c0;
}

.element.dropdown {
  justify-content: flex-start;
  padding-left: 8px;
  padding-right: 30px;
  border-color: #404040 #ffffff #ffffff #404040;
  background: #ffffff;
  color: #111111;
}

.element.dropdown::after {
  content: "v";
  position: absolute;
  right: 2px;
  top: 2px;
  display: grid;
  width: 24px;
  height: calc(100% - 4px);
  place-items: center;
  border: 1px solid;
  border-color: #ffffff #404040 #404040 #ffffff;
  background: var(--panel);
  font-size: 10px;
}

.element.slider {
  border-color: transparent;
  background: transparent;
  color: #111111;
}

.element.slider::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 50%;
  height: 4px;
  border: 1px solid;
  border-color: #404040 #ffffff #ffffff #404040;
  background: #ffffff;
}

.element.slider::after {
  content: "";
  position: absolute;
  left: 45%;
  top: calc(50% - 10px);
  width: 12px;
  height: 20px;
  border: 1px solid #404040;
  background: #c0c0c0;
}

.element.table,
.element.list,
.element.tabs,
.element.modal,
.element.card {
  align-items: flex-start;
  justify-content: flex-start;
  padding: 8px;
  border-color: #404040 #ffffff #ffffff #404040;
  background: #ffffff;
  color: #111111;
}

.element.table {
  background:
    linear-gradient(#c0c0c0 0 24px, transparent 24px),
    repeating-linear-gradient(to right, transparent 0 88px, #c0c0c0 88px 89px),
    repeating-linear-gradient(to bottom, transparent 0 30px, #c0c0c0 30px 31px),
    #ffffff;
  font-weight: 700;
}

.element.list {
  background:
    repeating-linear-gradient(to bottom, #ffffff 0 27px, #e8e8e8 27px 28px);
}

.element.tabs {
  padding-top: 30px;
  background:
    linear-gradient(to right, #ffffff 0 78px, #c0c0c0 78px 156px, #c0c0c0 156px 234px, transparent 234px),
    linear-gradient(#c0c0c0 0 28px, #ffffff 28px);
}

.element.modal {
  padding-top: 32px;
  background:
    linear-gradient(#0a246a 0 24px, #d4d0c8 24px);
  color: #111111;
}

.element.toolbar,
.element.menubar,
.element.statusbar {
  justify-content: flex-start;
  padding: 0 8px;
  border-color: #ffffff #404040 #404040 #ffffff;
  background: var(--panel);
  color: #111111;
  font-weight: 400;
}

.element.toolbar {
  gap: 4px;
}

.element.toolbar::before {
  content: "";
  width: 22px;
  height: 22px;
  margin-right: 6px;
  border: 1px solid;
  border-color: #ffffff #404040 #404040 #ffffff;
  background: #d4d0c8;
  box-shadow: 28px 0 0 #d4d0c8, 56px 0 0 #d4d0c8;
}

.element.statusbar {
  border-color: #808080 #ffffff #ffffff #808080;
}

.element.image,
.element.chart {
  border-color: #404040 #ffffff #ffffff #404040;
  background: #e8e8e8;
  color: #111111;
}

.element.image {
  background:
    linear-gradient(135deg, transparent calc(50% - 1px), #808080 50%, transparent calc(50% + 1px)),
    linear-gradient(45deg, transparent calc(50% - 1px), #808080 50%, transparent calc(50% + 1px)),
    #e8e8e8;
}

.element.chart {
  align-items: flex-end;
  gap: 8px;
  padding: 16px;
}

.element.chart::before {
  content: "";
  width: 22px;
  height: 44px;
  background: #008080;
  box-shadow: 32px -24px 0 #008080, 64px -8px 0 #008080;
}

.element.progress {
  justify-content: flex-start;
  padding: 3px;
  border-color: #404040 #ffffff #ffffff #404040;
  background: #ffffff;
  color: transparent;
}

.element.progress::before {
  content: "";
  width: 45%;
  height: 100%;
  background: repeating-linear-gradient(to right, #0a246a 0 10px, #ffffff 10px 12px);
}

.element.stepper {
  justify-content: center;
  border-color: #808080;
  background: #ffffff;
  color: #111111;
}

.element.card {
  background: #ffffff;
  box-shadow: inset 0 24px 0 #e8e8e8;
}

.element.shape,
.element.arrow {
  align-items: stretch;
  justify-content: stretch;
  border-color: transparent;
  background: transparent;
}

.element.shape.selected,
.element.arrow.selected {
  outline-style: dashed;
}

.drawing-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.resize-handle {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 9px;
  height: 9px;
  border: 1px solid #000000;
  background: #ffffff;
  cursor: nwse-resize;
  z-index: 3;
}

.tag {
  position: absolute;
  top: -12px;
  left: -12px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid white;
  border-radius: 50%;
  background: var(--tag);
  color: white;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.project-rules,
.screen-rules {
  margin-bottom: 10px;
  padding: 8px;
  border: 1px solid;
  border-color: #808080 #ffffff #ffffff #808080;
  background: #c8c4bc;
}

.inventory-dock {
  display: grid;
  grid-template-rows: 24px 1fr;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border-style: solid;
  border-width: 1px 0 0;
  border-color: #ffffff #808080 #808080 #ffffff;
}

.inventory-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  border-bottom: 1px solid #808080;
  background: #c0c0c0;
}

.inventory-titlebar h2 {
  font-size: 10px;
  text-transform: uppercase;
}

.inventory-titlebar span {
  color: #333333;
}

.inventory-list {
  display: grid;
  grid-auto-rows: min-content;
  gap: 0;
  min-height: 0;
  margin: 6px;
  overflow: auto;
  border: 1px solid;
  border-color: #404040 #ffffff #ffffff #404040;
  background: #ffffff;
}

.inventory-header,
.inventory-item {
  display: grid;
  grid-template-columns: 52px minmax(130px, 1.2fr) 92px minmax(180px, 1.6fr) 86px 86px;
  align-items: center;
  min-width: 720px;
}

.inventory-item {
  min-height: 22px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid #d0d0d0;
  background: #ffffff;
  color: #111111;
  text-align: left;
  cursor: pointer;
}

.inventory-header {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 22px;
  border-bottom: 1px solid #808080;
  background: var(--panel);
  font-weight: 700;
}

.inventory-header span,
.inventory-item span {
  overflow: hidden;
  padding: 3px 6px;
  border-right: 1px solid #d0d0d0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-item.active {
  background: #0a246a;
  color: #ffffff;
}

.inventory-empty {
  padding: 12px;
  background: #ffffff;
  color: #333333;
}

.spec-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.22);
}

.spec-modal[hidden] {
  display: none;
}

.spec-window {
  display: grid;
  grid-template-rows: 24px minmax(280px, 1fr) 34px;
  width: min(860px, calc(100vw - 48px));
  height: min(680px, calc(100vh - 48px));
  border: 1px solid;
  border-color: #ffffff #404040 #404040 #ffffff;
  background: var(--panel);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
}

.spec-window-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 4px 3px 8px;
  background: linear-gradient(90deg, #0a246a, #a6caf0);
  color: #ffffff;
}

.spec-window-titlebar h2 {
  font-size: 11px;
}

.window-close {
  width: 18px;
  height: 18px;
  border: 1px solid;
  border-color: #ffffff #404040 #404040 #ffffff;
  background: var(--panel);
  color: #111111;
  font-weight: 700;
  line-height: 12px;
  cursor: pointer;
}

.spec-editor {
  width: auto;
  min-width: 0;
  min-height: 0;
  margin: 8px;
  padding: 8px;
  border: 1px solid;
  border-color: #404040 #ffffff #ffffff #404040;
  background: #ffffff;
  color: #111111;
  resize: none;
  font: 12px/1.4 "Courier New", monospace;
}

.spec-window-footer {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 5px 8px;
  border-top: 1px solid #808080;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -8px -8px 8px;
  padding: 4px 8px;
  border-bottom: 1px solid #808080;
  background: #c0c0c0;
}

.inspector label {
  display: grid;
  gap: 3px;
  margin-bottom: 8px;
  color: #111111;
  font-size: 10px;
  font-weight: 700;
}

.inspector input,
.inspector textarea {
  width: 100%;
  border: 1px solid;
  border-color: #404040 #ffffff #ffffff #404040;
  border-radius: 0;
  background: white;
  color: var(--ink);
  padding: 4px 5px;
  resize: vertical;
  font-size: 11px;
}

.inspector input:disabled,
.inspector textarea:disabled {
  background: #c8c4bc;
  color: #777777;
}

.property-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .toolbox,
  .inspector {
    border-width: 0 0 1px 0;
  }

  .tool-section {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-section h2 {
    grid-column: 1 / -1;
  }

  .workbench {
    min-height: 720px;
  }

  .topbar-actions {
    gap: 4px;
  }
}
