:root {
  color-scheme: light;
  --bg: #edf2f8;
  --bg-deep: #d7e0ec;
  --panel: rgba(14, 23, 38, 0.94);
  --panel-soft: rgba(255, 255, 255, 0.8);
  --surface: #f8fafc;
  --surface-strong: #ffffff;
  --paper: #fffef9;
  --ink: #102133;
  --muted: #5d6c7c;
  --line: #d7e1eb;
  --accent: #0f766e;
  --accent-strong: #1d4ed8;
  --accent-warm: #ea580c;
  --danger: #dc2626;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 280px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Inter, "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(29, 78, 216, 0.12), transparent 24%),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.1), transparent 22%),
    linear-gradient(180deg, #dbe7f4 0%, #eef3f8 18%, #f7f9fc 100%);
  color: var(--ink);
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

#app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100vh;
  width: 100vw;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 16px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(19, 28, 46, 0.94));
  color: #eef4fb;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(29, 78, 216, 0.85), rgba(15, 118, 110, 0.85));
  color: #fff;
  flex: 0 0 auto;
  box-shadow: 0 10px 24px rgba(29, 78, 216, 0.28);
}

.brand-copy h1 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand-copy p {
  margin: 4px 0 0;
  color: rgba(226, 232, 240, 0.74);
  font-size: 0.86rem;
  line-height: 1.35;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.board-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.board-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 10px 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: #f8fbff;
  text-align: left;
  transition: background 140ms ease, transform 140ms ease, border-color 140ms ease;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.board-row:hover {
  background: rgba(255, 255, 255, 0.1);
}

.board-row.active {
  background: linear-gradient(145deg, rgba(29, 78, 216, 0.42), rgba(15, 118, 110, 0.42));
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.board-index {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
  flex: 0 0 auto;
}

.board-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.board-meta strong {
  font-size: 0.92rem;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.board-meta span {
  font-size: 0.77rem;
  color: rgba(226, 232, 240, 0.68);
}

.board-actions {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(250, 252, 255, 0.92), rgba(244, 248, 252, 0.88));
  backdrop-filter: blur(12px);
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-right: 10px;
  border-right: 1px solid rgba(148, 163, 184, 0.28);
}

.toolbar-group:last-child {
  border-right: 0;
  padding-right: 0;
}

.tool-btn,
.icon-btn,
.text-btn,
.board-row,
.color-slot,
.sidebar-actions .icon-btn {
  border-radius: 10px;
}

.tool-btn,
.icon-btn,
.text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.tool-btn i,
.icon-btn i,
.sidebar-actions .icon-btn i {
  font-size: 1rem;
}

.tool-btn span {
  font-size: 0.92rem;
  letter-spacing: 0;
}

.tool-btn:hover,
.icon-btn:hover,
.text-btn:hover,
.color-picker:hover,
.toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(29, 78, 216, 0.34);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.tool-btn.active,
.icon-btn.active {
  background: linear-gradient(145deg, rgba(29, 78, 216, 0.13), rgba(15, 118, 110, 0.12));
  border-color: rgba(29, 78, 216, 0.34);
  color: #0f2f66;
}

.icon-btn.primary {
  background: linear-gradient(145deg, var(--accent-strong), #2563eb);
  color: #fff;
  border-color: transparent;
}

.icon-btn.danger {
  background: linear-gradient(145deg, #ef4444, var(--danger));
  color: #fff;
  border-color: transparent;
}

.icon-btn,
.text-btn {
  padding-inline: 10px;
}

.text-btn {
  min-height: 34px;
  background: transparent;
}

.colors {
  align-items: stretch;
}

.color-slot {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 2px solid transparent;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.14);
}

.color-slot.active {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.12);
}

.color-picker,
.range-group,
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
}

.color-picker span,
.range-group span,
.toggle span {
  font-size: 0.82rem;
  color: var(--muted);
}

.color-picker input[type="color"] {
  width: 34px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
}

.range-group input[type="range"] {
  width: 150px;
}

.range-group output {
  min-width: 2ch;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
  text-align: right;
}

.toggle input {
  accent-color: var(--accent-strong);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: rgba(226, 232, 240, 0.9);
  font-size: 0.9rem;
  font-weight: 600;
}

.canvas-shell {
  flex: 1;
  min-height: 0;
  padding: 12px;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.95)),
    repeating-linear-gradient(45deg, rgba(15, 23, 42, 0.015) 0, rgba(15, 23, 42, 0.015) 10px, rgba(15, 23, 42, 0.03) 10px, rgba(15, 23, 42, 0.03) 20px);
  box-shadow: var(--shadow);
  touch-action: none;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.text-editor-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.text-editor {
  position: absolute;
  min-width: 160px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(29, 78, 216, 0.34);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  color: var(--ink);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
  resize: both;
  outline: none;
  pointer-events: auto;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  font-size: 0.88rem;
}

.status-bar strong {
  color: var(--ink);
}

.status-label {
  display: inline-block;
  margin-right: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.canvas-shell,
.workspace,
.sidebar {
  min-width: 0;
  min-height: 0;
}

@media (max-width: 1080px) {
  body {
    overflow: auto;
  }

  #app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .board-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
  }

  .board-row {
    min-width: 220px;
  }

  .toolbar {
    gap: 8px;
  }

  .toolbar-group {
    padding-right: 0;
    border-right: 0;
  }

  .range-group input[type="range"] {
    width: 120px;
  }

  .canvas-shell {
    height: 62vh;
    min-height: 62vh;
  }
}

@media (max-width: 720px) {
  :root {
    --sidebar-width: 100%;
  }

  .brand-copy p {
    display: none;
  }

  .sidebar-actions {
    grid-template-columns: 1fr;
  }

  .tool-btn span,
  .text-btn,
  .panel-title .text-btn {
    font-size: 0.84rem;
  }

  .toolbar {
    padding: 10px;
  }

  .canvas-shell {
    padding: 10px;
    height: 58vh;
    min-height: 58vh;
  }

  .status-bar {
    gap: 10px;
    justify-content: flex-start;
  }
}
