/* rake — многослойная рисовалка. Монохром, две темы. */

:root {
  --paper: #f4f4f1;
  --ink: #161616;
  --muted: #8a8a86;
  --line: rgba(22, 22, 22, 0.14);
  --card: #ffffff;
  color-scheme: light;
}

body.dark {
  --paper: #000000;
  --ink: #ffffff;
  --muted: #77777a;
  --line: rgba(255, 255, 255, 0.16);
  --card: #101010;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: "DM Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.on { background: var(--ink); color: var(--paper); }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.identity { display: flex; align-items: baseline; gap: 10px; }
.identity span { color: var(--muted); }
.actions { display: flex; gap: 8px; }

.workspace {
  display: flex;
  height: calc(100% - 45px);
}

.stage-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.stage { flex: 1; position: relative; }
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.hint {
  margin: 0;
  padding: 6px 14px 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  user-select: none;
}

.panel {
  width: 230px;
  flex: none;
  border-left: 1px solid var(--line);
  padding: 12px;
  overflow-y: auto;
}

.fold summary {
  cursor: pointer;
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.control { margin-bottom: 12px; }
.control .row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
}
.control .value { color: var(--muted); }

input[type="range"] {
  width: 100%;
  accent-color: var(--ink);
  background: transparent;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}
.toggle-row button { min-width: 44px; }

.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}
.color-choices { display: flex; align-items: center; gap: 8px; }
.color-choice {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  min-width: 0;
  padding: 0;
  border-color: transparent;
  border-radius: 50%;
}
.color-choice.selected { border-color: var(--ink); }
.color-swatch {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
}
.color-swatch.mono { background: var(--ink); }
.color-swatch.red { background: #ff0000; }

@media (min-width: 721px) {
  .panel.collapsed {
    width: 0;
    padding: 0;
    border-left: 0;
    overflow: visible;
  }
  .panel.collapsed .fold { position: relative; }
  .panel.collapsed .fold summary {
    position: absolute;
    z-index: 2;
    top: 12px;
    right: 8px;
    width: max-content;
    margin: 0;
    padding: 6px 8px;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 6px;
    white-space: nowrap;
  }
}

.mobile-tools {
  display: none;
  grid-template-columns: repeat(3, 56px);
  gap: 8px;
  justify-content: center;
  padding: 4px 0 12px;
}
.mobile-tools button { padding: 14px 0; font-size: 15px; }
.mobile-tools #btn-paint { grid-column: 2; }
.mobile-tools #btn-paint.on { background: var(--ink); color: var(--paper); }

@media (max-width: 720px) {
  .bar { padding: 8px; gap: 6px; }
  .identity span { display: none; }
  .actions { gap: 4px; }
  .actions button { padding: 5px 7px; }
  .workspace { flex-direction: column-reverse; height: calc(100% - 45px); }
  .panel {
    width: 100%;
    max-height: 46vh;
    border-left: none;
    border-top: 1px solid var(--line);
    padding: 8px 12px 12px;
  }
  .mobile-tools { display: grid; }
  .hint { display: none; }
}
