/* ============================================================
   THE ARK — member app
   X-style design language: pure black, hairline dividers,
   pill buttons, bold condensed headers, sparse accent color.
   ============================================================ */

:root {
  --bg: #000000;
  --text: #e7e9ea;
  --text-2: #71767b;
  --text-3: #4d5156;
  --line: #2f3336;
  --line-soft: #1d2124;
  --accent: #4f88c4;        /* ark steel-navy, darkened tone on black */
  --accent-deep: #345f8c;
  --accent-dim: rgba(79, 136, 196, 0.13);
  --live: #f4212e;          /* X-style red for LIVE only */
  --ok: #00ba7c;            /* X green for success/points */
  --gold: #e2b93b;          /* captain tier */
  --white: #ffffff;
  --hover: rgba(231, 233, 234, 0.06);
  --press: rgba(231, 233, 234, 0.1);
  --sheet: #0a0c0e;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: var(--bg); }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: var(--font);
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: inherit;
}

img { max-width: 100%; }
svg { display: block; }

::selection { background: rgba(79, 136, 196, 0.35); }

/* ---------- app shell ---------- */

#app {
  display: flex;
  min-height: 100dvh;
  max-width: 1180px;
  margin: 0 auto;
}

/* desktop side rail (X-style) */
#rail {
  display: none;
  width: 256px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  padding: 12px 12px calc(20px + var(--sab));
  position: sticky;
  top: 0;
  height: 100dvh;
  flex-direction: column;
}

#rail .rail-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 20px;
}

#rail .rail-logo img { width: 34px; filter: brightness(0) invert(1); }
#rail .rail-logo span { font-weight: 800; font-size: 17px; letter-spacing: 0.06em; }

.rail-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  border-radius: 999px;
  font-size: 19px;
  font-weight: 500;
  color: var(--text);
  width: 100%;
  text-align: left;
  transition: background 0.12s;
  position: relative;
}
.rail-item:hover { background: var(--hover); }
.rail-item.active { font-weight: 800; }
.rail-item svg { width: 25px; height: 25px; }
.rail-item .nav-badge { left: 26px; top: 8px; }

.rail-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  transition: background 0.12s;
  width: 100%;
  text-align: left;
}
.rail-user:hover { background: var(--hover); }
.rail-user .avatar { width: 38px; height: 38px; font-size: 14px; }
.rail-user .ru-name { font-weight: 700; font-size: 14px; }
.rail-user .ru-sub { color: var(--text-2); font-size: 12px; }

#main {
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  min-height: 100dvh;
  padding-bottom: calc(64px + var(--sab));
  position: relative;
}

@media (min-width: 1024px) {
  #rail { display: flex; }
  #main { border-left: none; padding-bottom: 40px; }
  #tabbar { display: none !important; }
  #main { max-width: 660px; }
}
@media (max-width: 1023px) {
  #main { border-left: none; border-right: none; }
}

/* ---------- top bar ---------- */

#topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(0, 0, 0, 0.72);
  border-bottom: 1px solid var(--line-soft);
  padding-top: var(--sat);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 14px;
}

.topbar-row .tb-logo { width: 30px; filter: brightness(0) invert(1); }

.tb-title { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background 0.12s;
  position: relative;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 21px; height: 21px; }

.nav-badge {
  position: absolute;
  top: 5px;
  left: 20px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--accent-deep);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg);
}

/* ---------- avatars ---------- */

.avatar {
  border-radius: 999px;
  background: linear-gradient(135deg, #24384e, #345f8c);
  color: #dbe7f3;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  font-size: 13px;
  letter-spacing: 0.02em;
  user-select: none;
}
.avatar.k1 { background: linear-gradient(135deg, #2c4a33, #3f7a52); color: #d9f0e1; }
.avatar.k2 { background: linear-gradient(135deg, #4a3a22, #8a6a2f); color: #f2e6cd; }

/* ---------- buttons ---------- */

.btn {
  border-radius: 999px;
  font-weight: 700;
  padding: 9px 18px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: opacity 0.12s, background 0.12s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--white); color: #0f1419; }
.btn-primary:hover { opacity: 0.9; }
.btn-outline { border: 1px solid #536471; color: var(--text); }
.btn-outline:hover { background: var(--hover); }
.btn-accent { background: var(--accent-deep); color: #fff; }
.btn-accent:hover { opacity: 0.9; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; padding: 13px 18px; font-size: 15px; }
.btn[disabled] { opacity: 0.4; cursor: default; }

/* ---------- generic rows / feed ---------- */

.divider { height: 1px; background: var(--line); }
.divider-thick { height: 7px; background: #060708; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 18px 16px 10px;
}
.section-head h2 { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
.section-head .see-all { color: var(--accent); font-size: 13.5px; font-weight: 500; }
.section-head .see-all:hover { text-decoration: underline; }

.muted { color: var(--text-2); }
.small { font-size: 13px; }

/* ---------- live + status chips ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
}
.chip-live { background: rgba(244, 33, 46, 0.14); color: #ff6b74; }
.chip-live .dot { width: 6px; height: 6px; border-radius: 99px; background: var(--live); animation: pulse 1.4s ease-in-out infinite; }
.chip-next { background: var(--accent-dim); color: var(--accent); }
.chip-done { background: rgba(113, 118, 123, 0.15); color: var(--text-2); }
.chip-open { background: rgba(0, 186, 124, 0.12); color: #3ddba0; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

/* ---------- toasts ---------- */

#toasts {
  position: fixed;
  bottom: calc(76px + var(--sab));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(480px, calc(100vw - 28px));
  pointer-events: none;
}
@media (min-width: 1024px) { #toasts { bottom: 32px; } }

.toast {
  background: #16181c;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  gap: 11px;
  align-items: flex-start;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  animation: toast-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  pointer-events: auto;
  cursor: pointer;
}
.toast.leaving { animation: toast-out 0.25s ease forwards; }
.toast svg { width: 19px; height: 19px; flex-shrink: 0; margin-top: 1px; }
.toast .t-title { font-weight: 700; font-size: 13.5px; }
.toast .t-body { color: var(--text-2); font-size: 12.5px; margin-top: 1px; }

@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(0.97); } }

/* ---------- bottom tab bar ---------- */

#tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line-soft);
  display: flex;
  padding-bottom: var(--sab);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 0 7px;
  color: var(--text-2);
  position: relative;
  transition: color 0.15s;
}
.tab svg { width: 24px; height: 24px; }
.tab span { font-size: 10px; font-weight: 600; letter-spacing: 0.02em; }
.tab.active { color: var(--text); }
.tab .nav-badge { left: calc(50% + 4px); top: 4px; }

/* ---------- screens ---------- */

.screen { display: none; }
.screen.active { display: block; animation: screen-in 0.18s ease; }
@keyframes screen-in { from { opacity: 0; } to { opacity: 1; } }
