:root {
  --bg: #2D2D2D;
  --bg-2: #262626;
  --yellow: #F7D049;
  --yellow-2: #FFD84D;
  --ink: #111111;
  --text: #FFFFFF;
  --muted: #B8B8B8;
  --line: #E6E6E6;
  --danger: #FF6B5B;
  --ok: #7BD88F;
  --wait: #FFB547;
  --off: #8E8E8E;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Montserrat', var(--font);
  --spring: cubic-bezier(.32, .72, 0, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button, a, input, select, textarea, label { touch-action: manipulation; }
button, .key { -webkit-user-select: none; user-select: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.loader {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  background: var(--bg); transition: opacity .25s;
}
.loader.overlay { background: rgba(45, 45, 45, .72); opacity: 0; pointer-events: none; }
.loader.overlay.on { opacity: 1; pointer-events: auto; }
.loader .bolt { width: 64px; height: auto; overflow: visible; }
.loader .bp { fill: var(--yellow); transform-box: fill-box; animation: bolt-run 1.1s cubic-bezier(.45, 0, .25, 1) infinite; }
.loader .bp2 { animation-delay: .16s; }
@keyframes bolt-run {
  0% { opacity: .15; transform: translateY(-40%); }
  35%, 60% { opacity: 1; transform: none; }
  100% { opacity: .15; transform: translateY(40%); }
}
@keyframes bolt-pulse { 50% { opacity: .35; } }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: clamp(48px, 7dvh, 58px); padding: 0 20px;
  border-radius: 12px; border: 3px solid var(--yellow);
  font-weight: 600; font-size: 16px; text-decoration: none;
  transition: transform .08s ease, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--yellow); color: var(--ink); }
.btn-outline { background: transparent; color: var(--yellow); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn + .btn { margin-top: clamp(8px, 1.5dvh, 12px); }

.form { padding: 0 28px; display: flex; flex-direction: column; gap: 14px; }
.field {
  width: 100%; height: 50px; padding: 0 14px;
  background: transparent; border: 1.5px solid var(--line); border-radius: 12px;
  color: var(--text); font-size: 16px; font-weight: 300; outline: none;
}
.field::placeholder { color: #DADADA; }
.field:focus { border-color: var(--yellow); }
textarea.field { height: clamp(64px, 11dvh, 96px); padding: 12px 14px; resize: none; line-height: 1.4; }
.label { font-size: 13px; color: var(--muted); margin: 4px 0 -6px; }

.key {
  height: clamp(50px, 8.5dvh, 68px); border-radius: 16px; border: 0; background: #3D3D3D; color: var(--text);
  font-family: var(--display); font-weight: 600; font-size: 28px;
}
.key:active { background: #4C4C4C; }
.key.fn { background: transparent; border: 2px solid #4A4A4A; color: var(--yellow); font-size: 22px; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  border: 1.5px solid currentColor; line-height: 1.3; white-space: nowrap;
}
.tag-busy { color: var(--ink); background: var(--yellow); border-color: var(--yellow); }
.tag-mine { color: var(--yellow); }
.tag-free { color: var(--ok); }
.tag-repair { color: var(--danger); }
.tag-wait { color: var(--wait); }
.tag-rejected { color: var(--off); }

.avatar-wrap { display: flex; align-items: center; gap: 18px; margin-bottom: 24px; }
.avatar {
  position: relative; width: 88px; height: 88px; border-radius: 50%; flex: none;
  background: #3D3D3D center/cover no-repeat; border: 3px solid var(--yellow);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 700; font-size: 30px; color: var(--yellow); padding: 0;
}
.avatar [data-placeholder] { display: flex; }
.avatar [data-placeholder] svg { width: 40px; height: 40px; }
.avatar .cam {
  position: absolute; right: -4px; bottom: -4px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--yellow); color: var(--ink); display: flex; align-items: center; justify-content: center;
}
.avatar-wrap .who { min-width: 0; }
.avatar-wrap .who b { display: block; font-size: 19px; font-weight: 600; overflow-wrap: anywhere; }
.avatar-wrap .who span { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 10px 0; }
.switch-row b { display: block; font-weight: 500; font-size: 15px; }
.switch-row small { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }
.switch-hit { display: flex; padding: 8px; margin: -8px; border-radius: 999px; cursor: pointer; flex: none; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; cursor: pointer;
  width: 50px; height: 30px; border-radius: 999px; background: #4A4A4A; position: relative; transition: background .2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; transition: transform .2s;
}
.switch:checked { background: var(--yellow); }
.switch:checked::after { transform: translateX(20px); background: var(--ink); }
.switch:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

.seg { display: flex; background: var(--bg); border: 1px solid #3A3A3A; border-radius: 12px; padding: 4px; }
.seg button { border: 0; background: none; color: var(--muted); padding: 8px 16px; border-radius: 9px; font-weight: 500; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--yellow); color: var(--ink); }
.seg-full { width: 100%; }
.seg-full button { flex: 1; }

.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 24px 0; }

.modal {
  position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b));
}
.modal-card {
  width: 100%; max-width: 460px; max-height: calc(100dvh - 32px); overflow-y: auto;
  background: var(--bg); border: 1px solid #3E3E3E; border-radius: 20px; padding: 24px;
}
.modal-card h2 { margin: 0 0 18px; font-size: 22px; font-weight: 500; }
.modal-card .form { padding: 0; }
.modal-lead { margin: -10px 0 16px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.modal-actions { display: flex; gap: 12px; margin-top: 18px; }
.modal-actions .btn { margin: 0; min-height: 50px; padding: 0 12px; white-space: nowrap; }
.confirm-card { max-width: 360px; text-align: center; }
.confirm-card h2 { margin-bottom: 10px; }
.confirm-card .modal-lead { margin: 0 0 4px; }

#toast {
  position: fixed; left: 50%; top: calc(10px + var(--safe-t)); z-index: 60;
  transform: translate(-50%, calc(-100% - 24px - var(--safe-t)));
  width: max-content; max-width: min(440px, calc(100% - 24px));
  display: flex; align-items: center; gap: 12px; padding: 12px 18px 12px 12px; border-radius: 22px;
  background: #1B1B1B; color: var(--text); border: 1px solid #3A3A3A;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .35);
  font-size: 15px; font-weight: 500; line-height: 1.35;
  opacity: 0; pointer-events: none; cursor: pointer;
  transition: transform .45s var(--spring), opacity .25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-ic {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--yellow); color: var(--ink);
}
.toast-ic svg { width: 17px; height: 17px; }
#toast.error .toast-ic { background: var(--danger); color: #fff; }
.toast-msg { min-width: 0; overflow-wrap: anywhere; }

@keyframes page-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.page-enter > :not(.tabbar):not(.desk-side):not(.desk-burger):not(.desk-scrim) {
  animation: page-in .34s cubic-bezier(.2, .8, .2, 1) both;
}
.page-enter > :nth-child(2) { animation-delay: .03s; }
.page-enter > :nth-child(3) { animation-delay: .06s; }
.page-enter > :nth-child(n+4) { animation-delay: .09s; }
.modal { animation: fade-in .2s ease both; }
.modal-card { animation: pop-in .26s cubic-bezier(.2, .8, .2, 1) both; }

@media (prefers-reduced-motion: reduce) {
  .page-enter > *, .page-enter .sheet > *, .modal, .modal-card { animation: none !important; }
  #toast { transition: opacity .2s; }
  .loader .bp { animation: bolt-pulse 1.4s ease-in-out infinite; }
}
