:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #20242a;
  --muted: #69707a;
  --line: #d7dce2;
  --accent: #2563eb;
  --free: #e7f6ed;
  --busy: #ffe8e1;
  --shadow: 0 8px 20px rgba(32, 36, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
}

button,
select {
  font: inherit;
}

.shell {
  width: min(1600px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0;
}

.topbar,
.controls,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 16px;
}

#statusLine,
.meta,
.muted {
  color: var(--muted);
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.topbar button,
.actions button {
  padding: 0 12px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(260px, 360px) 1fr;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
  padding: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 0 10px;
}

.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 14px;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  padding: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  margin-bottom: 12px;
}

.side {
  display: grid;
  gap: 14px;
  align-content: start;
}

.cells-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}

.cell {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 2px;
  min-height: 78px;
  padding: 8px;
  border-color: var(--line);
  text-align: left;
  overflow: hidden;
}

.cell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cell-led {
  position: relative;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 1px solid #8c96a3;
  border-radius: 50%;
  background:
    linear-gradient(135deg, transparent 43%, #66717f 45%, #66717f 55%, transparent 57%),
    #d8dde3;
}

.cell-led::after {
  content: none;
}

.cell.is-empty {
  background: var(--free);
}

.cell.is-busy {
  background: var(--busy);
}

.cell.is-lighten {
  border-color: var(--cell-light);
  box-shadow: inset 0 0 0 2px var(--cell-light);
}

.cell.is-lighten .cell-led {
  border-color: #20242a;
  background: var(--cell-light);
  box-shadow: 0 0 0 2px #ffffff, 0 0 8px var(--cell-light);
}

.cell.is-lighten .cell-led::after {
  display: none;
}

.cell-number {
  font-weight: 700;
}

.cell-state,
.cell-light,
.cell-reel {
  font-size: 12px;
  color: var(--muted);
}

.cell-reel {
  min-height: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tower-list,
.journal {
  display: grid;
  gap: 8px;
}

.tower {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #ffffff;
}

.tower strong,
.tower span {
  display: block;
}

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

.tower-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #f1f3f5;
}

.tower.is-lighten .tower-dot {
  background: var(--tower-light);
  border-color: var(--tower-light);
}

.journal {
  max-height: 520px;
  overflow: auto;
}

.journal-row {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #ffffff;
}

.journal-row span,
.journal-row small {
  color: var(--muted);
}

@media (max-width: 960px) {
  .controls,
  .workspace {
    grid-template-columns: 1fr;
  }

  .actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
