:root {
  --ink: #1b1a17;
  --muted: #6f6a60;
  --line: #e4ded1;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --accent: #1b1a17;
  --danger: #c2283b;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 8px 24px rgba(40, 30, 10, .10);
  --radius: 14px;
  --paper: #f7f3ea;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #d9d3c6; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; font-size: 16px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px; background: #111;
  background-image: linear-gradient(135deg, transparent 48%, #e8407f 48%, #e8407f 64%, transparent 64%);
}
.brand-lg { font-size: 26px; }
.brand-lg .brand-mark { width: 30px; height: 30px; border-radius: 9px; }

/* ---------- login ---------- */
.login {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background:
    radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(60,45,20,.12) 100%),
    var(--paper);
}
.login-card {
  width: min(420px, 100%); background: #fffdf8; border: 1px solid var(--line);
  border-radius: 18px; padding: 32px; box-shadow: var(--shadow);
}
.login-sub { color: var(--muted); line-height: 1.5; margin: 10px 0 24px; }
.login label, .pw-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.login input, .pw-form input {
  display: block; width: 100%; margin-top: 6px; padding: 11px 12px; font: inherit; font-weight: 400;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); outline: none;
}
.login input:focus, .pw-form input:focus { border-color: #1b1a17; box-shadow: 0 0 0 3px rgba(27,26,23,.08); }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 0 0 8px; }
.login-note { font-size: 12.5px; color: var(--muted); line-height: 1.6; margin: 18px 0 0; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin: 0 4px 0 2px; vertical-align: -1px; }
.btn-primary {
  width: 100%; padding: 12px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600;
}
.btn-primary:hover { background: #33312b; }
.btn-primary:disabled { opacity: .6; cursor: default; }

/* ---------- board ---------- */
#app { position: fixed; inset: 0; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

.floating {
  position: absolute; z-index: 2; background: var(--panel); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.top-left { top: 14px; left: 14px; padding: 9px 14px; }
.top-right { top: 14px; right: 14px; }
.bottom-right { bottom: 14px; right: 14px; }
.bottom-left { bottom: 14px; left: 14px; }

.live { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; padding-left: 12px; border-left: 1px solid var(--line); font-size: 12px; font-weight: 500; color: var(--muted); }
.live i { width: 7px; height: 7px; border-radius: 50%; background: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.live.off i { background: #d97706; box-shadow: 0 0 0 3px rgba(217,119,6,.15); }

/* toolbar */
.toolbar {
  top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px; padding: 6px;
}
.tool {
  width: 38px; height: 38px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 10px;
}
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool:hover { background: rgba(27,26,23,.06); }
.tool.active { background: var(--accent); color: #fff; }
.tool.danger:hover { color: var(--danger); background: rgba(194,40,59,.08); }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; flex: none; }

.size { display: flex; align-items: center; gap: 8px; padding: 0 6px; }
.size-dot { width: 24px; height: 24px; display: grid; place-items: center; }
.size-dot::after { content: ""; width: var(--d, 4px); height: var(--d, 4px); max-width: 22px; max-height: 22px; border-radius: 50%; background: var(--me, #111); }
.size input { width: 96px; accent-color: #1b1a17; }

/* hamburger + drawer */
.burger {
  position: relative; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent;
  display: grid; place-items: center; margin-right: 2px;
}
.burger:hover, .burger[aria-expanded="true"] { background: rgba(27,26,23,.07); }
.burger svg, .icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.badge {
  position: absolute; top: 1px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: #16a34a; color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  box-shadow: 0 0 0 2px #fff;
}

.drawer {
  z-index: 3; top: 72px; right: 14px; width: min(330px, calc(100vw - 28px)); max-height: calc(100vh - 150px);
  background: #fffdf8; display: flex; flex-direction: column; padding: 14px 0 0; overflow: hidden;
  opacity: 0; transform: translateY(-8px) scale(.98); transform-origin: top right; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.drawer.open { opacity: 1; transform: none; pointer-events: auto; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 0 16px 8px; }
.drawer-title { font-weight: 700; font-size: 17px; }
.drawer-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.drawer-sub b { color: #16a34a; }
.icon-btn { width: 32px; height: 32px; border: 0; background: transparent; border-radius: 8px; display: grid; place-items: center; }
.icon-btn:hover { background: rgba(27,26,23,.07); }
.drawer-h {
  margin: 8px 16px 6px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  display: flex; justify-content: space-between; align-items: baseline;
}
.drawer-hint { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 11.5px; }

.people-list { list-style: none; margin: 0; padding: 0 8px; max-height: 42vh; overflow: auto; flex: none; }
.person {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; width: 100%;
  padding: 8px; border: 0; background: transparent; border-radius: 10px; text-align: left;
}
.person:hover { background: rgba(27,26,23,.05); }
.person .av {
  position: relative; width: 30px; height: 30px; border-radius: 50%; background: var(--c); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; text-transform: uppercase;
}
.person .av i { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: #cfc8b9; box-shadow: 0 0 0 2px #fffdf8; }
.person .av i.on { background: #16a34a; }
.person .who { min-width: 0; }
.person .nm { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .nm .you { color: var(--muted); font-weight: 400; font-size: 12px; }
.person .st { font-size: 12.5px; font-weight: 600; color: var(--c); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .st.quiet { color: var(--muted); font-weight: 500; }
.person .loc { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .av.busy { animation: busy 1.1s ease-in-out infinite; }
@keyframes busy { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 25%, transparent); } }
.person .loc .live-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--c); margin-right: 5px; vertical-align: 1px; animation: pulse 1.2s ease-in-out infinite; }
.person .go { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); font-size: 15px; }
.person:hover .go { background: var(--c); color: #fff; }
@keyframes pulse { 50% { opacity: .25; } }

.activity-list { list-style: none; margin: 0; padding: 0 8px 16px; overflow: auto; flex: 1; border-top: 1px solid var(--line); }
.activity-list li { display: flex; gap: 10px; padding: 8px; border-radius: 10px; font-size: 13px; line-height: 1.4; align-items: flex-start; }
.activity-list li.jump { cursor: pointer; }
.activity-list li.jump:hover { background: rgba(27,26,23,.05); }
.activity-list li.fresh { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: rgba(232,64,127,.12); } }
.activity-list .sw { width: 9px; height: 9px; margin: 5px 0 0; flex: none; }
.activity-list .txt { flex: 1; }
.activity-list .t { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.activity-empty { color: var(--muted); padding: 8px; font-size: 13px; }

/* account */
.account { padding: 5px; }
.account .burger { margin: 0; }
.account-head { display: flex; align-items: center; gap: 8px; }
.avatars { display: flex; padding-left: 6px; }
.avatars span {
  width: 24px; height: 24px; margin-left: -6px; border-radius: 50%; background: var(--c); color: #fff; font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center; text-transform: uppercase; box-shadow: 0 0 0 2px #fff;
}
.me-btn {
  width: 30px; height: 30px; border-radius: 50%; border: 0; color: #fff; font-size: 12px; font-weight: 700;
  background: var(--me, #111); text-transform: uppercase;
}
.menu { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 6px; display: grid; min-width: 190px; }
.menu button { text-align: left; border: 0; background: transparent; padding: 8px 8px; border-radius: 8px; font-size: 14px; }
.menu button:hover { background: rgba(27,26,23,.06); }

/* zoom */
.zoom { display: flex; align-items: center; padding: 5px; gap: 2px; }
.zoom button { min-width: 34px; height: 32px; border: 0; background: transparent; border-radius: 8px; font-weight: 500; padding: 0 8px; font-variant-numeric: tabular-nums; }
.zoom button:hover { background: rgba(27,26,23,.06); }
#zoomLabel { min-width: 74px; font-size: 13px; }

.hint { padding: 8px 12px; font-size: 12.5px; color: var(--muted); max-width: min(460px, calc(100vw - 28px)); }

.toast {
  position: fixed; left: 50%; bottom: 70px; transform: translate(-50%, 10px); z-index: 5;
  background: #1b1a17; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: rgba(30,25,15,.35); }
.modal-card { width: min(400px, 100%); background: #fff; border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.modal-card h2 { margin: 0 0 8px; font-size: 18px; }
.modal-card p { margin: 0 0 20px; color: var(--muted); line-height: 1.5; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn-ghost, .btn-danger { padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-weight: 600; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }

/* small screens */
@media (max-width: 760px) {
  .top-left { padding: 8px 10px; font-size: 14px; }
  .drawer { top: 64px; max-height: calc(100vh - 200px); }
  .top-left .live span { display: none; }
  .toolbar { top: auto; bottom: 14px; max-width: calc(100vw - 28px); overflow-x: auto; }
  .tool { width: 36px; height: 36px; }
  .size input { width: 70px; }
  .avatars { display: none; }
  .bottom-right { bottom: 72px; }
  .hint { display: none; }
}
