:root {
  --toolbar-height: 76px;
  --ink: #111111;
  --toolbar-bg: #55565a;
  --toolbar-line: rgba(255, 255, 255, 0.28);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background: #ffffff;
  color: #111111;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.memo-app {
  position: fixed;
  inset: 0 0 calc(var(--toolbar-height) + env(safe-area-inset-bottom)) 0;
  background: #ffffff;
}

.memo-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: #ffffff;
}

.memo-toolbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: calc(var(--toolbar-height) + env(safe-area-inset-bottom));
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--toolbar-bg);
}

.preset-panel {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
  gap: 14px;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom));
  background: #1f2025;
  color: #f2f2f7;
}

.preset-panel.open {
  display: flex;
}

.preset-panel__bar {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 36px;
  font-size: 20px;
}

.preset-list-view,
.preset-detail-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.preset-list-view[hidden],
.preset-detail-view[hidden] {
  display: none;
}

.preset-folder-item {
  width: 100%;
  min-height: 58px;
  border: 1px solid #3e414c;
  border-radius: 8px;
  background: #292b33;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 18px;
  font-weight: 800;
}

.preset-folder-item__chev {
  color: #8e8e93;
  font-size: 30px;
  line-height: 1;
}

.preset-add-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.preset-add-btn {
  min-height: 46px;
  border: 1px solid #3f424c;
  border-radius: 8px;
  background: #22242b;
  color: #8e8e93;
  font-size: 16px;
  font-weight: 800;
}

.preset-add-btn--composite {
  color: #9a8cff;
}

.prep-canvas {
  width: 100%;
  height: min(54vh, 520px);
  min-height: 280px;
  display: block;
  border: 1px solid #3c3f49;
  border-radius: 8px;
  background: #ffffff;
  touch-action: none;
}

.preset-back-btn {
  border: 0;
  background: transparent;
  color: #0a84ff;
  font-size: 20px;
  font-weight: 800;
  padding: 4px 0;
}

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

.preset-controls label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #b8bac3;
  font-size: 12px;
  font-weight: 700;
}

.preset-controls select {
  width: 100%;
  border: 1px solid #444751;
  border-radius: 8px;
  background: #2a2c34;
  color: #ffffff;
  font-size: 16px;
  padding: 10px;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  max-height: 190px;
  overflow: auto;
}

.slot-cell {
  aspect-ratio: 1.15;
  border: 1px solid #3e414c;
  border-radius: 8px;
  background: #292b33;
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
}

.slot-cell.active {
  border-color: #ffd60a;
  box-shadow: inset 0 0 0 2px #ffd60a;
}

.slot-cell.saved {
  background: #353842;
}

.preset-actions {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.preset-action {
  border: 1px solid #444751;
  border-radius: 8px;
  background: #2b2e38;
  color: #ffffff;
  min-height: 48px;
  font-size: 15px;
  font-weight: 800;
}

.preset-action.primary {
  background: #ffcc00;
  border-color: #ffcc00;
  color: #111111;
}

.preset-action.danger {
  color: #ff8b82;
}

.tool-btn,
.pen-size-btn {
  width: 48px;
  height: 48px;
  border: 1px solid var(--toolbar-line);
  border-radius: 999px;
  background: transparent;
  color: #ffffff;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.pen-size-btn {
  background: rgba(255, 255, 255, 0.12);
}

.palette {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--toolbar-line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.1);
}

.swatch {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 3px;
}

.swatch.active {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}
