:root {
  color-scheme: light;
  --bg: #eef1ee;
  --panel: #ffffff;
  --panel-soft: #f8faf8;
  --ink: #163f73;
  --text: #17242d;
  --muted: #657581;
  --line: #d7dfdd;
  --line-strong: #becbc8;
  --accent: #0f766e;
  --accent-soft: #e4f4f1;
  --gold: #b8872e;
  --danger: #b83232;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(184, 135, 46, 0.1), transparent 28%),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 100vh;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  background: rgba(248, 250, 248, 0.94);
  border-right: 1px solid var(--line);
  box-shadow: 16px 0 44px rgba(23, 36, 45, 0.08);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 2px 10px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 3px double var(--accent);
  border-radius: 50%;
  background: #ffffff;
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.14);
}

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

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

.panel {
  display: grid;
  gap: 13px;
  padding: 15px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(18, 34, 43, 0.07);
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-title-row span {
  min-width: 26px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

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

input[type="text"] {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--panel-soft);
  outline: none;
}

input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

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

input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.file-drop {
  display: grid;
  min-height: 76px;
  place-items: center;
  padding: 13px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f7faf8);
  color: var(--accent);
  cursor: pointer;
  font-weight: 800;
  text-align: center;
}

.file-drop:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-drop input {
  width: 100%;
  max-width: 230px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

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

.compact-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

button {
  display: grid;
  min-width: 0;
  min-height: 40px;
  place-items: center;
  border: 1px solid #c7d5d2;
  border-radius: 7px;
  background: linear-gradient(180deg, #ffffff, #f4f8f7);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.02em;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.12);
}

button.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #075d52;
}

button.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: 0 8px 18px rgba(184, 50, 50, 0.1);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
  box-shadow: none;
}

.layers {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.layer-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.layer-item:hover,
.layer-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.layer-type {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: #ffffff;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px var(--line);
}

.layer-name {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.layer-delete {
  min-height: 34px;
  width: 34px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.workspace {
  display: grid;
  min-width: 0;
  place-items: center;
  padding: 28px;
}

.canvas-shell {
  width: min(91vmin, 980px);
  display: grid;
  gap: 14px;
}

.workspace-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
}

.workspace-top strong {
  display: block;
  font-size: 18px;
}

.workspace-top span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.download-btn {
  min-height: 44px;
  padding: 0 18px;
  border-color: rgba(184, 135, 46, 0.55);
  background: linear-gradient(180deg, #fff8e6, #ecd39b);
  color: #674817;
  box-shadow: 0 10px 22px rgba(184, 135, 46, 0.18);
  white-space: nowrap;
}

.download-btn:hover {
  border-color: var(--gold);
  color: #4f360e;
}

.stage-wrap {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2vw, 18px);
  border: 1px solid rgba(190, 203, 200, 0.85);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(55, 75, 68, 0.06) 1px, transparent 1px),
    linear-gradient(rgba(55, 75, 68, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, #ffffff, #f4f7f5);
  background-size: 34px 34px, 34px 34px, auto;
  box-shadow: 0 24px 64px rgba(17, 35, 45, 0.16);
}

canvas {
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid #cbd7d4;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
  touch-action: none;
}

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

  .toolbar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 55vh;
  }

  .workspace {
    min-height: 45vh;
    padding: 14px;
  }

  .canvas-shell {
    width: min(96vw, 680px);
  }
}
