:root {
  --bg: #f4efe6;
  --paper: #fffaf1;
  --ink: #1f1a17;
  --muted: #6c6259;
  --line: rgba(31, 26, 23, 0.12);
  --panel: rgba(255, 250, 241, 0.84);
  --shadow: 0 20px 50px rgba(60, 43, 28, 0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  color: var(--ink);
  background: var(--bg);
  font-family: 'IBM Plex Mono', monospace;
  overflow: hidden;
}

button, input { font: inherit; }

button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  font-size: 0.82rem;
  white-space: nowrap;
  transition: background 140ms, color 140ms;
}

button:hover { border-color: rgba(31,26,23,0.28); }
button.is-active { background: var(--ink); color: var(--paper); }

.tool-key {
  display: inline-block;
  font-size: 0.68rem;
  opacity: 0.55;
  margin-right: 0.2rem;
  letter-spacing: 0;
}
button.is-active .tool-key { opacity: 0.75; }

/* ── Topbar ── */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  backdrop-filter: blur(18px);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex: none;
  margin-right: 0.5rem;
}

.brand-mark {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.45rem;
  background: linear-gradient(135deg, #2b2119, #a56b43);
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1;
}

.brand-name {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: 1rem;
  line-height: 1;
}

.brand-sub {
  margin: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  opacity: 0.5;
  line-height: 1.2;
}

.brand p {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: 1rem;
  line-height: 1;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex: 1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-left: auto;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 0.1rem;
  background: var(--paper);
}

.zoom-controls button {
  border: none;
  background: none;
  padding: 0.3rem 0.6rem;
  min-width: 2rem;
  text-align: center;
}

.zoom-controls [data-zoom-label] {
  font-size: 0.78rem;
  min-width: 3.2rem;
  text-align: center;
  color: var(--muted);
}

.file-button {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ── Canvas workspace ── */
.workspace {
  position: fixed;
  inset: 0;
  padding-top: 52px; /* topbar height */
}

.board-shell {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

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

/* ── Export dropdown ── */
.export-wrap {
  position: relative;
}

.export-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: var(--shadow);
  min-width: 11rem;
}

.export-menu[hidden] { display: none; }

.export-menu button {
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0.9rem;
  text-align: left;
  font-size: 0.82rem;
  width: 100%;
}

.export-menu button:last-child { border-bottom: none; }
.export-menu button:hover { background: var(--bg); }

/* ── Zoom HUD ── */
.zoom-hud {
  position: fixed;
  bottom: 1.1rem;
  right: 1.1rem;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.1rem;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.4rem;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(60,43,28,0.10);
}

.zoom-hud button {
  border: none;
  background: none;
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  font-size: 0.9rem;
  line-height: 1;
  min-width: 1.8rem;
  text-align: center;
}

.zoom-hud [data-zoom-label] {
  font-size: 0.74rem;
  color: var(--muted);
  min-width: 3rem;
  text-align: center;
  pointer-events: none;
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

/* ── Inline text input overlay ── */
.inline-text-input {
  position: fixed;
  transform: translate(-50%, -50%);
  z-index: 100;
  background: color-mix(in srgb, var(--paper) 96%, transparent);
  border: 1.5px solid #4a90d9;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  color: var(--ink);
  font-family: 'IBM Plex Mono', monospace;
  outline: none;
  min-width: 80px;
  box-shadow: 0 4px 16px rgba(74, 144, 217, 0.18);
}

/* ── Mobile ── */
@media (max-width: 720px) {
  .topbar { gap: 0.4rem; padding: 0.5rem 0.6rem; }
  .workspace { padding-top: 44px; }
  .hint { font-size: 0.65rem; bottom: 0.5rem; }
}
