:root {
  --bg: #f4f5f7;
  --toolbar-bg: #ffffff;
  --border: #d8dce3;
  --ink: #1b1f27;
  --accent: #1971c2;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 8px 12px;
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-group.hidden { display: none; }

.tool-btn {
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}

.tool-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(25, 113, 194, .2);
}

.shape-btn {
  width: 36px;
  height: 36px;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}

.shape-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.db-text-editor {
  position: absolute;
  min-width: 120px;
  min-height: 1.4em;
  padding: 2px 4px;
  border: 1px dashed var(--accent);
  background: rgba(255, 255, 255, .85);
  outline: none;
  resize: both;
  font-family: -apple-system, Arial, sans-serif;
  line-height: 1.25;
  z-index: 5;
}

#zoomOutBtn, #zoomResetBtn, #zoomInBtn,
#pagePrevBtn, #pageNextBtn, #pageAddBtn, #pageDuplicateBtn, #pageDeleteBtn {
  height: 36px;
  min-width: 36px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: .95rem;
}

#pagePrevBtn:disabled, #pageNextBtn:disabled, #pageDeleteBtn:disabled {
  opacity: .4;
  cursor: default;
}

.page-indicator {
  font-size: .8rem;
  color: #555;
  min-width: 48px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.swatches { gap: 6px; }

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
  padding: 0;
}

.swatch.active { box-shadow: 0 0 0 2px var(--accent); }

#colorPicker {
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  cursor: pointer;
}

.size-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  color: #555;
}

.actions { margin-left: auto; }

.actions button {
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: .85rem;
}

.actions button:disabled {
  opacity: .4;
  cursor: default;
}

.practice-box { max-width: 420px; text-align: left; }

.practice-input {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  margin: 8px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 1rem;
  box-sizing: border-box;
}

.practice-hint {
  font-size: .78rem;
  color: #777;
  margin: 4px 0 0;
}

#canvasWrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  touch-action: none;
}

#board {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #ffffff;
  display: block;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden { display: none; }

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 20px 24px;
  max-width: 320px;
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

.modal-actions button {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
}

#confirmClearYes {
  background: #e03131;
  color: #fff;
  border-color: #e03131;
}

@media (max-width: 600px) {
  #toolbar { gap: 8px; padding: 6px 8px; }
  .tool-btn { width: 36px; height: 36px; }
  .size-control span { display: none; }
}
