/* Shared surfaces and system theme. This file also owns phone layouts. */
:root {
  color-scheme: light;
  --surface: #ffffff;
  --surface-soft: #f3f5fa;
  --input: #ffffff;
  --accent-soft: #edf1ff;
  --muted: #647187;
  --line: #e5e9f0;
  --blue: #3158e5;
  --ink: #222f42;
  --bg: #f7f8fa;
}
.sidebar,.topbar,.panel,.stat,.idea-card,.gate,dialog,.btn,.search {
  background: var(--surface);
}
.btn.primary {background: var(--blue);color:#fff}
.field input,.field textarea,.field select,.skill-row select {
  background:var(--input);color:var(--ink);border-color:var(--line);
}
.search {color:var(--ink)}
.sub,.meta,.stat-top,.stat-note,.field,.panel-foot,.event-card p,.idea-card p,
.profile-card p,.gate p,.footer,.breadcrumb,.eyebrow,.side-caption,.nav button,
.tabs button,.rank-num,.rank-points small,.table th,.date-box small,.skill-row .check {
  color:var(--muted);
}
.quarter,.date-box,.table th,.mini-count {background:var(--surface-soft)}
.nav button.active,.tabs button.active,.rank-row.me,.table tr.current {background:var(--accent-soft);color:var(--blue)}
.nav button:hover {background:var(--surface-soft)}
.idea-row,.table td,.skill-row,.modal-header,.panel-foot,.rank-divider,.divider {border-color:var(--line)}
.access-gate {max-width:400px;padding:28px;box-shadow:none}
.access-gate h1 {font-size:22px;font-weight:600;line-height:1.4;margin:0}
.gate-wrap {min-height:100svh;background:var(--bg)}
button,a,input,select,textarea {-webkit-tap-highlight-color:transparent}
:focus-visible {outline:2px solid var(--blue);outline-offset:3px}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg:#10141d;
    --surface:#1a202c;
    --surface-soft:#232c3b;
    --input:#141b27;
    --ink:#edf1f8;
    --muted:#a5b0c4;
    --line:#303b4e;
    --blue:#8faaff;
    --accent-soft:#283658;
    --green:#7dd6b3;
  }
  .btn {border-color:var(--line)}
  .btn.primary {background:#476de5;color:#fff;box-shadow:none}
  .hero {background:linear-gradient(110deg,#232943,#29243a);border-color:#3b3d59}
  .hero p {color:#bbc1d6}
  .hero .eyebrow {color:#b4acd6}
  .orb {background:linear-gradient(145deg,#4c416b,#2c304b);border-color:#655a83;box-shadow:8px 12px 24px #05091140}
  .orbit {border-color:#655a83}
  .hero-pill {background:#343b51;color:#d4d8ec}
  .spark {color:#b5a3eb}
  .avatar,.stat-icon {background:#2b3553;color:#b0c0f9}
  .avatar.orange {background:#49372e;color:#ffc08f}
  .idea-icon {background:#362d4c;color:#c0a9ec}
  .badge {background:#303a4c;color:#c0cada}
  .badge.blue {background:#293a59;color:#b0c9ff}
  .badge.green {background:#213e36;color:#8bdfba}
  .badge.red {background:#482e36;color:#ffb0ad}
  .badge.orange {background:#453a2c;color:#efc487}
  .badge.purple {background:#39304f;color:#cbb3f4}
  .community-box {background:#252a40;border-color:var(--line)}
  .quarter,.mini-count,.breadcrumb b {color:var(--muted);border-color:var(--line)}
  .info-note {background:#24304a;color:#bac9ed;border-color:#3b4c6c}
  .demo-bar {background:#322b22;border-color:#4f4434;color:#e5c492}
  .demo-bar select {background:#28241e;border-color:#665239;color:#edcf9a}
  .event-card,.events-list .event-card {background:var(--surface);border-color:var(--line)}
  .gate details {color:var(--muted);border-color:var(--line)}
  .form-error {color:#ffafaf}
  .idea-card:hover {border-color:#738ac3}
  dialog {border-color:var(--line)}
  dialog::backdrop {background:#050810b3}
  #toast {background:#e3eaf7;color:#192234}
  #toast.error {background:#f2b1b1;color:#431d24}
}
@media (max-width:760px) {
  :root {--bottom-nav-height:76px}
  body {font-size:15px}
  .topbar {height:64px;position:sticky;top:0;z-index:10;padding:0 18px}
  .top-right {gap:16px}
  .notification {min-width:44px;min-height:44px;align-items:center;justify-content:center}
  .notification i {top:10px;right:10px}
  .content {padding:22px 16px calc(var(--bottom-nav-height) + 30px + env(safe-area-inset-bottom))}
  .page-head {display:flex;flex-direction:column;align-items:stretch;gap:16px;margin-bottom:20px}
  .page-head h1 {font-size:27px;letter-spacing:-.8px;line-height:1.2;margin:0 0 9px;overflow-wrap:anywhere}
  .page-head .eyebrow {display:none}
  .page-head .sub {font-size:14px;max-width:none;line-height:1.6}
  .page-head>.btn {width:100%;min-height:48px;font-size:14px;border-radius:12px}
  .btn {min-height:44px;font-size:14px;padding:11px 16px;border-radius:10px}
  .text-btn {min-height:44px;font-size:13px}
  .hero {padding:22px;min-height:0;border-radius:16px}
  .hero>div:first-child {max-width:100%;width:100%}
  .hero h2 {font-size:23px;line-height:1.25;max-width:100%}
  .hero p {font-size:14px;line-height:1.6;max-width:100%;padding:0}
  .hero br {display:none}
  .hero-art {display:none}
  .hero .eyebrow {font-size:10px}
  .stats {gap:12px}
  .stat {padding:16px;border-radius:14px;min-width:0}
  .stat-top {font-size:12px;line-height:1.4;gap:6px}
  .stat-icon {width:26px;height:26px;flex-shrink:0}
  .stat-value {font-size:30px}
  .stat-note {font-size:11px;line-height:1.5}
  .dashboard-grid {gap:18px}
  .panel {border-radius:16px}
  .panel h3 {font-size:15px;line-height:1.4}
  .panel-head {padding:16px;min-height:64px}
  .panel-head .text-btn {font-size:12px;flex-shrink:0}
  .idea-row {padding:17px 16px;display:grid;grid-template-columns:32px minmax(0,1fr);gap:8px 12px}
  .idea-info h4 {font-size:14px;line-height:1.5;margin-bottom:10px;overflow-wrap:anywhere}
  .idea-row .status-side {grid-column:2;max-width:none;justify-self:start;white-space:normal}
  .meta {font-size:12px;line-height:1.5}
  .badge {font-size:11px;line-height:1.4;padding:5px 8px;white-space:normal}
  .rank-row {min-height:60px;padding:12px 16px}
  .rank-name {font-size:14px}
  .rank-points {font-size:15px}
  .panel-foot {font-size:12px;line-height:1.6;padding:16px}
  .sidebar {padding:6px 4px calc(8px + env(safe-area-inset-bottom));background:var(--surface)}
  .nav {width:100%;align-items:stretch;gap:2px}
  .nav button {min-width:0;flex:1;min-height:54px;gap:5px;padding:7px 0;font-size:10px;line-height:1.2;border-radius:10px}
  .nav button span {max-width:100%;white-space:nowrap}
  .nav button.active {font-weight:650}
  .nav button svg {height:22px;width:22px}
  .nav .badge {font-size:9px;padding:1px 4px;min-width:15px;right:3px;top:0}
  .toolbar {gap:14px;margin-bottom:18px}
  .toolbar .tabs {flex:1;min-width:0;flex-wrap:nowrap;overflow-x:auto;gap:6px;scrollbar-width:none}
  .tabs button {min-height:44px;padding:10px 14px;flex-shrink:0;font-size:13px;white-space:nowrap}
  .search {min-width:0;width:100%;min-height:48px;font-size:16px;border-radius:12px}
  .idea-cards,.events-list {gap:14px}
  .idea-card {padding:19px;gap:16px;border-radius:16px}
  .idea-card h3 {font-size:17px;line-height:1.4;overflow-wrap:anywhere}
  .idea-card p {font-size:14px;line-height:1.6}
  .card-bottom {flex-wrap:wrap}
  .event-card,.events-list .event-card {padding:18px;gap:15px;border-radius:14px}
  .event-card h4,.events-list .event-card h4 {font-size:15px;line-height:1.5}
  .event-card p {font-size:13px;line-height:1.5}
  .events-list .event-card .btn {font-size:13px;min-height:44px;margin-top:12px}
  .date-box {min-width:48px;padding:10px}
  .date-box small {font-size:11px}
  .date-box strong {font-size:22px}
  .form-panel {padding:20px 16px}
  .field {font-size:13px;gap:9px}
  .field input,.field textarea,.field select,.skill-row select {font-size:16px;min-height:48px;border-radius:10px;padding:12px;line-height:1.5}
  .field textarea {min-height:110px}
  .check {min-height:44px;font-size:14px;gap:12px}
  .check input {width:20px;height:20px}
  .check-grid {gap:6px}
  .skill-row {padding:20px 0;gap:12px}
  .skill-row b {font-size:15px;line-height:1.5}
  .skill-row .check {font-size:13px}
  #profile-form>.btn {width:100%;min-height:48px}
  .info-note {font-size:13px;line-height:1.7;border-radius:12px}
  .demo-bar {font-size:10px;gap:10px;padding:8px 12px}
  .demo-bar select {font-size:12px;min-height:36px;max-width:145px}
  dialog {width:100%;max-width:none;margin:auto 0 0;border-radius:22px 22px 0 0;max-height:calc(100dvh - 20px);padding-bottom:env(safe-area-inset-bottom)}
  .modal-header {position:sticky;top:0;background:var(--surface);z-index:1;padding:15px 20px}
  .modal-header h2 {font-size:19px;line-height:1.4}
  .modal-header button {min-height:44px;min-width:44px}
  .modal-body {padding:20px}
  .modal-actions {display:grid;grid-template-columns:1fr 2fr;gap:10px}
  .modal-actions .btn {white-space:normal;min-height:48px;font-size:14px}
  .detail-title {font-size:23px}
  .detail-section p {font-size:15px}
  .detail-section h4 {font-size:12px}
  #toast {bottom:calc(var(--bottom-nav-height) + 14px + env(safe-area-inset-bottom));font-size:14px;line-height:1.5;width:max-content;max-width:calc(100vw - 32px)}
  .access-gate {padding:24px;width:100%;border-radius:16px}
  .access-gate h1 {font-size:22px;text-align:center}
  .access-gate summary {font-size:14px;min-height:44px;align-content:center}
  .gate .btn {min-height:48px;font-size:15px}
  .rating-table .table {table-layout:fixed;white-space:normal}
  .rating-table th,.rating-table td {padding:14px 10px;font-size:14px}
  .rating-table th:first-child,.rating-table td:first-child {width:54px;text-align:center}
  .rating-table th:nth-child(3),.rating-table td:nth-child(3) {width:70px;text-align:right;padding-right:16px}
  .rating-table th:nth-child(n+4),.rating-table td:nth-child(n+4) {display:none}
  .rating-table .person {flex-wrap:wrap;gap:8px;overflow-wrap:anywhere}
  .rating-table .avatar {width:28px;height:28px;font-size:10px}
  .users-table,.activity-table {overflow:hidden}
  .users-table .table,.activity-table .table {white-space:normal}
  .users-table thead,.activity-table thead {display:none}
  .users-table tbody,.activity-table tbody {display:grid}
  .users-table tr,.activity-table tr {display:grid;padding:16px;gap:12px;border-bottom:1px solid var(--line)}
  .users-table td,.activity-table td {padding:0;border:0;font-size:14px;overflow-wrap:anywhere}
  .users-table td::before,.activity-table td::before {content:attr(data-label);display:block;color:var(--muted);font-size:11px;margin-bottom:5px}
  .users-table td:first-child::before {display:none}
  .users-table .person {align-items:flex-start;font-size:15px}
  .users-table .meta {margin-top:6px;word-break:break-word}
  .users-table td:last-child .btn {width:100%;min-height:44px;font-size:14px}
}
@media (max-width:359px) {
  .content {padding-left:12px;padding-right:12px}
  .topbar {padding:0 12px}
  .top-right {gap:5px}
  .quarter {font-size:10px}
  .stat {padding:13px}
  .stat-top {font-size:11px}
  .stat-icon {display:none}
  .panel-head {gap:8px}
  .panel h3 {font-size:14px}
  .nav button {font-size:9px}
}

@media(max-width:760px) {
  :root {--safe-bottom:max(env(safe-area-inset-bottom),var(--tg-content-safe-area-inset-bottom,0px));--safe-top:max(env(safe-area-inset-top),var(--tg-content-safe-area-inset-top,0px))}
  .topbar {height:calc(64px + var(--safe-top));padding-top:var(--safe-top)}
  .sidebar {padding-bottom:calc(8px + var(--safe-bottom))}
  .content {padding-bottom:calc(var(--bottom-nav-height) + 30px + var(--safe-bottom))}
  dialog {padding-bottom:var(--safe-bottom)}
  #toast {bottom:calc(var(--bottom-nav-height) + 14px + var(--safe-bottom))}
}

.nav-mobile-label{display:none}
@media(max-width:760px){.nav .nav-label{display:none}.nav .nav-mobile-label{display:inline}.nav{gap:4px}}
