/* BeadMap — app shell styles (no external assets, offline safe) */

:root {
  --bg: #ded9cf;
  --surface: #f7f6f2;
  --surface-2: #efece5;
  --line: #d9d3c7;
  --line-strong: #b9b1a2;
  --ink: #23201b;
  --ink-2: #5d574d;
  --ink-3: #8b8478;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --danger: #b4432f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(35, 32, 27, .08), 0 8px 24px rgba(35, 32, 27, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --mono: "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

.app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  height: 100dvh;
  min-height: 100%;
  overflow: hidden;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: conic-gradient(from 45deg, #2f6f5e, #c9a227, #b4432f, #34618c, #2f6f5e);
  align-self: center;
}

.brand-name {
  font-weight: 700;
  letter-spacing: .01em;
  font-size: 15px;
}

.brand-sub {
  font-size: 12px;
  color: var(--ink-3);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.spacer { flex: 1; }

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover:not(:disabled) { background: #275c4e; }

.seg {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  padding: 7px 11px;
  cursor: pointer;
  color: var(--ink-2);
}

.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.is-active { background: var(--ink); color: #fff; }

.field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  background: #fff;
}

.field input[type="range"] { width: 96px; accent-color: var(--accent); }
.field output { font-family: var(--mono); font-size: 12px; min-width: 2ch; }

/* ---------- workspace ---------- */

.workspace {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 300px;
  min-height: 0;
  background: var(--bg);
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.panel-right { border-right: 0; border-left: 1px solid var(--line); }

.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.badge {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.panel-body {
  overflow: auto;
  padding: 10px;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.empty-hint {
  margin: 8px 4px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-3);
}

/* ---------- stage ---------- */

.stage {
  position: relative;
  min-height: 0;
  min-width: 0;
  background:
    radial-gradient(circle at 30% 20%, #e8e4da 0%, transparent 60%),
    var(--bg);
  overflow: hidden;
  touch-action: none;
}

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

#board:active { cursor: grabbing; }

.stage-hud {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
  pointer-events: none;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  background: rgba(247, 246, 242, .82);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  backdrop-filter: blur(6px);
}

.stage-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: none;
}

.stage-empty[hidden] { display: none; }

.empty-card {
  pointer-events: auto;
  max-width: 380px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 24px;
  box-shadow: var(--shadow);
}

.empty-card h3 { margin: 0 0 8px; font-size: 16px; }
.empty-card p { margin: 0 0 18px; font-size: 13px; line-height: 1.6; color: var(--ink-2); }

/* ---------- status bar ---------- */

.statusbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--surface);
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

#status-pos { font-family: var(--mono); color: var(--ink-3); }

/* ---------- mobile bottom tabs (hidden on desktop) ---------- */

.mobile-tabs {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 52px;
  z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.mobile-tab {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.mobile-tab[aria-expanded="true"] { color: var(--ink); background: var(--surface-2); }

.tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
}

.mobile-tab[aria-expanded="true"] .tab-dot { background: var(--accent); }

/* ---------- mobile ---------- */

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 220px minmax(0, 1fr) 260px; }
  .brand-sub { display: none; }
}

@media (max-width: 820px) {
  body { padding-bottom: 0; }

  .statusbar { display: none; }

  .workspace { margin-bottom: calc(52px + env(safe-area-inset-bottom)); }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px 10px;
  }

  .brand { gap: 6px; }

  .toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding-bottom: 2px;
    scrollbar-width: none;
    gap: 6px;
  }

  .toolbar::-webkit-scrollbar { display: none; }

  .btn { padding: 8px 10px; flex: 0 0 auto; }
  .seg, .field { flex: 0 0 auto; }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  /* both side panels become bottom sheets, opened from the tab bar */
  .panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 52px;
    top: auto;
    width: auto;
    max-height: 68dvh;
    display: flex;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -10px 30px rgba(35, 32, 27, .18);
    transform: translateY(calc(100% + 64px));
    transition: transform .24s cubic-bezier(.2, .8, .2, 1);
    z-index: 25;
  }

  .panel.is-open { transform: translateY(0); }
  .panel-left { display: flex; }
  .mobile-tabs { display: flex; }
  .statusbar { font-size: 11px; }
  .stage-empty { padding: 16px; }
  .empty-card { padding: 20px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
