/* Сцена во весь экран; сверху часы, слева снизу потребности, справа снизу дела, меню у пальца */
:root {
  --studio: #c8c5bf;
  --ink: #26221e;
  --muted: #6b655d;
  --card: #f6f5f2;
  --line: #e1ddd6;
  --accent: #df6a22;
  --accent-ink: #ffffff;
  --jacket: #4d6a48;
  --good: #4f9a5a;
  --ok: #d39a24;
  --bad: #c9472f;
  --shadow: 0 10px 30px rgba(46, 36, 26, 0.2);
  --f-body: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --f-display: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  color-scheme: light;
}
html, body { height: 100%; margin: 0; }
body {
  background: var(--studio);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

#stage { position: fixed; inset: 0; touch-action: none; }
#stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }

#tags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.tag {
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -100%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  white-space: nowrap; will-change: transform;
}
.tag .nm {
  font-weight: 700; font-size: 13px; padding: 3px 9px; border-radius: 999px;
  background: rgba(246, 245, 242, 0.92); box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.tag.me .nm { background: var(--accent); color: var(--accent-ink); }
.tag .st { font-size: 12px; font-weight: 600; color: var(--ink); background: rgba(246,245,242,.72); padding: 1px 7px; border-radius: 999px; }
.tag .st:empty { display: none; }

.top {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
  padding: 6px 6px 6px 14px;
  max-width: calc(100% - 24px);
}
.clock { display: flex; flex-direction: column; line-height: 1.05; min-width: 64px; }
.clock span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.clock b { font-family: var(--f-display); font-size: 19px; font-variant-numeric: tabular-nums; }
.speeds { display: flex; gap: 2px; background: var(--line); padding: 3px; border-radius: 12px; }
.speeds button {
  border: 0; background: transparent; width: 38px; height: 32px; border-radius: 9px; cursor: pointer;
  display: grid; place-items: center;
}
.speeds button svg { width: 18px; height: 18px; fill: var(--ink); }
.speeds button[aria-pressed="true"] { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.14); }
.invite {
  border: 0; border-radius: 11px; padding: 9px 12px; cursor: pointer;
  background: var(--jacket); color: #fff; font-weight: 700; font-size: 14px; white-space: nowrap;
}

.panel {
  position: fixed;
  left: max(12px, env(safe-area-inset-left, 0px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  width: min(270px, calc(100% - 24px));
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 9px;
}
.who { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.who b { font-family: var(--f-display); font-size: 17px; }
.mood { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.needs { display: flex; flex-direction: column; gap: 6px; }
.need { display: grid; grid-template-columns: 74px 1fr; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.need .bar { height: 9px; border-radius: 999px; background: var(--line); overflow: hidden; }
.need .bar i { display: block; height: 100%; border-radius: 999px; background: var(--good); transition: width .4s linear, background-color .4s; }
.need.ok .bar i { background: var(--ok); }
.need.bad .bar i { background: var(--bad); }

.queue {
  position: fixed;
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  display: flex; flex-direction: row-reverse; gap: 6px; flex-wrap: wrap-reverse; justify-content: flex-start;
  max-width: min(420px, calc(100% - 300px));
}
.qi {
  display: flex; align-items: center; gap: 4px;
  background: var(--card); border-radius: 13px; box-shadow: var(--shadow);
  padding: 4px 4px 4px 11px; font-size: 13.5px; font-weight: 600; position: relative; overflow: hidden;
}
.qi.now { background: #fff; outline: 2px solid var(--accent); }
.qi .pr { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); }
.qi .auto { font-size: 11px; color: var(--muted); font-weight: 700; }
.qi button {
  border: 0; background: var(--line); width: 26px; height: 26px; border-radius: 8px; cursor: pointer;
  font-size: 16px; line-height: 1; display: grid; place-items: center;
}

.menu {
  position: fixed; z-index: 5;
  background: var(--card); border-radius: 16px; box-shadow: 0 14px 40px rgba(46,36,26,.28);
  padding: 8px; display: flex; flex-direction: column; gap: 4px; min-width: 190px;
}
.menu .mh { font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 8px 2px; text-transform: uppercase; letter-spacing: .06em; }
.menu button {
  border: 0; background: transparent; text-align: left; padding: 10px 10px; border-radius: 10px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.menu button:hover, .menu button:active { background: var(--line); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0px) + 72px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center;
}
.conn {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: var(--bad); color: #fff; padding: 9px 14px; border-radius: 12px; font-weight: 700; font-size: 14px;
}

.join {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: rgba(200, 197, 191, 0.55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px));
}
.joincard {
  width: min(400px, 100%); background: var(--card); border-radius: 22px; box-shadow: var(--shadow);
  padding: 22px; display: flex; flex-direction: column; gap: 12px;
  -webkit-user-select: text; user-select: text;
}
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--jacket); }
.joincard h1 { margin: -6px 0 0; font-family: var(--f-display); font-size: 34px; }
.joincard p { margin: 0; line-height: 1.45; }
.joincard label, .joincard .lbl { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: -6px; }
.joincard input {
  font: inherit; font-size: 17px; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line);
  background: #fff; color: var(--ink);
}
.looks { display: flex; gap: 8px; flex-wrap: wrap; }
.looks button {
  width: 48px; height: 48px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; padding: 0;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.6);
}
.looks button[aria-checked="true"] { border-color: var(--accent); }
.primary {
  border: 0; border-radius: 14px; padding: 14px 18px; background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 17px; cursor: pointer; margin-top: 4px;
}
.primary:disabled { opacity: .55; }
.err { color: var(--bad); font-weight: 700; font-size: 14px; }

.tool {
  border: 0; border-radius: 11px; padding: 9px 12px; cursor: pointer;
  background: var(--line); color: var(--ink); font-weight: 700; font-size: 14px; white-space: nowrap;
}
.tool[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.catalog {
  position: fixed; left: 0; right: 0;
  bottom: 0;
  padding: 10px max(12px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 10px) max(12px, env(safe-area-inset-left, 0px));
  background: var(--card); box-shadow: 0 -8px 26px rgba(46,36,26,.16);
  border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column; gap: 8px;
}
.catalog .hint { margin: 0; font-size: 13px; color: var(--muted); }
.catalog .items { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.catalog .items button {
  flex: 0 0 auto; border: 0; border-radius: 14px; padding: 12px 14px; cursor: pointer;
  background: var(--line); font-weight: 700; font-size: 14px; white-space: nowrap;
}
.catalog .items button:active { background: var(--accent); color: var(--accent-ink); }

.tools {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 116px);
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 6px 6px 6px 14px;
  max-width: calc(100% - 24px);
}
.tools b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools button {
  border: 0; border-radius: 11px; padding: 9px 12px; cursor: pointer; background: var(--line);
  font-weight: 700; font-size: 14px; white-space: nowrap;
}
.tools button.danger { background: #f3d9d2; color: var(--bad); }
body.building .panel, body.building .queue { display: none; }

.narrow { display: none; }
@media (max-width: 640px) {
  .top { flex-wrap: wrap; justify-content: center; }
  .wide { display: none; }
  .narrow { display: inline; }
  .top .tool { padding: 9px 9px; font-size: 13px; }
  .top { padding-left: 10px; gap: 6px; }
  .speeds button { width: 32px; }
  .invite { padding: 9px 9px; font-size: 13px; }
  .panel { width: min(230px, calc(100% - 24px)); padding: 10px 12px; }
  .need { grid-template-columns: 64px 1fr; font-size: 12px; }
  .queue { max-width: calc(100% - 24px); bottom: calc(env(safe-area-inset-bottom, 0px) + 190px); }
}
@media (prefers-reduced-motion: reduce) { .need .bar i { transition: none; } }
