/* =====================================================================
 * Issuon mini-app — OLED-dark design system (Inter, GitHub/Linear-grade).
 * Mobile-first. CSS variables are theme-aware (Telegram themeParams map onto them).
 * =================================================================== */
:root {
  /* surfaces (deep → elevated) */
  --bg: #0b0f17;
  --bg-1: #11161f;
  --bg-2: #161c26;
  --bg-3: #1f2733;
  --bg-hover: #232c39;
  --border: #222b38;
  --border-2: #2c3744;
  /* text */
  --text: #e9eef5;
  --muted: #8b97a7;
  --faint: #5b6675;
  /* accents */
  --accent: #4493f8;
  --accent-weak: rgba(68, 147, 248, 0.16);
  --green: #2ea043;
  --green-2: #3fb950;
  --green-weak: rgba(63, 185, 80, 0.16);
  --purple: #a371f7;
  --purple-weak: rgba(163, 113, 247, 0.16);
  --danger: #f85149;
  --warn: #d29922;
  /* shape & motion */
  --r-sm: 9px; --r: 13px; --r-lg: 18px; --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(0,0,0,0.3);
  --sh-2: 0 8px 28px rgba(0,0,0,0.5);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --fonts: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--fonts);
  font-size: 15px; line-height: 1.5; letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico { width: 20px; height: 20px; display: block; flex: none; }

.app { min-height: 100dvh; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar__title {
  flex: 1; min-width: 0; font-weight: 650; font-size: 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar__right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; flex: none;
  border: 1px solid var(--border-2); background: var(--bg-2);
  border-radius: var(--r-sm); cursor: pointer; color: var(--text);
  transition: background 0.15s var(--ease), transform 0.12s var(--ease), border-color 0.15s var(--ease);
}
.icon-btn:hover { background: var(--bg-3); }
.icon-btn:active { transform: scale(0.92); background: var(--bg-hover); }
.icon-btn--accent { background: var(--green); border-color: transparent; color: #fff; }
.icon-btn--accent:hover { background: var(--green-2); }
.icon-btn--danger { color: #ff7b72; }

.repo-pill {
  display: inline-flex; align-items: center; gap: 7px; max-width: 44vw; height: 40px;
  padding: 0 12px; border: 1px solid var(--border-2); background: var(--bg-2);
  border-radius: var(--r-pill); cursor: pointer; color: var(--text);
  transition: background 0.15s var(--ease), transform 0.12s var(--ease);
}
.repo-pill:active { transform: scale(0.96); background: var(--bg-3); }
.repo-pill .ico { width: 16px; height: 16px; color: var(--muted); }
.repo-pill__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; font-weight: 550; }

/* ---- layout ---- */
.screen { min-height: 100dvh; display: flex; flex-direction: column; }
.body { padding: 14px 14px calc(28px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 14px; }
.toolbar { display: flex; flex-direction: column; gap: 10px; }

.center { min-height: 72vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 28px; text-align: center; }
.center--pad { min-height: 130px; }
.muted { color: var(--muted); }
.hint { font-size: 12.5px; line-height: 1.5; margin: 0; }

/* ---- spinner / skeleton ---- */
.spinner { width: 26px; height: 26px; border: 2.5px solid var(--bg-3); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { position: relative; overflow: hidden; background: var(--bg-2); border-radius: var(--r); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--bg-3) 80%, transparent), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.sk-row { height: 70px; }

/* ---- empty ---- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 44px 18px; text-align: center; }
.empty__icon { font-size: 46px; filter: saturate(0.9); }
.empty__title { font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.empty__sub { color: var(--muted); max-width: 440px; line-height: 1.55; }

/* ---- inputs ---- */
.input {
  width: 100%; min-height: 44px; padding: 11px 13px; background: var(--bg-2);
  border: 1px solid var(--border-2); border-radius: var(--r-sm); outline: none; color: var(--text);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
textarea.input { resize: vertical; min-height: 44px; line-height: 1.55; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 19px) 19px, calc(100% - 14px) 19px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.title-input { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; overflow: hidden; }
.search-wrap { display: flex; gap: 8px; }
.search-wrap .input { flex: 1; }

/* ---- segmented tabs ---- */
.tabs { display: flex; gap: 4px; background: var(--bg-1); padding: 4px; border-radius: var(--r); border: 1px solid var(--border); }
.tab { flex: 1; padding: 9px 6px; border: 0; background: transparent; color: var(--muted); border-radius: var(--r-sm); cursor: pointer; font-weight: 600; font-size: 13.5px; transition: all 0.18s var(--ease); }
.tab--active { background: var(--bg-3); color: var(--text); box-shadow: var(--sh-1); }

/* ---- chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips--select { padding: 2px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px;
  border: 1px solid var(--border-2); background: var(--bg-2); color: var(--text);
  border-radius: var(--r-pill); cursor: pointer; font-size: 13px; font-weight: 550;
  transition: all 0.15s var(--ease);
}
.chip:active { transform: scale(0.95); }
.chip--active { border-color: var(--accent); background: var(--accent-weak); color: #cfe2ff; }
.chip__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: 0 0 6px currentColor; }

/* ---- lists / rows ---- */
.list { display: flex; flex-direction: column; gap: 10px; }
.issue-row, .repo-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r); cursor: pointer; color: var(--text);
  transition: background 0.15s var(--ease), transform 0.12s var(--ease), border-color 0.15s var(--ease);
}
.issue-row:hover, .repo-row:hover { background: var(--bg-3); border-color: var(--border-2); }
.issue-row:active, .repo-row:active { transform: scale(0.985); }
.issue-row__main, .repo-row__main { flex: 1; min-width: 0; }
.issue-row__title { font-weight: 600; letter-spacing: -0.01em; }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: none; margin-top: 6px; align-self: flex-start; }
.dot--open { background: var(--green-2); box-shadow: 0 0 8px var(--green-weak); }
.dot--closed { background: var(--purple); box-shadow: 0 0 8px var(--purple-weak); }
.row-meta { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.row-meta__item { display: inline-flex; align-items: center; gap: 4px; }
.row-meta__item .ico { width: 14px; height: 14px; }
.lbls { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.lbl { font-size: 11px; padding: 2px 9px; border: 1px solid; border-radius: var(--r-pill); color: var(--text); opacity: 0.95; font-weight: 550; }
.chev { color: var(--faint); flex: none; }
.chev .ico { width: 18px; height: 18px; }

.repo-row__name { font-weight: 650; display: flex; gap: 7px; align-items: center; }
.repo-row__name .ico { width: 16px; height: 16px; color: var(--muted); }
.repo-row__desc { color: var(--muted); font-size: 12.5px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62vw; }
.repo-row--active { border-color: var(--accent); background: var(--accent-weak); }
.repo-row__meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.badge { font-size: 11px; color: var(--muted); border: 1px solid var(--border-2); border-radius: 7px; padding: 2px 8px; font-variant-numeric: tabular-nums; }
.badge--ok { color: var(--green-2); border-color: var(--green-2); }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 11px 17px; border: 1px solid var(--border-2); background: var(--bg-2); color: var(--text); border-radius: var(--r-sm); cursor: pointer; font-weight: 600; letter-spacing: -0.01em; transition: background 0.15s var(--ease), transform 0.1s var(--ease), filter 0.15s var(--ease); }
.btn .ico { width: 18px; height: 18px; }
.btn:hover { background: var(--bg-3); }
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--green); border-color: transparent; color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset, var(--sh-1); }
.btn--primary:hover { background: var(--green-2); }
.btn--ghost { background: var(--bg-2); }
.btn--danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn--block { width: 100%; }
.btn:disabled, .btn.is-busy { opacity: 0.55; pointer-events: none; }
.btn.is-busy::after { content: ""; width: 15px; height: 15px; margin-left: 4px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }

/* ---- fields / detail ---- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field__label { font-size: 12px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }
.issue-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.state-badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 13px; padding: 5px 12px; border-radius: var(--r-pill); }
.state-badge .sb-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; }
.state-badge--open { background: var(--green-weak); color: var(--green-2); }
.state-badge--closed { background: var(--purple-weak); color: #d2b8ff; }

.section { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 4px; display: flex; flex-direction: column; gap: 10px; }
.section__title { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.section__title .ico { width: 18px; height: 18px; color: var(--muted); }
.comment { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px; }
.comment__head { font-size: 12.5px; color: var(--accent); font-weight: 600; margin-bottom: 5px; }
.comment__body { white-space: pre-wrap; word-break: break-word; line-height: 1.55; }
.add-row { display: flex; flex-direction: column; gap: 8px; }
.sub-row { display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 4px 4px 4px 12px; }
.sub-row__open { flex: 1; text-align: left; background: transparent; border: 0; color: var(--text); cursor: pointer; padding: 9px 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.sub-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sub-actions .btn { flex: 1; }

/* ---- users / switch ---- */
.user-row { display: flex; align-items: center; gap: 12px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; }
.user-row__main { flex: 1; min-width: 0; }
.user-row__name { font-weight: 600; }
.user-row__sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.user-row__actions { display: flex; gap: 8px; }
.switch { display: flex; align-items: center; gap: 12px; }
.switch input { width: 22px; height: 22px; accent-color: var(--green-2); }

/* ---- toast ---- */
.toast-layer { position: fixed; left: 0; right: 0; bottom: calc(18px + var(--safe-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 80; pointer-events: none; }
.toast { max-width: 88vw; padding: 12px 17px; background: color-mix(in srgb, var(--bg-3) 92%, transparent); backdrop-filter: blur(12px); border: 1px solid var(--border-2); border-radius: var(--r); box-shadow: var(--sh-2); transform: translateY(18px) scale(0.96); opacity: 0; transition: all 0.28s var(--ease); font-size: 14px; font-weight: 550; }
.toast--in { transform: translateY(0) scale(1); opacity: 1; }
.toast--error { border-color: var(--danger); }
.toast--success { border-color: var(--green-2); }

/* ---- modal / sheet ---- */
.modal-layer:empty { display: none; }
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(2px); display: flex; align-items: flex-end; justify-content: center; z-index: 70; animation: fade 0.2s var(--ease); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet { width: 100%; max-width: 560px; background: var(--bg-1); border: 1px solid var(--border-2); border-bottom: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 90vh; display: flex; flex-direction: column; animation: slideUp 0.3s var(--ease); }
.sheet::before { content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 38px; height: 4px; border-radius: 2px; background: var(--border-2); }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0.4; } to { transform: translateY(0); opacity: 1; } }
.sheet__head { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 14px; border-bottom: 1px solid var(--border); }
.sheet__title { font-weight: 700; font-size: 16.5px; letter-spacing: -0.02em; }
.sheet__body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 11px; }
.sheet__actions { display: flex; gap: 8px; padding: 12px 16px calc(16px + var(--safe-bottom)); border-top: 1px solid var(--border); }
.sheet__actions .btn { flex: 1; }

/* ---- menu / workspaces ---- */
.menu-who { padding: 2px 2px 14px; border-bottom: 1px solid var(--border); }
.menu-who__name { font-weight: 700; font-size: 16px; }
.menu-who__sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.menu-list { display: flex; flex-direction: column; gap: 2px; padding-top: 10px; }
.menu-item { display: flex; align-items: center; gap: 13px; padding: 13px 10px; background: transparent; border: 0; color: var(--text); cursor: pointer; text-align: left; border-radius: var(--r-sm); font-size: 15px; font-weight: 550; transition: background 0.15s var(--ease); }
.menu-item:hover { background: var(--bg-2); }
.menu-item:active { background: var(--bg-3); }
.menu-item__ic { width: 24px; display: inline-flex; justify-content: center; color: var(--muted); }
.menu-item__ic .ico { width: 20px; height: 20px; }
.ws-row { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 13px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm); cursor: pointer; color: var(--text); }
.ws-row--active { border-color: var(--accent); background: var(--accent-weak); }
.ws-row__name { font-weight: 600; }
.ws-row__role { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---- gate diagnostic ---- */
.gate-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.diag-wrap { margin-top: 20px; width: 100%; max-width: 460px; text-align: left; }
.diag-wrap summary { color: var(--muted); font-size: 12px; cursor: pointer; }
.diag { white-space: pre-wrap; word-break: break-all; font-size: 11px; color: var(--muted); background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px; margin-top: 8px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ---- favorites (repo picker) ---- */
.body { padding-bottom: calc(84px + var(--safe-bottom)); } /* room for the floating button */
.repo-row { padding: 0; cursor: default; overflow: hidden; align-items: stretch; }
.repo-row:active { transform: none; }
.repo-row__btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 14px; background: transparent; border: 0; color: var(--text); cursor: pointer; text-align: left; font: inherit; }
.repo-row__btn:active { transform: scale(0.99); }
.fav-btn { flex: none; width: 48px; display: flex; align-items: center; justify-content: center; background: transparent; border: 0; border-left: 1px solid var(--border); color: var(--faint); cursor: pointer; transition: color 0.15s var(--ease), transform 0.12s var(--ease); }
.fav-btn:hover { color: var(--muted); }
.fav-btn:active { transform: scale(0.88); }
.fav-btn--on { color: #e3b341; }
.fav-btn .ico { width: 20px; height: 20px; }

/* ---- floating action button (activity feed) ---- */
.fab { position: fixed; right: 16px; bottom: calc(18px + var(--safe-bottom)); z-index: 40; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: var(--sh-2); cursor: pointer; transition: transform 0.12s var(--ease), filter 0.15s var(--ease); }
.fab:hover { filter: brightness(1.08); }
.fab:active { transform: scale(0.92); }
.fab .ico { width: 24px; height: 24px; }

/* ---- event rows (activity feed) ---- */
.event-row { display: flex; align-items: flex-start; gap: 11px; padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r); color: var(--text); }
a.event-row:hover { background: var(--bg-3); border-color: var(--border-2); }
.event-row__avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; background: var(--bg-3); object-fit: cover; }
.event-row__ic { width: 34px; height: 34px; flex: none; display: flex; align-items: center; justify-content: center; background: var(--bg-3); border-radius: 50%; font-size: 16px; }
.event-row__main { flex: 1; min-width: 0; }
.event-row__title { line-height: 1.4; word-break: break-word; }
.event-row__type { opacity: 0.85; margin-right: 2px; }
.event-row__time { color: var(--faint); font-size: 12px; margin-top: 3px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
