:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #69717c;
  --line: #d7dde2;
  --panel: #f6f8f8;
  --paper: #ffffff;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --amber: #d97706;
  --shadow: 0 20px 60px rgba(32, 33, 36, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(255, 255, 255, 0) 360px),
    #eef2f1;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.workspace,
.side-panel {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(215, 221, 226, 0.9);
  box-shadow: var(--shadow);
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto;
  overflow: hidden;
  border-radius: 8px;
}

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

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 12px;
  font-size: 15px;
}

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

.icon-button,
.small-button,
.seg-button,
.brush-button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 9px 13px;
  border-radius: 8px;
  font-weight: 700;
}

.icon-button input {
  display: none;
}

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

.icon-button.primary:hover {
  background: var(--accent-dark);
}

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 18px;
  overflow: auto;
  background:
    linear-gradient(45deg, #edf1f0 25%, transparent 25%),
    linear-gradient(-45deg, #edf1f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf1f0 75%),
    linear-gradient(-45deg, transparent 75%, #edf1f0 75%);
  background-color: #f8faf9;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

canvas {
  display: none;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  background: white;
  box-shadow: 0 12px 36px rgba(32, 33, 36, 0.22);
  touch-action: none;
}

.empty-state {
  display: grid;
  gap: 8px;
  place-items: center;
  max-width: 360px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.9);
  border: 1px dashed #b9c3c9;
  border-radius: 8px;
}

.empty-state strong {
  color: var(--ink);
  font-size: 18px;
}

.tool-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: rgba(246, 248, 248, 0.95);
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.seg-button,
.brush-button {
  min-height: 36px;
  padding: 7px 11px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  white-space: nowrap;
}

.seg-button:last-child,
.brush-button:last-child {
  border-right: 0;
}

.seg-button.active,
.brush-button.active {
  background: #d8f0ec;
  color: #064d48;
  font-weight: 700;
}

.compact-control {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 180px;
  color: var(--muted);
  font-size: 13px;
}

.compact-control input {
  min-width: 110px;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: 8px;
}

.side-panel section {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
}

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

.sliders {
  display: grid;
  gap: 15px;
}

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

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

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.small-button {
  min-height: 40px;
  border-radius: 8px;
  font-size: 22px;
}

.note p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

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

  .side-panel {
    order: -1;
  }

  .workspace {
    min-height: 70vh;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    width: 100%;
  }

  .icon-button {
    flex: 1;
  }

  h1 {
    font-size: 21px;
  }

  .canvas-wrap {
    padding: 10px;
  }

  .tool-row {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
  }
}
