:root {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #0a1628;
  background: #0b1020;
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  --brand-midnight: #0b1020;
  --brand-graphite: #171b26;
  --brand-electric: #2e6bff;
  --brand-ice: #f5f8ff;
  --brand-steel: #98a2b3;
  --navy: var(--brand-midnight);
  --blue: var(--brand-electric);
  --green: #168a50;
  --red: #d93f4c;
  --muted: #667085;
  --page: #f4f7fb;
  --surface: #fff;
  --border: #e3e9f2;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --app-height: 100dvh;
  --header-height: calc(82px + var(--safe-top));
  --nav-height: calc(68px + var(--safe-bottom));
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--brand-midnight);
  scroll-padding-bottom: calc(var(--nav-height) + 24px);
}

body {
  min-width: 320px;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  background: var(--page);
  overscroll-behavior-y: none;
}

button,
input,
select,
textarea {
  max-width: 100%;
  min-width: 0;
  font: inherit;
}

button,
label,
select {
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand-electric) 55%, white);
  outline-offset: 2px;
}

.shell {
  width: 100%;
  max-width: 520px;
  min-height: var(--app-height);
  margin: 0 auto;
  background: var(--surface);
  box-shadow: 0 0 32px #00152a1a;
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--header-height);
  padding: calc(14px + var(--safe-top)) max(18px, var(--safe-right)) 12px max(18px, var(--safe-left));
  color: white;
  background: linear-gradient(135deg, var(--brand-midnight), var(--brand-graphite));
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  color: white;
  text-decoration: none;
}

.brand-mark {
  display: block;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  box-shadow: 0 5px 16px #0005;
}

.brand-wordmark {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .14em;
}

.brand-x {
  color: #5b86ff;
}

.sub {
  min-width: 0;
  margin-top: 2px;
  overflow: hidden;
  color: #d0d7e5;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view {
  width: 100%;
  min-width: 0;
  padding: 18px max(16px, var(--safe-right)) calc(var(--nav-height) + 24px) max(16px, var(--safe-left));
}

.card {
  width: 100%;
  min-width: 0;
  margin-bottom: 14px;
  padding: 16px;
  overflow-wrap: anywhere;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 8px 24px #10233c0d;
}

.card.compact {
  padding: 13px;
}

.hero {
  color: #fff;
  background: linear-gradient(145deg, var(--navy), color-mix(in srgb, var(--navy) 76%, var(--blue)));
  border: 0;
}

.login-hero {
  background: linear-gradient(145deg, var(--brand-midnight), #162f67);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 8px 0 12px;
}

.login-brand .brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 15px;
}

.login-brand .brand-wordmark {
  font-size: 25px;
}

.tag {
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .72;
}

.title {
  min-width: 0;
  margin: 6px 0;
  font-size: clamp(20px, 5.8vw, 24px);
  font-weight: 850;
  line-height: 1.16;
  overflow-wrap: anywhere;
}

.meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.hero .meta {
  color: #d6deec;
}

.small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.row > * {
  min-width: 0;
}

.between {
  justify-content: space-between;
}

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

.btn {
  min-width: 44px;
  min-height: 44px;
  padding: 11px 14px;
  color: #13233a;
  font-size: 15px;
  font-weight: 750;
  line-height: 1.2;
  cursor: pointer;
  background: #edf3fa;
  border: 0;
  border-radius: 13px;
  -webkit-tap-highlight-color: transparent;
}

.btn:disabled {
  cursor: wait;
  opacity: .58;
}

.btn.primary {
  color: #fff;
  background: var(--blue);
}

.btn.success,
.success {
  color: #fff;
  background: var(--green) !important;
}

.btn.danger {
  color: #fff;
  background: var(--red);
}

.btn.yes {
  flex: 1 1 0;
  color: #fff;
  background: var(--green);
}

.btn.no {
  flex: 1 1 0;
  color: #a82d38;
  background: #fff0f1;
}

.btn.reserve {
  color: #8a5900;
  background: #fff7e8;
}

.btn.icon {
  display: inline-grid;
  min-width: 44px;
  padding: 9px 11px;
  place-items: center;
}

.wide {
  width: 100%;
  margin-top: 8px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  margin: 7px 0 10px;
  padding: 12px 13px;
  color: #101828;
  font-size: 16px;
  background: #fff;
  border: 1px solid #d4deea;
  border-radius: 12px;
}

textarea {
  min-height: 96px;
  line-height: 1.4;
  resize: vertical;
}

input[type="checkbox"] {
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  margin: 0;
}

.empty {
  padding: 32px 10px;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

.status {
  padding: 8px 10px;
  font-size: 13px;
  background: #edf3fa;
  border-radius: 10px;
}

.status.yes {
  color: #126d40;
  background: #e9f9f0;
}

.status.reserve {
  color: #865600;
  background: #fff6e3;
}

.provider {
  width: 100%;
  margin-bottom: 8px;
  color: #fff;
  background: var(--brand-graphite);
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 12px;
}

.divider::before,
.divider::after {
  height: 1px;
  flex: 1;
  content: "";
  background: #e4eaf1;
}

.counts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.count {
  min-width: 0;
  padding: 10px 4px;
  text-align: center;
  background: #f5f8fc;
  border-radius: 12px;
}

.count b {
  display: block;
  font-size: 20px;
}

.count span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
}

.event {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.date {
  width: 52px;
  min-width: 52px;
  padding: 8px 3px;
  color: #0c61c9;
  text-align: center;
  background: #eef5ff;
  border-radius: 13px;
}

.date b {
  display: block;
  font-size: 20px;
}

.badge {
  display: inline-block;
  padding: 5px 8px;
  color: #0c61c9;
  font-size: 11px;
  font-weight: 750;
  background: #eef5ff;
  border-radius: 999px;
}

.nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: min(520px, 100%);
  min-height: var(--nav-height);
  padding: 5px max(4px, var(--safe-right)) max(5px, var(--safe-bottom)) max(4px, var(--safe-left));
  overflow: hidden;
  background: #fffffff7;
  border-top: 1px solid #dde5ef;
  box-shadow: 0 -10px 28px #0b10200f;
  transform: translateX(-50%);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.nav button {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 56px;
  padding: 5px 2px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  color: #667085;
  font-size: 10px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: none;
  border: 0;
  border-radius: 11px;
}

.nav button.active {
  color: var(--blue);
  font-weight: 800;
  background: color-mix(in srgb, var(--blue) 8%, white);
}

.nav-icon {
  min-height: 20px;
  font-size: 19px;
  font-weight: 850;
  line-height: 20px;
}

.nav-count,
.room-unread {
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  background: var(--red);
  border-radius: 999px;
  place-items: center;
}

.nav-count {
  position: absolute;
  top: 4px;
  right: calc(50% - 22px);
}

body.keyboard-open .nav {
  display: none !important;
}

body.keyboard-open .view {
  padding-bottom: 18px;
}

.section-title {
  margin: 18px 0 10px;
  font-size: 18px;
}

.actions {
  margin-top: 12px;
}

.lineup-unit {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #edf1f5;
}

.slot,
.line-slot {
  display: grid;
  grid-template-columns: minmax(72px, 90px) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 7px 0;
}

.line-slot select {
  margin: 0;
}

.notice.unread {
  background: #f7fbff;
  border-left: 4px solid var(--blue);
}

.person {
  margin-bottom: 8px;
}

.copybox {
  min-height: 96px;
  font-size: 14px;
  resize: none;
}

.attendance-item {
  display: flex;
  min-width: 0;
  padding: 10px 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid #edf1f5;
}

.attendance-item > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.attendance-item select {
  width: auto;
  max-width: 58%;
  margin: 0;
}

.chat-room {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.chat-screen {
  display: flex;
  height: calc(var(--app-height) - var(--header-height) - var(--nav-height) - 36px);
  min-height: 360px;
  flex-direction: column;
  overflow: hidden;
}

body.keyboard-open .chat-screen {
  height: calc(var(--app-height) - var(--header-height) - 18px);
  min-height: 0;
}

.chat-header {
  position: relative;
  z-index: 2;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  background: #fff;
}

.message-list {
  min-height: 0;
  max-height: none;
  padding: 4px 0 14px;
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1 1 auto;
  overscroll-behavior: contain;
  scroll-padding-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}

.message {
  max-width: 86%;
  margin: 8px 0;
  padding: 10px 12px;
  overflow-wrap: anywhere;
  background: #fff;
  border: 1px solid #e4eaf2;
  border-radius: 16px 16px 16px 5px;
}

.message.mine {
  margin-left: auto;
  background: #eef6ff;
  border-color: #cfe3ff;
  border-radius: 16px 16px 5px 16px;
}

.message-head {
  display: flex;
  min-width: 0;
  justify-content: space-between;
  gap: 10px;
  color: #627087;
  font-size: 11px;
}

.message-body {
  margin-top: 5px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: normal;
}

.chat-photo {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(360px, 52dvh);
  margin: 7px 0;
  object-fit: contain;
  background: var(--brand-midnight);
  border-radius: 12px;
}

.sticker {
  margin: 4px;
  font-size: 48px;
  line-height: 1.15;
}

.pin-label {
  margin-bottom: 5px;
  color: #7a5900;
  font-size: 10px;
}

.message-actions,
.reaction-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 7px;
}

.message-actions {
  opacity: .78;
}

.message-actions button,
.reaction-chip,
.sticker-tray button {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 10px;
  cursor: pointer;
  background: #edf3fa;
  border: 0;
  border-radius: 999px;
}

.sticker-tray {
  display: flex;
  min-height: 52px;
  padding: 4px 0;
  overflow-x: auto;
  flex: 0 0 auto;
  gap: 6px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.sticker-tray::-webkit-scrollbar {
  display: none;
}

.sticker-tray button {
  min-width: 44px;
  padding: 5px 8px;
  font-size: 20px;
}

.chat-compose {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  flex: 0 0 auto;
  gap: 7px;
  align-items: end;
  padding: 8px 0 max(8px, var(--safe-bottom));
  background: #fff;
  border-top: 1px solid #e5ebf2;
}

body.keyboard-open .chat-compose {
  padding-bottom: 6px;
}

.chat-compose textarea {
  min-height: 44px;
  max-height: 112px;
  margin: 0;
  resize: none;
}

.attach-btn {
  display: grid;
  width: 44px;
  height: 44px;
  font-size: 24px;
  cursor: pointer;
  background: #edf3fa;
  border-radius: 12px;
  place-items: center;
}

.toggle-row {
  display: flex;
  min-height: 52px;
  padding: 10px 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #edf1f5;
}

.toggle-row span span {
  display: block;
}

.score-line {
  display: flex;
  min-width: 0;
  margin-top: 10px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.score-line b,
.score-big {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: .02em;
}

.score-big {
  padding: 16px 0;
  text-align: center;
}

.protocol-player {
  display: flex;
  min-height: 48px;
  padding: 8px 0;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #edf1f5;
}

.minutes-input {
  width: 76px !important;
  min-height: 42px;
  margin: 0 !important;
  padding: 9px !important;
}

.protocol-event {
  background: #fbfdff;
  box-shadow: none;
}

.stats-summary {
  margin-bottom: 14px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.stat-grid > div {
  min-width: 0;
  padding: 9px;
  overflow-wrap: anywhere;
  background: #f5f8fc;
  border-radius: 11px;
}

.stat-grid b {
  display: block;
  margin-top: 3px;
  font-size: 18px;
}

.account-card {
  background: linear-gradient(145deg, #fbfcff, #f3f6fc);
}

.account-avatar {
  display: grid;
  width: 48px;
  min-width: 48px;
  height: 48px;
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  text-transform: uppercase;
  background: var(--brand-midnight);
  border-radius: 15px;
  place-items: center;
}

dialog.sheet {
  width: min(420px, calc(100% - 28px));
  max-width: 100%;
  margin: auto;
  padding: 20px;
  color: #101828;
  background: #fff;
  border: 0;
  border-radius: 22px;
  box-shadow: 0 24px 80px #0b102066;
}

dialog.sheet::backdrop {
  background: #0b102099;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 600px) {
  .shell {
    max-width: none;
    box-shadow: none;
  }

  dialog.sheet {
    width: 100%;
    margin: auto 0 0;
    padding: 20px max(18px, var(--safe-right)) calc(18px + var(--safe-bottom)) max(18px, var(--safe-left));
    border-radius: 24px 24px 0 0;
  }
}

@media (max-width: 370px) {
  .view {
    padding-right: max(12px, var(--safe-right));
    padding-left: max(12px, var(--safe-left));
  }

  .top {
    padding-right: max(14px, var(--safe-right));
    padding-left: max(14px, var(--safe-left));
  }

  .counts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .between {
    flex-wrap: wrap;
  }

  .message {
    max-width: 92%;
  }

  .chat-compose {
    grid-template-columns: 44px minmax(0, 1fr) auto;
  }

  .chat-compose .btn {
    padding: 8px 5px;
    font-size: 12px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav button {
    font-size: 9px;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  :root {
    --header-height: calc(58px + var(--safe-top));
  }

  .top {
    min-height: var(--header-height);
    padding-top: calc(8px + var(--safe-top));
    padding-bottom: 7px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .sub {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
