.shell {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding-inline: 24px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(9, 9, 10, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: var(--header-height);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm);
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex: none;
}

.brand-name {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  transition: color var(--fast), background-color var(--fast);
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-link.is-active {
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 14px 0 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 500;
  transition: border-color var(--fast), background-color var(--fast), color var(--fast);
}

.user-chip:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}

.user-chip .avatar {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.user-chip[data-empty="true"] {
  padding-left: 14px;
  color: var(--muted);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  transition: background-color var(--fast), color var(--fast), border-color var(--fast);
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn--outline {
  border-color: var(--line);
}

.menu-toggle {
  display: none;
}

.mobile-menu {
  display: none;
  border-top: 1px solid var(--line-soft);
  padding: 8px 0 12px;
  background: var(--bg-elevated);
}

.mobile-menu.is-open {
  display: block;
}

.mobile-menu a,
.mobile-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 4px;
  color: var(--text-soft);
  font-size: 15px;
  text-align: left;
  border-radius: var(--radius-sm);
}

.mobile-menu a:hover,
.mobile-menu button:hover {
  color: var(--text);
}

.btn {
  position: relative;
  --btn-bg: transparent;
  --btn-border: transparent;
  --btn-color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius);
  background: var(--btn-bg);
  color: var(--btn-color);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--fast), border-color var(--fast), color var(--fast),
    transform var(--fast), opacity var(--fast);
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  --btn-bg: var(--accent-hover);
  --btn-border: var(--accent-hover);
}

.btn-primary:active:not(:disabled) {
  --btn-bg: var(--accent-active);
  --btn-border: var(--accent-active);
}

.btn-secondary {
  --btn-bg: var(--surface-2);
  --btn-border: var(--line);
  --btn-color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  --btn-bg: var(--surface-hover);
  --btn-border: var(--line-strong);
}

.btn-ghost {
  --btn-color: var(--text-soft);
}

.btn-ghost:hover:not(:disabled) {
  --btn-bg: var(--surface-2);
  --btn-color: var(--text);
}

.btn-danger {
  --btn-bg: var(--accent-soft);
  --btn-border: var(--accent-line);
  --btn-color: #ffd9d7;
}

.btn-danger:hover:not(:disabled) {
  --btn-bg: rgba(226, 59, 54, 0.22);
  --btn-border: var(--accent);
  --btn-color: #fff;
}

.btn-sm {
  height: 36px;
  padding: 0 14px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  height: 50px;
  padding: 0 24px;
  font-size: 15px;
  border-radius: var(--radius);
}

.btn-block {
  width: 100%;
}

.btn .icon {
  flex: none;
}

.btn-loading {
  position: relative;
  color: transparent !important;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 640ms linear infinite;
}

.btn-secondary.btn-loading::after,
.btn-ghost.btn-loading::after {
  border-color: rgba(255, 255, 255, 0.2);
  border-top-color: var(--text);
}

.icon {
  width: 18px;
  height: 18px;
  stroke-width: 1.7;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sm {
  width: 15px;
  height: 15px;
}

.icon-lg {
  width: 22px;
  height: 22px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 550;
  color: var(--text-soft);
}

.field-hint {
  font-size: 12.5px;
  color: var(--muted-2);
}

.field-hint strong {
  color: var(--muted);
  font-weight: 500;
}

.input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0d0d10;
  color: var(--text);
  font-size: 15px;
  transition: border-color var(--fast), box-shadow var(--fast), background-color var(--fast);
}

.input::placeholder {
  color: var(--muted-2);
}

.input:hover {
  border-color: var(--line-strong);
}

.input:focus {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: #0f0f12;
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.field-error {
  display: none;
  font-size: 12.5px;
  color: #ff8f8b;
}

.field-error.is-visible {
  display: block;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-row .input {
  flex: 1 1 auto;
  min-width: 0;
}

.input-row .btn {
  flex: none;
}

.tabbar {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}

.tabbar button {
  height: 38px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14px;
  font-weight: 550;
  transition: background-color var(--fast), color var(--fast), box-shadow var(--fast);
}

.tabbar button:hover {
  color: var(--text-soft);
}

.tabbar button[aria-selected="true"] {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-full);
  background: rgba(19, 19, 22, 0.75);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
}

.pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(62, 207, 142, 0.12);
}

.pill.is-idle .dot {
  background: var(--muted-2);
  box-shadow: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge--live {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: #ff9b97;
}

.badge--live .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s var(--ease) infinite;
}

.badge--soft {
  border-color: var(--line-soft);
  background: transparent;
  color: var(--muted-2);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  user-select: none;
}

.avatar--accent {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: #ffb4b1;
}

.avatar--lg {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

.divider {
  height: 1px;
  background: var(--line-soft);
}

.dot-sep {
  color: var(--muted-2);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 48px 24px;
  text-align: center;
}

.empty-state h3 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.empty-state p {
  max-width: 34ch;
  color: var(--muted);
  font-size: 14px;
}

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 440px);
  padding: 11px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--text);
  font-size: 14px;
  box-shadow: 0 16px 40px -18px rgba(0, 0, 0, 0.9);
  animation: toast-in 200ms var(--ease);
}

.toast[data-tone="error"] {
  border-color: rgba(239, 68, 68, 0.5);
  background: #2a1415;
}

.toast[data-tone="success"] {
  border-color: rgba(62, 207, 142, 0.4);
  background: #10231b;
}

.toast.is-leaving {
  animation: toast-out 160ms var(--ease) forwards;
}

.dialog {
  width: calc(100% - 32px);
  max-width: 420px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 40px 90px -40px #000;
}

.dialog::backdrop {
  background: rgba(4, 4, 5, 0.7);
  backdrop-filter: blur(3px);
}

.dialog[open] {
  animation: dialog-in 180ms var(--ease);
}

.dialog-body {
  padding: 24px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
}

.dialog-title {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.dialog-text {
  color: var(--muted);
  font-size: 14px;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.dialog-actions .btn {
  flex: 1;
}

.site-footer {
  margin-top: 64px;
  border-top: 1px solid var(--line-soft);
  padding: 26px 0 34px;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted-2);
  font-size: 13px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 18px;
}

.footer-links a:hover {
  color: var(--text-soft);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (max-width: 860px) {
  .shell {
    padding-inline: 18px;
  }

  .header-nav {
    display: none;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .header-inner {
    gap: 12px;
  }

  .user-chip {
    height: 36px;
    font-size: 13px;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

@media (max-width: 420px) {
  .user-chip .user-chip-label {
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand-name {
    font-size: 16px;
  }
}

.dialog-field {
  margin-top: 16px;
}
