/* =========================================================================
   STUDY ORBIT — стили
   Токены темы вынесены в CSS-переменные (:root и [data-theme="dark"]),
   поэтому переключение темы происходит мгновенно, без перерисовки DOM.
   ========================================================================= */

:root {
  /* --- Светлая тема (по умолчанию) --- */
  --bg: #F6F4EF;
  --surface: #FFFFFF;
  --surface-2: #FBFAF7;
  --border: #E4E0D6;
  --text: #1C1E22;
  --text-muted: #6B6F76;
  --shadow: 0 8px 24px rgba(28, 30, 34, 0.07);

  /* Акценты категорий событий */
  --c-lecture: #2F6690;
  --c-lecture-bg: #E7F0F6;
  --c-deadline: #B4652A;
  --c-deadline-bg: #FBEDE0;
  --c-exam: #A5313F;
  --c-exam-bg: #FAE6E8;

  /* Акцент модуля энергии/фокуса */
  --c-focus: #5B4B9E;
  --c-focus-soft: #EFEBFA;

  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 20px;

  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #14151A;
  --surface: #1C1E24;
  --surface-2: #22242B;
  --border: #303339;
  --text: #EDEDF0;
  --text-muted: #9498A2;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.45);

  --c-lecture: #6FA8CE;
  --c-lecture-bg: #1F2C36;
  --c-deadline: #E39A5E;
  --c-deadline-bg: #35291E;
  --c-exam: #E37884;
  --c-exam-bg: #3A2226;

  --c-focus: #A497DE;
  --c-focus-soft: #26223B;

  color-scheme: dark;
}

/* --- Базовый сброс --- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  transition: background 0.25s ease, color 0.25s ease;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font-family: inherit; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; }

/* =========================== ШАПКА =========================== */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  margin-right: auto;
}
.brand-mark { color: var(--c-focus); font-size: 1.3rem; }

.view-switch {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.view-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  transition: background 0.2s, color 0.2s;
}
.view-btn.is-active { background: var(--c-focus); color: #fff; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.primary-btn {
  background: var(--c-focus);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: var(--radius-s);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:active { transform: scale(0.97); }
.primary-btn.full-width { width: 100%; margin-top: 14px; }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-s);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}
.ghost-btn:hover { background: var(--surface-2); }

.danger-btn {
  background: transparent;
  border: 1px solid var(--c-exam);
  color: var(--c-exam);
  padding: 8px 14px;
  border-radius: var(--radius-s);
  font-weight: 600;
  cursor: pointer;
}
.danger-btn:hover { background: var(--c-exam-bg); }

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 1.1rem;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-s);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }

.menu-wrap { position: relative; }
.dropdown {
  position: absolute;
  right: 0;
  top: 42px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow);
  padding: 6px;
  display: flex;
  flex-direction: column;
  min-width: 170px;
  z-index: 30;
}
/* Тот же фикс, что и для .modal-overlay: без этого правила display: flex
   выше может в некоторых WebView перебивать атрибут [hidden], и меню
   останется видимым и кликабельным, даже когда JS считает его закрытым. */
.dropdown[hidden] {
  display: none !important;
}
.dropdown button, .dropdown-file {
  background: none;
  border: none;
  text-align: left;
  padding: 9px 10px;
  border-radius: var(--radius-s);
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text);
}
.dropdown button:hover, .dropdown-file:hover { background: var(--surface-2); }


/* =========================== ПРОФИЛЬ =========================== */
.profile-btn {
  position:relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 5px 10px 5px 6px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.profile-btn:hover { background: var(--surface-2); }
.topbar-actions { position:relative; }
.profile-quick-menu { position:absolute; z-index:120; top:calc(100% + 8px); left:0; width:220px; padding:6px; border:1px solid var(--border-heavy); border-radius:12px; background:var(--surface); box-shadow:0 14px 36px rgba(0,0,0,.24); }
.profile-quick-menu[hidden] { display:none!important; }
.profile-quick-menu button { width:100%; display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px 11px; border:0; border-radius:8px; background:transparent; color:var(--text); font:inherit; text-align:left; cursor:pointer; }
.profile-quick-menu button:hover { background:var(--surface-2); }
.profile-avatar, .profile-large-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--c-focus);
  color: #fff;
  font-weight: 700;
}
.profile-avatar { width: 28px; height: 28px; font-size: .78rem; background-size:cover; background-position:center; overflow:hidden; }
.profile-large-avatar { width: 58px; height: 58px; font-size: 1.2rem; flex: 0 0 auto; }
.profile-modal { max-width: 520px; }
.modal.profile-modal { width:min(1120px,calc(100vw - 40px)); max-width:1120px; max-height:min(94vh,1100px); overflow:auto; }
.profile-modal .modal-head { position:sticky; top:-20px; z-index:2; padding:12px 0; background:var(--surface); }
.profile-modal .profile-large-avatar { position:relative; flex-direction:column; width:76px; height:76px; background-size:cover; background-position:center; border:0; cursor:pointer; }
.profile-avatar-picker span { margin:0!important; color:#fff!important; font-size:1.2rem!important; }
.profile-cover-preview { position:relative; height:clamp(118px,18vw,190px); margin:-4px 0 0; border-radius:var(--radius-m); border:1px solid var(--border); background-color:#050811; background-image:url("profile-banner-stars.png"); background-size:cover; background-position:center; }
.profile-banner-picker { position:absolute; right:12px; top:12px; border:1px solid #ffffff77; border-radius:9px; padding:8px 11px; background:#111217b8; color:#fff; cursor:pointer; font:inherit; font-size:.78rem; }
.profile-username-field { display:flex; align-items:center; gap:8px; }
.profile-username-field>span { color:var(--text-muted); font-weight:700; }
.profile-username-field .field-input { min-width:0; flex:1; }
.profile-social-preferences { display:grid; gap:8px; margin:12px 0; font-size:.82rem; }
.profile-social-preferences label { display:flex; align-items:flex-start; gap:8px; }
.profile-social-preferences input { margin-top:2px; accent-color:var(--c-focus); }
.profile-social-subtitle { margin:16px 0 8px; font-size:.84rem; }
.profile-social-list { display:grid; gap:7px; }
.profile-social-empty { display:block; padding:10px; color:var(--text-muted); font-size:.8rem; }
.profile-social-item { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:9px 10px; border:1px solid var(--border); border-radius:9px; color:var(--text); text-decoration:none; font-size:.8rem; }
.profile-social-item>div:first-child { min-width:0; }
.profile-social-item small { display:block; margin-top:3px; color:var(--text-muted); }
.profile-social-item>div:last-child { display:flex; flex-wrap:wrap; align-items:center; justify-content:flex-end; gap:6px; }
.profile-social-item button,.profile-social-item a { padding:7px 9px; font-size:.72rem; }
.profile-search-person { display:flex; align-items:center; gap:10px; min-width:0; }
.profile-search-avatar { width:38px; height:38px; display:grid; place-items:center; flex:0 0 38px; overflow:hidden; border-radius:50%; background:var(--c-focus-soft); color:var(--text); font-weight:700; }
.profile-search-avatar img { width:100%; height:100%; object-fit:cover; }
.profile-search-copy { display:block; min-width:0; }
.profile-search-copy strong,.profile-search-copy small { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.profile-platform-awards { padding:10px; border-radius:9px; background:var(--surface-2); font-size:.8rem; }
.profile-platform-awards p { color:var(--text-muted); margin:4px 0 8px; }
.profile-platform-awards>div { display:flex; gap:6px; flex-wrap:wrap; }
.profile-platform-awards>div span { padding:5px 8px; border:1px solid var(--border); border-radius:99px; }
.profile-main-actions { display:flex; gap:8px; margin:16px 0; }
.profile-advanced { margin:14px 0; padding:16px; border:1px solid var(--border); border-radius:var(--radius-m); background:var(--surface-2); }
.profile-advanced[hidden] { display:none!important; }
.profile-advanced-tools { display:flex; gap:8px; margin:10px 0 16px; }
.profile-module-edit { display:block; margin-top:10px; min-height:42px; }
.profile-work-actions { display:flex; gap:6px; margin-top:8px; }
.profile-work-actions button { font-size:.75rem; padding:6px 9px; }
.profile-friends-rail { display:flex; gap:14px; overflow-x:auto; padding:10px 2px 5px; }
.profile-friend-chip { display:flex; flex:0 0 58px; align-items:center; flex-direction:column; gap:5px; text-decoration:none; color:var(--text); }
.profile-friend-chip>span { width:48px; height:48px; display:grid; place-items:center; overflow:hidden; border-radius:50%; border:2px solid var(--border); background:var(--surface); color:var(--text); font-weight:700; }
.profile-friend-chip img { width:100%; height:100%; object-fit:cover; }
.profile-friend-chip small { max-width:62px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:.67rem; }
.modal.profile-preview-modal { width:min(1080px,calc(100vw - 36px)); max-width:1080px; max-height:92vh; overflow:auto; }
.modal.profile-small-modal { width:min(540px,calc(100vw - 28px)); max-width:540px; }
.modal.profile-inbox-modal { width:min(680px,calc(100vw - 28px)); max-width:680px; max-height:88vh; overflow:auto; }
.modal.notes-editor-modal { width:min(1040px,calc(100vw - 40px)); max-width:1040px; max-height:96vh; overflow:auto; }
.banner-color-row { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }
.banner-color-row input[type="color"] { width:44px; height:40px; padding:3px; border:1px solid var(--border); border-radius:8px; background:var(--surface); }
.banner-presets { display:flex; flex-wrap:wrap; gap:8px; margin:12px 0; }
.banner-presets button { padding:8px 11px; border:1px solid var(--border); border-radius:999px; background:var(--surface-2); color:var(--text); cursor:pointer; font:inherit; font-size:.76rem; }
.profile-earned-badges { display:grid; gap:8px; }
.profile-earned-badge { display:flex; align-items:center; gap:12px; padding:11px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); }
.profile-earned-badge>span { font-size:1.4rem; }
.profile-earned-badge small { display:block; margin-top:3px; color:var(--text-muted); }
.profile-inbox-tabs { display:flex; gap:6px; padding:5px; margin:0 0 14px; border-radius:10px; background:var(--surface-2); }
.profile-inbox-tabs button { flex:1; padding:9px 8px; border:0; border-radius:8px; background:transparent; color:var(--text-muted); cursor:pointer; font:inherit; font-size:.82rem; }
.profile-inbox-tabs button.is-active { background:var(--surface); color:var(--text); box-shadow:0 1px 4px #0002; }
.inbox-pane[hidden] { display:none!important; }
.profile-avatar-picker small { position:absolute; inset:auto 0 0; padding:3px 0; border-radius:0 0 50px 50px; background:#0009; color:#fff; font-size:9px; }
.profile-editor-section,.profile-preview-section { margin-top:20px; padding-top:16px; border-top:1px solid var(--border); }
.profile-section-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; }
.profile-section-heading h3 { margin:0; font-size:1rem; }
.profile-section-heading p { margin:4px 0 0; color:var(--text-muted); font-size:.78rem; }
.profile-modules,.public-profile-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.profile-module-card,.profile-preview-module { min-width:0; padding:12px; border:1px solid var(--border); border-radius:var(--radius-m); background:var(--surface-2); }
.profile-module-card.size-wide,.profile-preview-module.size-wide { grid-column:1/-1; }
.profile-module-card.size-half,.profile-preview-module.size-half { grid-column:auto; }
.profile-module-card.is-hidden { opacity:.52; }
.profile-module-toolbar { display:flex; align-items:center; justify-content:space-between; gap:10px; padding-bottom:9px; border-bottom:1px solid var(--border); }
.profile-module-toolbar>div { display:flex; align-items:center; gap:4px; }
.profile-module-toolbar button,.profile-editor-item button { border:1px solid var(--border); border-radius:7px; background:var(--surface); color:var(--text); padding:5px 8px; cursor:pointer; }
.profile-module-toolbar button:disabled { opacity:.35; cursor:default; }
.profile-module-visible { display:flex; align-items:center; gap:4px; font-size:.72rem; white-space:nowrap; }
.profile-module-content,.profile-preview-module { font-size:.84rem; }
.profile-module-content>p,.profile-preview-module>p { margin:10px 0 0; color:var(--text-muted); }
.profile-work-editor { margin:10px 0 14px; }
.profile-editor-list { display:grid; gap:6px; margin-bottom:12px; }
.profile-editor-item { display:flex; justify-content:space-between; align-items:center; gap:8px; padding:7px 9px; border-radius:8px; background:var(--surface-2); font-size:.8rem; }
.profile-inline-form { display:flex; gap:8px; margin:6px 0 12px; }
.profile-inline-form .field-input { flex:1; min-width:0; }
.public-profile-preview { padding:14px; border:1px solid var(--border); border-radius:var(--radius-m); background:var(--surface); }
.preview-cover { height:110px; margin:-14px -14px 0; border-radius:var(--radius-m) var(--radius-m) 0 0; background:radial-gradient(ellipse at 78% 18%,rgba(181,87,102,.28),transparent 34%),linear-gradient(120deg,#45172b,#77243c 54%,#32172d); background-size:cover; background-position:center; }
.public-profile-head { display:flex; align-items:center; gap:12px; padding-bottom:12px; margin-bottom:12px; border-bottom:1px solid var(--border); }
.public-profile-head h4 { margin:0; font-size:1rem; }
.public-profile-head p { margin:4px 0 0; color:var(--text-muted); font-size:.8rem; }
.public-profile-avatar { width:48px; height:48px; display:grid; place-items:center; border-radius:50%; background:var(--c-focus); color:#fff; overflow:hidden; font-weight:700; }
.public-profile-avatar img { width:100%; height:100%; object-fit:cover; }
.profile-preview-module h5 { margin:0; font-size:.84rem; }
.public-profile-page { min-height:100vh; padding:24px; background:var(--bg); color:var(--text); }
.shared-profile-shell { max-width:1120px; margin:0 auto; padding:20px; border:1px solid var(--border); border-radius:var(--radius-l); background:var(--surface); }
.shared-profile-brand { display:block; margin:0 0 16px; color:var(--text); text-decoration:none; font-weight:700; }
.shared-profile-cover { height:clamp(140px,20vw,220px); border-radius:var(--radius-m); background-color:#050811; background-image:url("profile-banner-stars.png"); background-size:cover; background-position:center; }
.shared-profile-header { display:flex; align-items:center; gap:15px; margin:-34px 18px 18px; position:relative; }
.shared-profile-avatar { width:82px; height:82px; flex:0 0 82px; display:grid; place-items:center; overflow:hidden; border:4px solid var(--surface); border-radius:50%; background:var(--c-focus); color:white; font-size:1.5rem; font-weight:800; }
.shared-profile-avatar img { width:100%; height:100%; object-fit:cover; }
.shared-profile-header h1 { margin:22px 0 3px; font-size:1.45rem; }
.shared-profile-header p { margin:0; color:var(--text-muted); font-size:.8rem; }
.shared-profile-content { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.shared-profile-content>section { min-width:0; padding:14px; border:1px solid var(--border); border-radius:var(--radius-m); background:var(--surface-2); }
.shared-profile-content>section.shared-profile-wide { grid-column:1/-1; }
.shared-profile-content>section.size-wide { grid-column:1/-1; }
.shared-profile-content>section.shared-profile-wide.size-half { grid-column:auto; }
.shared-profile-content h2 { margin:0 0 9px; font-size:1rem; }
.shared-profile-content p { color:var(--text-muted); line-height:1.55; font-size:.86rem; }
.shared-profile-empty { max-width:720px; margin:12vh auto; padding:28px; border:1px solid var(--border); border-radius:var(--radius-l); background:var(--surface); }
.profile-game-stats { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:6px; margin-top:10px; }
.profile-game-stats div { padding:8px 5px; border-radius:8px; background:var(--surface); text-align:center; }
.profile-game-stats strong,.profile-game-stats span { display:block; }
.profile-game-stats strong { font-size:1rem; }
.profile-game-stats span { color:var(--text-muted); font-size:.67rem; }
.profile-preview-works { display:grid; gap:8px; margin-top:10px; }
.profile-preview-works article { padding:9px; border-radius:8px; background:var(--surface); }
.profile-preview-works p { margin:5px 0; color:var(--text-muted); }
.profile-preview-works a { color:var(--c-focus); }
.friend-notification-badge { min-width:17px; height:17px; display:inline-grid!important; place-items:center; padding:0 4px; border-radius:99px; background:#d85663; color:#fff!important; font-size:10px!important; line-height:1; }
.friend-notification-badge[hidden] { display:none!important; }
.profile-notification-indicator { width:25px; height:25px; min-width:25px; padding:0; margin-left:2px; position:relative; background:transparent; color:var(--text-muted)!important; }
.profile-notification-indicator .notification-bell-icon { width:19px; height:19px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.profile-notification-indicator>span { display:none; }
.profile-notification-indicator.has-notifications { position:absolute; top:-4px; right:-3px; z-index:2; width:auto; min-width:17px; height:17px; padding:0 4px; margin:0; background:#d85663; color:#fff!important; }
.profile-notification-indicator.has-notifications .notification-bell-icon { display:none; }
.profile-notification-indicator.has-notifications>span { display:block; }
.profile-mode-text { margin: 4px 0 0; color: var(--text-muted); font-size: .84rem; }
.profile-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; margin: 4px 0 18px;
  border: 1px solid var(--border); border-radius: var(--radius-m);
  background: var(--surface-2);
}
.profile-card strong, .profile-card span { display: block; }
.profile-card span { margin-top: 3px; color: var(--text-muted); font-size: .82rem; }
.profile-card .profile-card-university { color: var(--text); font-weight: 600; }
.profile-field-hint { margin: 5px 0 14px; color: var(--text-muted); font-size: .74rem; line-height: 1.4; }
.field-label { display: block; margin: 0 0 7px; font-weight: 600; font-size: .86rem; }
.field-input {
  width: 100%; box-sizing: border-box; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text); outline: none;
}
.field-input:focus { border-color: var(--c-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-focus) 15%, transparent); }
.profile-info-box {
  margin-top: 16px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-m);
  background: var(--surface-2); font-size: .84rem;
}
.profile-info-box strong { display: block; margin-bottom: 7px; }
.profile-info-box ul { list-style: disc; padding-left: 20px; color: var(--text-muted); }
.profile-info-box li + li { margin-top: 5px; }
.profile-actions { align-items: center; }
.profile-hint { margin: 10px 0 0; color: var(--text-muted); font-size: .76rem; line-height: 1.4; }
@media (max-width: 760px) {
  .modal.profile-modal { width:calc(100vw - 20px); max-width:none; max-height:94dvh; padding:16px; }
  .modal.profile-preview-modal,.modal.profile-inbox-modal,.modal.profile-small-modal { width:calc(100vw - 20px); max-width:none; max-height:94dvh; padding:16px; }
  .modal.notes-editor-modal { width:calc(100vw - 16px); max-width:none; max-height:98dvh; padding:14px; }
  .profile-main-actions,.profile-advanced-tools { flex-wrap:wrap; }
  .profile-inbox-tabs button { font-size:.72rem; padding:8px 4px; }
  .profile-modules,.public-profile-grid { grid-template-columns:1fr; }
  .profile-module-card.size-wide,.profile-preview-module.size-wide { grid-column:auto; }
  .profile-section-heading { align-items:flex-start; }
  .profile-section-heading>.ghost-btn { padding:8px; font-size:.74rem; }
  .profile-module-toolbar { align-items:flex-start; flex-direction:column; }
  .profile-module-toolbar>div { flex-wrap:wrap; }
  .profile-game-stats { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .profile-cover-preview { height:120px; }
  .profile-username-field { flex-wrap:wrap; }
  .profile-username-field .field-input { flex-basis:calc(100% - 38px); }
  .profile-username-field button { width:100%; }
  .profile-social-item { align-items:flex-start; flex-direction:column; }
  .profile-social-item>div:last-child { justify-content:flex-start; }
  .public-profile-page { padding:10px; }
  .shared-profile-shell { padding:12px; }
  .shared-profile-content { grid-template-columns:1fr; }
  .shared-profile-content>section.shared-profile-wide { grid-column:auto; }
  .shared-profile-header { margin:-27px 7px 14px; }
  .shared-profile-avatar { width:66px; height:66px; flex-basis:66px; }
  .profile-btn #profileLabel { display: none; }
  .profile-actions { flex-direction: column-reverse; align-items: stretch; }
  .profile-actions button { width: 100%; }
}

/* =========================== ОСНОВНОЙ ЛЭЙАУТ =========================== */
.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 22px;
  padding: 22px 24px 60px;
  max-width: 1440px;
  margin: 0 auto;
  align-items: start;
}

.calendar-panel, .dashboard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 20px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 10px;
}
.period-label { font-size: 1.15rem; font-weight: 600; min-width: 200px; text-align: center; text-transform: capitalize; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px dashed var(--border); }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--text-muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-lecture { background: var(--c-lecture); }
.dot-deadline { background: var(--c-deadline); }
.dot-exam { background: var(--c-exam); }

/* =========================== ЖИВОЙ ПОИСК =========================== */
.field-search {
  display: block;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.88rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field-search::placeholder { color: var(--text-muted); }
.field-search:focus {
  outline: none;
  border-color: var(--c-focus);
  box-shadow: 0 0 0 3px var(--c-focus-soft);
}

/* =========================== МАТРИЦА ЭЙЗЕНХАУЭРА =========================== */
.matrix-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
/* Тот же фикс, что и для .modal-overlay/.dropdown: без него display: grid
   выше может перебивать атрибут [hidden] в некоторых движках. */
.matrix-grid[hidden] {
  display: none !important;
}
/* --- Панель управления матрицей: тумблер режима + кнопка-подсказка ---
   Занимает всю ширину грида (обе колонки), поэтому располагается отдельной
   строкой над квадрантами. */
.matrix-controls {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}
.switch-label { font-size: 0.84rem; font-weight: 600; color: var(--text); margin-right: auto; }

/* Тумблер-переключатель */
.switch-wrap {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}
.switch-wrap input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-wrap .slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.2s ease;
}
.switch-wrap .slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: var(--surface);
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: var(--shadow);
}
.switch-wrap input:checked + .slider {
  background: var(--c-focus);
}
.switch-wrap input:checked + .slider::before {
  transform: translateX(18px);
}
.switch-wrap input:focus-visible + .slider {
  outline: 2px solid var(--c-focus);
  outline-offset: 2px;
}

/* Круглая кнопка-подсказка */
.help-icon-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.help-icon-btn:hover {
  background: var(--c-focus-soft);
  border-color: var(--c-focus);
}

/* Модалка-подсказка по режимам матрицы */
.help-modal p { font-size: 0.86rem; line-height: 1.5; color: var(--text); margin: 0 0 12px; }
.help-modal p:last-of-type { margin-bottom: 16px; }

.matrix-quadrant {
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 14px;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, filter 0.15s ease;
}
.matrix-quadrant:hover {
  border-color: var(--c-focus);
  filter: brightness(1.03);
}
/* Список и его элементы возвращают обычный курсор — кликабельна именно
   пустая область квадранта, а не сам список задач. */
.quadrant-list, .quadrant-item {
  cursor: pointer;
}
.matrix-quadrant h3 { font-size: 0.95rem; }
.quadrant-hint { margin: 0; font-size: 0.72rem; color: var(--text-muted); line-height: 1.35; }
.quadrant-list { display: flex; flex-direction: column; gap: 6px; margin-top: 2px; }
.quadrant-list .empty { color: var(--text-muted); font-size: 0.8rem; }
.quadrant-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 8px 10px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: transform 0.1s ease;
}
.quadrant-item:hover { transform: translateY(-1px); }
.quadrant-item-meta { font-size: 0.68rem; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

/* Цветовая идентичность каждого квадранта — использует те же токены,
   что и чипы событий в календаре, для визуальной согласованности. */
.q-urgent-important   { background: var(--c-exam-bg);     border-color: var(--c-exam); }
.q-important          { background: var(--c-lecture-bg);  border-color: var(--c-lecture); }
.q-urgent-notimportant{ background: var(--c-deadline-bg); border-color: var(--c-deadline); }
.q-notimportant        { background: var(--surface-2); }

@media (max-width: 640px) {
  .matrix-grid { grid-template-columns: 1fr; }
}

/* =========================== БАННЕРЫ: ПРЕД-ДЕДЛАЙН УВЕДОМЛЕНИЯ =========================== */
.notif-container {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90; /* ниже модалок (100), выше остального интерфейса */
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(480px, calc(100% - 28px));
  pointer-events: none; /* сам контейнер клики не перехватывает */
}
.notif-banner {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--c-exam-bg);
  border: 1px solid var(--c-exam);
  color: var(--c-exam);
  padding: 10px 12px;
  border-radius: var(--radius-m);
  box-shadow: var(--shadow);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.35;
  animation: notifSlideIn 0.22s ease;
}
.notif-banner span { flex: 1; }
.notif-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
@keyframes notifSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =========================== ВИД: МЕСЯЦ =========================== */
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
/* Тот же фикс, что и для .modal-overlay/.dropdown/.matrix-grid: без него
   display: grid выше может перебивать атрибут [hidden]. */
.month-grid[hidden] {
  display: none !important;
}
.weekday-head {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  padding-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.day-cell {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  min-height: 96px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s, background 0.15s;
}
.day-cell:hover { border-color: var(--c-focus); }
.day-cell.is-outside { opacity: 0.4; }
.day-cell.is-today { border-color: var(--c-focus); box-shadow: inset 0 0 0 1px var(--c-focus); }
.day-num { font-size: 0.8rem; font-weight: 700; }
.day-chip {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
.day-chip.chip-lecture { background: var(--c-lecture-bg); color: var(--c-lecture); }
.day-chip.chip-deadline { background: var(--c-deadline-bg); color: var(--c-deadline); }
.day-chip.chip-exam { background: var(--c-exam-bg); color: var(--c-exam); font-weight: 700; }
.day-more { font-size: 0.68rem; color: var(--text-muted); }

/* --- Затенение дней вне текущей недели в режиме "Неделя" ---
   Идёт ПОСЛЕ .is-outside в исходном коде, поэтому при совпадении дня
   (край месяца одновременно вне выбранной недели) побеждает именно это
   более сильное затенение. */
.day-cell.is-dimmed {
  opacity: 0.25;
  filter: grayscale(50%);
  transition: opacity 0.2s;
}

/* --- Подсветка/затенение для живого поиска ---
   День или чип, не совпавшие с запросом, получают .search-blur; день,
   в котором есть хотя бы одно совпадение, получает .day-has-match. */
.search-blur {
  opacity: 0.15;
  filter: blur(0.5px);
  transition: all 0.2s;
}
.day-cell.day-has-match {
  border-color: var(--c-focus);
  box-shadow: inset 0 0 0 2px var(--c-focus);
}
.day-chip.chip-match {
  box-shadow: inset 0 0 0 1px var(--c-focus);
}

/* =========================== ВИД: НЕДЕЛЯ =========================== */
.week-grid {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  overflow: hidden;
}
/* Тот же фикс [hidden], для полноты — хотя renderCalendar() теперь всегда
   держит #weekView скрытым (режим "Неделя" переиспользует сетку месяца). */
.week-grid[hidden] {
  display: none !important;
}
.week-head-cell {
  padding: 8px 4px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
}
.week-head-cell.is-today { color: var(--c-focus); }
.hour-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  padding: 4px;
  text-align: right;
  border-top: 1px solid var(--border);
}
.week-slot {
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  min-height: 44px;
  padding: 2px;
  cursor: pointer;
  position: relative;
}
.week-slot:hover { background: var(--surface-2); }
.week-event {
  font-size: 0.66rem;
  border-radius: 5px;
  padding: 2px 5px;
  margin-bottom: 2px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================== ДАШБОРД: ЭНЕРГИЯ =========================== */
.dash-title { font-size: 1.05rem; }
.dash-sub { color: var(--text-muted); font-size: 0.82rem; margin: 6px 0 16px; line-height: 1.4; }

.energy-input {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}
.energy-slot { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.energy-slot-time { font-size: 0.66rem; color: var(--text-muted); font-weight: 600; }
.energy-levels { display: flex; flex-direction: column; gap: 3px; }
.energy-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 0.68rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: transform 0.1s;
}
.energy-dot:hover { transform: scale(1.1); }
.energy-dot.is-selected { background: var(--c-focus); border-color: var(--c-focus); color: #fff; }

.energy-chart-wrap { margin-bottom: 16px; }
.energy-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 90px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 8px;
}
.energy-bar {
  flex: 1;
  background: linear-gradient(180deg, var(--c-focus), var(--c-focus-soft));
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s ease;
}
.chart-axis { display: flex; justify-content: space-between; font-size: 0.62rem; color: var(--text-muted); padding: 4px 8px 0; }

.advice-card {
  display: flex;
  gap: 10px;
  background: var(--c-focus-soft);
  border-radius: var(--radius-m);
  padding: 12px;
  margin-bottom: 18px;
}
.advice-icon { font-size: 1.1rem; }
.advice-card p { margin: 0; font-size: 0.84rem; line-height: 1.45; color: var(--text); }

/* --- Модуль "Задачи на день" --- */
.today-tasks-panel {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px dashed var(--border);
}
.today-tasks-panel .dash-title { margin-bottom: 8px; }

.mini-date-picker {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
}
.mini-date-btn {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 42px;
  padding: 6px 4px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-s);
  cursor: pointer;
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--text-muted);
}
.mini-date-btn .mdb-num { font-size: 0.86rem; font-weight: 700; color: var(--text); }
.mini-date-btn.is-today { border-color: var(--c-focus); }
.mini-date-btn.is-selected { background: var(--c-focus); border-color: var(--c-focus); color: #fff; }
.mini-date-btn.is-selected .mdb-num { color: #fff; }

.today-tasks-table { display: flex; flex-direction: column; gap: 6px; }
.today-tasks-table .empty { color: var(--text-muted); font-size: 0.82rem; }
.today-task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-s);
  cursor: pointer;
  border-left: 4px solid var(--c-lecture);
  background: var(--c-lecture-bg);
  transition: transform 0.1s ease;
}
.today-task-row:hover { transform: translateX(2px); }
.today-task-row.type-deadline { border-left-color: var(--c-deadline); background: var(--c-deadline-bg); }
.today-task-row.type-exam { border-left-color: var(--c-exam); background: var(--c-exam-bg); }
.today-task-row.is-done { opacity: 0.55; text-decoration: line-through; }
.today-task-title { font-size: 0.84rem; font-weight: 600; color: var(--text); }
.today-task-time { font-size: 0.76rem; font-weight: 700; color: var(--text-muted); flex-shrink: 0; white-space: nowrap; }

.deadline-summary h3 { font-size: 0.9rem; margin-bottom: 10px; }
.deadline-list { display: flex; flex-direction: column; gap: 8px; }
.deadline-list .empty { color: var(--text-muted); font-size: 0.82rem; }
.deadline-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 8px 10px;
}
.deadline-row-top { display: flex; justify-content: space-between; font-size: 0.82rem; font-weight: 600; }
.deadline-row-date { font-size: 0.7rem; color: var(--text-muted); }
.progress-track { background: var(--border); border-radius: 999px; height: 6px; overflow: hidden; margin-top: 2px; }
.progress-fill { height: 100%; background: var(--c-deadline); border-radius: 999px; transition: width 0.3s ease; }
.progress-fill.is-done { background: #4C9A6A; }

/* =========================== МОДАЛЬНЫЕ ОКНА =========================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 14, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.18s ease;
}
/* Явно принудительно скрываем оверлей, когда стоит атрибут [hidden].
   Без этого правила display: flex выше может в некоторых движках/WebView
   выигрывать у стандартного [hidden]{display:none} — модалка тогда
   формально "скрыта" атрибутом, но всё ещё видна и перехватывает клики. */
.modal-overlay[hidden] {
  display: none !important;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-l);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: var(--shadow);
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.event-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.field input, .field textarea {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-s);
  padding: 9px 10px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 400;
  resize: vertical;
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--c-focus);
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.type-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.type-opt {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.type-opt.is-active[data-type="lecture"] { background: var(--c-lecture-bg); color: var(--c-lecture); border-color: var(--c-lecture); }
.type-opt.is-active[data-type="deadline"] { background: var(--c-deadline-bg); color: var(--c-deadline); border-color: var(--c-deadline); }
.type-opt.is-active[data-type="exam"] { background: var(--c-exam-bg); color: var(--c-exam); border-color: var(--c-exam); }

.fields-group { display: flex; flex-direction: column; gap: 12px; }
.checkbox-field { display: flex; align-items: center; gap: 8px; font-size: 0.86rem; font-weight: 500; color: var(--text); }
.progress-preview { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }

.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.spacer { flex: 1; }

.day-event-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; max-height: 50vh; overflow-y: auto; }
.day-event-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-s);
  border-left: 4px solid var(--c-lecture);
  background: var(--surface-2);
  cursor: pointer;
}
.day-event-row.type-deadline { border-left-color: var(--c-deadline); }
.day-event-row.type-exam { border-left-color: var(--c-exam); }
.day-event-row.is-done { opacity: 0.55; text-decoration: line-through; }
.day-event-meta { font-size: 0.72rem; color: var(--text-muted); }

/* =========================== АДАПТИВНОСТЬ =========================== */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
  .layout { padding: 14px; }
  .day-cell { min-height: 74px; }
  .period-label { min-width: auto; font-size: 1rem; }
  .week-grid { grid-template-columns: 40px repeat(7, minmax(70px, 1fr)); overflow-x: auto; }
}

/* Уважение к настройке "меньше анимаций" */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}


/* =========================== ИЕРАРХИЧЕСКИЕ ЗАМЕТКИ =========================== */
.notes-panel[hidden] { display: none !important; }
.notes-panel {
  width: min(1440px, calc(100% - 48px));
  min-height: calc(100vh - 110px);
  margin: 22px auto 60px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 22px;
}
.notes-sidebar, .notes-content-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 18px;
}
.notes-sidebar { align-self: start; position: sticky; top: 92px; }
.notes-sidebar > .primary-btn { width: 100%; margin-bottom: 14px; }
.notes-sidebar { background:linear-gradient(180deg,var(--surface),var(--surface-2)); }
.notes-category-nav { display:flex; flex-direction:column; gap:5px; margin:0 0 14px; padding:0 0 12px; border-bottom:1px solid var(--border); }
.notes-category-nav button { display:flex; align-items:center; border:0; border-radius:9px; background:transparent; color:var(--text-muted); padding:9px 11px; text-align:left; font:inherit; font-size:.86rem; cursor:pointer; }
.notes-category-nav button:hover,.notes-category-nav button.is-active { color:var(--text); background:var(--c-focus-soft); }
.notes-category-nav button .notes-icon { width:19px; height:19px; margin-right:8px; color:#f2f3f7; }
.notes-icon { width:18px; height:18px; flex:0 0 18px; fill:none; stroke:currentColor; stroke-width:1.75; stroke-linecap:round; stroke-linejoin:round; }
.notes-icon-grid rect { fill:currentColor; stroke:none; }
.notes-icon-chevron { width:14px; height:14px; flex-basis:14px; }
.notes-icon-right { width:12px; height:12px; flex-basis:12px; }
.hierarchy-tree { display: flex; flex-direction: column; gap: 4px; }
.notes-tree-hub, .notes-tree-folder {
  width: 100%; border: 1px solid transparent; background: transparent; color: var(--text);
  text-align: left; border-radius: var(--radius-s); cursor: pointer; font: inherit;
}
.notes-tree-hub { display:flex; align-items:center; gap:9px; padding:9px 10px; }
.notes-tree-hub:hover, .notes-tree-hub.is-selected { background: var(--c-focus-soft); border-color: var(--border); }
.notes-tree-hub .notes-icon { color:#f5f6fa; }
.notes-tree-hub .notes-tree-chevron .notes-icon-chevron { transform:rotate(-90deg); }
.notes-tree-hub.has-children .notes-tree-chevron .notes-icon-chevron { transform:none; }
.notes-tree-folder { display:flex; width:100%; align-items:center; gap:7px; padding:7px 8px; color:var(--text-muted); font-size:.82rem; }
.notes-tree-folder:hover, .notes-tree-folder.is-selected { background: var(--surface-2); color: var(--text); }
.notes-tree-folders { display:flex; flex-direction:column; gap:0; margin:3px 0 10px 13px; padding-left:8px; border-left:1px solid var(--border-heavy); }
.notes-tree-node { position:relative; }
.notes-tree-node:before { content:""; position:absolute; left:-8px; top:17px; width:8px; border-top:1px solid var(--border-heavy); }
.notes-tree-children { display:flex; flex-direction:column; gap:0; margin-left:11px; padding-left:9px; border-left:1px solid var(--border-heavy); }
.notes-tree-chevron { width:14px; height:14px; display:inline-grid; place-items:center; color:#f2f3f7; }
.notes-tree-chevron .notes-icon-chevron { transform:rotate(-90deg); }
.notes-tree-folder.has-children .notes-tree-chevron .notes-icon-chevron { transform:none; }
.notes-tree-folder.is-selected { color:#fff; background:var(--c-focus-soft); }
.notes-tree-folder .notes-icon-folder { color:#f2f3f7; }
.notes-tree-folder-name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.notes-folder-glyph { flex:0 0 15px; width:15px; height:10px; border:1.5px solid currentColor; border-radius:2px; position:relative; opacity:.8; }
.notes-folder-glyph:before { content:""; position:absolute; width:6px; height:3px; top:-4px; left:1px; border:1.5px solid currentColor; border-bottom:0; border-radius:2px 2px 0 0; }
.notes-empty-tree, .notes-list-empty { color: var(--text-muted); font-size: .82rem; padding: 12px 8px; }
.notes-content-header { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.notes-content-header .field-search { margin-bottom: 0; flex: 1; }
.notes-actions-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.notes-workspace-placeholder, .notes-empty-state {
  min-height: 360px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--text-muted); border: 1px dashed var(--border); border-radius: var(--radius-m); padding: 30px;
}
.notes-empty-state h2, .notes-empty-state h3 { color: var(--text); margin-bottom: 8px; }
.notes-empty-state p { margin: 4px 0; max-width: 560px; line-height: 1.5; }
.notes-empty-icon { font-size: 2.2rem; margin-bottom: 10px; }
.notes-folder-head { display: flex; justify-content: space-between; gap: 15px; align-items: center; margin-bottom: 16px; }
.notes-breadcrumb { display:flex; flex-wrap:wrap; align-items:center; gap:5px; color:var(--text-muted); font-size:.76rem; margin-bottom:6px; }
.notes-breadcrumb-link { border:0; padding:2px 0; background:transparent; color:var(--text-muted); font:inherit; cursor:pointer; }
.notes-breadcrumb-link:hover,.notes-breadcrumb-link.is-current { color:var(--text); text-decoration:underline; text-underline-offset:3px; }
.notes-breadcrumb-separator { display:inline-flex; align-items:center; color:var(--text-muted); opacity:.7; }
.notes-count { color: var(--text-muted); font-size: .78rem; }
.notes-topic-layout { display: grid; grid-template-columns: 260px minmax(0,1fr); gap: 16px; min-height: 300px; }
.notes-topic-list { display:flex; flex-direction:column; gap:5px; }
.notes-topic-row { display:flex; align-items:stretch; gap:4px; }
.notes-topic-item { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: var(--radius-s); padding: 10px; text-align: left; cursor: pointer; }
.notes-topic-row .notes-topic-item { flex:1; min-width:0; }
.notes-topic-delete { width:35px; flex:0 0 35px; border:1px solid transparent; border-radius:var(--radius-s); background:transparent; color:var(--text-muted); cursor:pointer; display:grid; place-items:center; }
.notes-topic-delete:hover { color:#ff9aa3; border-color:#d8566355; background:#d8566315; }
.notes-topic-delete .notes-icon { width:16px; height:16px; }
.notes-topic-name { display:flex; align-items:center; gap:7px; min-width:0; }
.notes-topic-file-icon { display:inline-flex; color:#f4f5f8; }
.notes-topic-file-icon .notes-icon { width:15px; height:15px; }
.notes-topic-item:hover, .notes-topic-item.is-selected { border-color: var(--c-focus); background: var(--c-focus-soft); }
.notes-topic-item strong, .notes-topic-item span { display: block; overflow: hidden; text-overflow: ellipsis; }
.notes-topic-item strong { font-size: .84rem; margin-bottom: 4px; }
.notes-topic-item span { color: var(--text-muted); font-size: .7rem; white-space: nowrap; }
.notes-topic-item .notes-topic-name { display:flex; align-items:center; gap:7px; color:var(--text); font-size:.84rem; white-space:normal; text-overflow:clip; }
.notes-topic-item .notes-topic-name strong { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; margin:0; }
.notes-topic-item .notes-topic-file-icon { display:inline-flex; flex:0 0 15px; color:#f4f5f8; }
.note-card { border: 1px solid var(--border); border-radius: var(--radius-m); background: var(--surface-2); padding: 20px; }
.note-card h3 { font-size: 1.25rem; margin-bottom: 16px; }
.note-card-content { line-height: 1.65; font-size: .92rem; white-space: normal; overflow-wrap: anywhere; }
.notes-muted { color: var(--text-muted); }
.note-images { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.note-attached-image { display: block; width: 100%; height: auto; max-height: 720px; object-fit: contain; border-radius: var(--radius-s); border: 1px solid var(--border); background: var(--surface); }
.notes-modal select { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: var(--radius-s); padding: 9px 10px; }
.notes-modal input[type="file"] { padding: 8px; }
.notes-modal #noteHubStudyFields[hidden],.notes-modal #noteHubPersonalFields[hidden] { display:none!important; }
.notes-folder-head-actions { display:flex; flex-wrap:wrap; gap:7px; }
.notes-delete-hub { margin-left:10px; font-size:.75rem; }
.notes-nested-grid { margin:0 0 18px; }
.notes-folder-head { align-items:flex-start; }
.notes-breadcrumb { letter-spacing:.01em; }

@media (max-width: 980px) {
  .notes-panel { width: calc(100% - 28px); grid-template-columns: 1fr; margin: 14px auto 40px; }
  .notes-sidebar { position: static; }
}
@media (max-width: 700px) {
  .notes-content-header { flex-direction: column; }
  .notes-actions-buttons { width: 100%; }
  .notes-actions-buttons button { flex: 1; }
  .notes-topic-layout { grid-template-columns: 1fr; }
  .notes-panel { width: calc(100% - 28px); }
}


/* =========================== НОВЫЕ ФУНКЦИИ ЗАМЕТОК v300.2 =========================== */
.notes-folder-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.notes-folder-title-row h2 { margin: 0; }
.note-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.note-card-head h3 { margin: 0; }
.note-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.note-image-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.note-attached-image {
  cursor: zoom-in;
  transition: transform .16s ease, opacity .16s ease;
}
.note-attached-image:hover { opacity: .9; }
.note-image-delete {
  align-self: flex-start;
  padding: 5px 9px;
  font-size: .72rem;
}
.notes-hub-description {
  color: var(--text-muted);
  max-width: 700px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.note-materials {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.notes-section-title {
  margin: 0 0 12px;
  color: var(--text);
  font-size: .95rem;
}
.note-material-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
  padding: 16px;
  margin-top: 10px;
}
.note-material-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.note-material-head h4 { margin: 0 0 4px; font-size: .98rem; }
.note-material-head span { color: var(--text-muted); font-size: .72rem; }

/* Полноэкранный просмотр изображений */
.note-lightbox {
  background: rgba(0, 0, 0, .86);
  z-index: 300;
  padding: 18px;
}
.note-lightbox-panel {
  position: relative;
  width: min(96vw, 1500px);
  height: min(94vh, 1000px);
  display: flex;
  flex-direction: column;
  background: rgba(20, 21, 27, .94);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-l);
  overflow: hidden;
}
.note-lightbox-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 50%;
  background: rgba(0,0,0,.5);
  color: #fff;
  cursor: pointer;
  font-size: 1.15rem;
}
.note-lightbox-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  background: rgba(0,0,0,.5);
}
.note-lightbox-toolbar .ghost-btn {
  min-width: 34px;
  padding: 6px 9px;
}
#noteImageZoomValue {
  min-width: 48px;
  text-align: center;
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
}
.note-lightbox-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  cursor: zoom-out;
  padding: 70px 30px 30px;
}
.note-lightbox-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transform-origin: center center;
  transition: transform .12s ease;
  user-select: none;
  -webkit-user-drag: none;
}

@media (max-width: 700px) {
  .note-card-head,
  .notes-folder-title-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .note-lightbox-panel { width: 100%; height: 94vh; }
  .note-lightbox-toolbar { left: 8px; top: 8px; }
  .note-lightbox-close { right: 8px; top: 8px; }
}


/* =========================== RICH NOTES EDITOR v300.3 =========================== */
.hub-overview { min-height: 360px; }
.hub-overview-head { margin-bottom: 18px; }
.hub-overview-title { display: flex; align-items: center; gap: 10px; }
.hub-overview-title h2 { margin: 0; }
.hub-overview-title .notes-empty-icon { margin: 0; font-size: 2rem; }
.notes-overview-icon { display:inline-flex; color:#f4f5f8; }
.notes-overview-icon .notes-icon { width:25px; height:25px; }
.hub-overview-head p { margin: 7px 0 0; color: var(--text-muted); }
.notes-folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.notes-folder-card { min-height:120px; padding:14px; border:1px solid var(--border); border-radius:var(--radius-m); background:var(--surface-2); color:var(--text); display:flex; flex-direction:column; align-items:stretch; gap:7px; transition:border-color .18s,transform .18s,background .18s; }
.notes-folder-card:hover { border-color: var(--c-focus); background: var(--c-focus-soft); transform: translateY(-2px); }
.notes-folder-card strong { font-size: 1rem; }
.notes-folder-open { width:100%; border:0; background:transparent; color:inherit; cursor:pointer; text-align:left; display:grid; grid-template-columns:30px 1fr; grid-template-rows:auto auto; align-items:center; gap:4px 8px; padding:0; }
.notes-folder-open:hover strong { color:var(--c-focus); }
.notes-folder-open .notes-folder-card-icon { grid-row:span 2; }
.notes-folder-delete { align-self:flex-end; padding:4px 8px; font-size:.72rem; }
.notes-folder-card span:last-child { color: var(--text-muted); font-size: .76rem; }
.notes-folder-card-icon { width:29px; height:22px; display:inline-flex; align-items:center; color:#f2f3f7; }
.notes-folder-card-icon .notes-icon { width:24px; height:24px; }
.notes-empty-state.compact { min-height: 220px; }

.rich-editor { border: 1px solid var(--border); border-radius: var(--radius-m); overflow: hidden; background: var(--surface-2); }
.rich-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px; border-bottom: 1px solid var(--border); background: var(--surface); }
.rich-toolbar .ghost-btn, .rich-toolbar .danger-btn { padding: 6px 9px; font-size: .78rem; }
.editor-color { display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 7px; border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface-2); color: var(--text); font-weight: 700; cursor: pointer; }
.editor-color input { width: 24px; height: 24px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.rich-editor-content { min-height:min(48vh,480px); max-height:68vh; overflow:auto; padding:18px 20px; line-height:1.75; font-size:1rem; outline:none; white-space:normal; overflow-wrap:anywhere; }
.rich-editor-content:empty::before { content: attr(data-placeholder); color: var(--text-muted); pointer-events: none; }
.rich-editor-content img { max-width: 100%; height: auto; display: block; margin: 12px 0; border-radius: var(--radius-s); border: 1px solid var(--border); cursor: pointer; }
.rich-editor-content img:focus { outline: 2px solid var(--c-focus); }
.inline-note-image { max-width: 100%; height: auto; display: block; margin: 12px 0; border-radius: var(--radius-s); }
.note-card-content img { max-width: 100%; height: auto; display: block; margin: 14px 0; border-radius: var(--radius-s); border: 1px solid var(--border); cursor: zoom-in; }
.note-card-content img.is-selected { outline: 2px solid var(--c-focus); }
.note-lightbox-image { cursor: grab; touch-action: none; }
.note-lightbox-image.is-dragging { cursor: grabbing; transition: none; }
.note-lightbox-stage { overscroll-behavior: contain; }

@media (max-width: 700px) {
  .notes-folder-grid { grid-template-columns: 1fr; }
  .rich-toolbar { gap: 4px; }
  .rich-editor-content { min-height: 220px; }
}


/* Account / authentication */
.auth-modal { max-width: 520px; }
#authStatus[data-error="true"] { color: var(--c-danger, #b42318); }
#authStatus[data-error="false"] { color: var(--c-text-muted, #667085); }
#authConfirmWrap[hidden] { display: none; }


/* =========================== STUDY ORBIT GAMES — стартовый экран =========================== */
.games-panel[hidden] { display: none !important; }
.games-panel { max-width: 1440px; margin: 0 auto; padding: 24px; color: var(--text); }
.games-hero { display:flex; align-items:center; justify-content:space-between; gap:24px; padding:clamp(22px,4vw,42px); border:1px solid var(--border); border-radius:var(--radius-l); background:radial-gradient(circle at 85% 20%, color-mix(in srgb, var(--c-focus) 22%, transparent), transparent 36%), var(--surface); }
.games-eyebrow { margin:0 0 8px; color:var(--c-focus); font-size:.75rem; font-weight:800; letter-spacing:.16em; }
.games-hero h1 { margin:0; font-family:var(--font-display); font-size:clamp(1.5rem,3vw,2.3rem); line-height:1.15; }
.games-hero p:last-child { max-width:660px; margin:12px 0 0; color:var(--text-muted); line-height:1.6; }
.games-orbit-mark { display:grid; place-items:center; width:100px; height:100px; flex:0 0 auto; border:1px solid color-mix(in srgb, var(--c-focus) 60%, var(--border)); border-radius:50%; color:var(--c-focus); font-size:3.5rem; box-shadow:0 0 45px color-mix(in srgb, var(--c-focus) 18%, transparent), inset 0 0 24px color-mix(in srgb, var(--c-focus) 12%, transparent); }
.games-section-head { display:flex; align-items:center; justify-content:space-between; gap:16px; margin:26px 0 14px; }
.games-section-head h2 { margin:0; font-size:1.2rem; }
.games-section-head p { margin:5px 0 0; color:var(--text-muted); font-size:.88rem; }
.games-cards { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; }
.game-card, .games-ranking-card { overflow:hidden; border:1px solid var(--border); border-radius:var(--radius-l); background:var(--surface); }
.game-card { display:flex; flex-direction:column; }
.game-art { display:grid; place-items:center; min-height:150px; color:#eaf2ff; font-size:4.5rem; background:linear-gradient(140deg,#17253b,#0b1020 65%,#1c2550); }
.chess-art { color:#d9e7ff; text-shadow:0 8px 22px #438bff80; }
.checkers-art { font-size:2.5rem; letter-spacing:.1em; background:linear-gradient(140deg,#262a35,#10131b); }
.backgammon-art { background:linear-gradient(140deg,#3b2a20,#10131b); }
.game-card-body { display:flex; flex:1; flex-direction:column; align-items:flex-start; padding:18px; }
.game-status { display:inline-flex; align-items:center; width:max-content; max-width:100%; padding:5px 9px; border:1px solid var(--border); border-radius:999px; color:var(--text-muted); font-size:.72rem; font-weight:700; }
.game-status-next { color:var(--c-focus); border-color:color-mix(in srgb, var(--c-focus) 50%, var(--border)); }
.game-card h3 { margin:12px 0 6px; font-size:1.1rem; }
.game-card p { flex:1; margin:0 0 18px; color:var(--text-muted); font-size:.87rem; line-height:1.55; }
.game-card .primary-btn, .game-card .ghost-btn { width:100%; }
.games-ranking-card { margin-top:24px; padding:20px; }
.games-ranking-card .games-section-head { margin-top:0; }
.games-ranking-tabs { display:flex; flex-wrap:wrap; gap:8px; margin:16px 0; }
.games-ranking-tab { padding:9px 16px; border:1px solid var(--border); border-radius:999px; background:transparent; color:var(--text-muted); font:inherit; cursor:pointer; }
.games-ranking-tab.is-active { background:var(--c-focus); color:#fff; border-color:var(--c-focus); }
.games-ranking-empty { display:flex; align-items:center; gap:16px; padding:18px; border:1px dashed var(--border); border-radius:var(--radius-m); background:var(--surface-2); }
.ranking-trophy { font-size:2rem; }
.games-ranking-empty strong { display:block; }
.games-ranking-empty p { margin:6px 0 0; color:var(--text-muted); font-size:.86rem; line-height:1.5; }
.games-roadmap-note { margin-top:16px; padding:14px 16px; border-left:3px solid var(--c-focus); border-radius:0 var(--radius-s) var(--radius-s) 0; background:var(--surface-2); color:var(--text-muted); font-size:.88rem; line-height:1.55; }
.games-roadmap-note strong { color:var(--text); }
@media (max-width:900px) { .games-cards { grid-template-columns:repeat(2,minmax(0,1fr)); } .game-card-featured { grid-column:1/-1; } }
@media (max-width:600px) { .games-panel { padding:14px; } .games-hero { padding:22px; } .games-orbit-mark { width:58px; height:58px; font-size:2rem; } .games-cards { grid-template-columns:1fr; } .game-card-featured { grid-column:auto; } .game-art { min-height:120px; } .games-ranking-card { padding:14px; } }


/* STUDY ORBIT CHESS */
.chess-game-panel{margin:24px 0;padding:clamp(16px,3vw,28px);border:1px solid var(--border-color,rgba(255,255,255,.12));border-radius:22px;background:var(--surface-color,rgba(255,255,255,.035))}
.chess-panel-head{display:flex;align-items:center;justify-content:space-between;gap:18px;margin-bottom:22px}.chess-panel-head h2{margin:0 0 6px}.chess-panel-head p:not(.games-eyebrow){margin:0;opacity:.72}
.chess-game-layout{display:grid;grid-template-columns:minmax(0,1fr) minmax(220px,290px);gap:24px;align-items:start}.chess-board-wrap{width:100%;max-width:640px;margin:auto;padding:8px;border-radius:14px;background:#1a2130;box-shadow:0 18px 50px rgba(0,0,0,.24)}
.chess-board{display:grid;grid-template-columns:repeat(8,minmax(0,1fr));width:100%;aspect-ratio:1;overflow:hidden;border-radius:7px}.chess-square{position:relative;display:flex;align-items:center;justify-content:center;aspect-ratio:1;border:0;padding:0;cursor:pointer;font-family:"Segoe UI Symbol","Noto Sans Symbols 2",serif;font-size:clamp(25px,5.3vw,52px);line-height:1;user-select:none}
.chess-square.light{background:#e8e5dc;color:#202634}.chess-square.dark{background:#6c88a2;color:#101927}.chess-square:focus-visible{outline:3px solid #a8e1ff;outline-offset:-4px;z-index:2}.chess-square.selected{box-shadow:inset 0 0 0 4px #b5ed73}.chess-square.last-move{background-image:linear-gradient(rgba(191,234,104,.28),rgba(191,234,104,.28))}.chess-square.legal-target:after{content:"";position:absolute;width:23%;height:23%;border-radius:50%;background:rgba(21,34,45,.32)}.chess-square.legal-capture:after{content:"";position:absolute;inset:4px;border:4px solid rgba(31,45,59,.38);border-radius:50%}.chess-square .chess-coordinate{position:absolute;left:4px;bottom:2px;font:600 10px/1 sans-serif;opacity:.7}
.chess-side-panel{display:flex;flex-direction:column;gap:14px}.chess-turn-card,.chess-captured{padding:15px;border:1px solid var(--border-color,rgba(255,255,255,.12));border-radius:14px;background:var(--card-bg,rgba(255,255,255,.035))}.chess-turn-card{display:flex;gap:11px;align-items:center}.chess-turn-card small,.chess-captured small{display:block;font-size:10px;letter-spacing:.08em;opacity:.62;margin-bottom:5px}.chess-turn-card strong{font-size:14px}.chess-status-dot{width:10px;height:10px;border-radius:50%;background:#a8e1ff;flex:none;box-shadow:0 0 12px rgba(168,225,255,.6)}.chess-captured div{min-height:28px;font-family:"Segoe UI Symbol","Noto Sans Symbols 2",serif;font-size:25px;letter-spacing:2px}.chess-help{font-size:12px;line-height:1.55;opacity:.68;margin:0}
@media(max-width:760px){.chess-game-layout{grid-template-columns:1fr}.chess-board-wrap{max-width:100%}.chess-panel-head{align-items:flex-start;flex-direction:column}.chess-panel-head .ghost-btn{width:100%}.chess-side-panel{display:grid;grid-template-columns:1fr 1fr}.chess-side-panel .chess-turn-card,.chess-side-panel .chess-help,.chess-side-panel .full-width{grid-column:1/-1}}


/* Chess fullscreen modal: keeps the game separate from the Games catalogue */
.chess-game-modal[hidden]{display:none!important}
.chess-game-modal{position:fixed!important;inset:12px!important;z-index:9999!important;margin:0!important;padding:clamp(14px,2.2vw,30px)!important;overflow:auto!important;border:1px solid rgba(139,157,190,.28)!important;border-radius:24px!important;background:radial-gradient(ellipse at 18% 0%,rgba(70,83,143,.22),transparent 45%),#10131b!important;box-shadow:0 28px 100px rgba(0,0,0,.72)!important;color:#edf2ff!important;backdrop-filter:blur(24px)}
body.chess-modal-open{overflow:hidden!important}
.chess-panel-head{max-width:1180px;margin:0 auto 22px!important;padding:4px 2px 18px;border-bottom:1px solid rgba(255,255,255,.09)}
.chess-game-layout{max-width:1180px;margin:0 auto!important;grid-template-columns:minmax(0, min(68vh,680px)) minmax(250px,320px)!important;justify-content:center!important;align-items:center!important;gap:clamp(20px,4vw,54px)!important}
.chess-board-wrap{max-width: min(68vh,680px)!important;width:100%;padding:9px!important;border:1px solid rgba(150,177,220,.22);border-radius:18px!important;background:linear-gradient(145deg,#202b40,#111827)!important;box-shadow:0 22px 70px rgba(0,0,0,.42),inset 0 1px rgba(255,255,255,.08)!important}
.chess-board{border-radius:10px!important;overflow:hidden}
.chess-square{transition:background-color .18s ease,filter .18s ease!important;font-size:clamp(28px,5.3vw,56px)!important;text-shadow:0 2px 2px rgba(0,0,0,.14)}
.chess-square.light{background:#e7e9f0!important;color:#303b50!important}.chess-square.dark{background:#7186a8!important;color:#f5f7ff!important}
.chess-square:hover{filter:brightness(1.12)}.chess-square.selected{box-shadow:inset 0 0 0 4px #b6f28b!important;z-index:1}
.chess-square.last-move{background-image:linear-gradient(rgba(180,236,119,.32),rgba(180,236,119,.32))!important}
.chess-square.legal-target:after{background:#d7f4a4!important;box-shadow:0 0 12px rgba(215,244,164,.4)}
.chess-square.legal-capture:after{border-color:#ffcf86!important;box-shadow:inset 0 0 0 2px rgba(255,207,134,.2)}
.chess-side-panel{gap:16px!important}.chess-turn-card,.chess-captured{border-color:rgba(155,174,210,.16)!important;background:linear-gradient(145deg,rgba(35,43,61,.92),rgba(22,27,39,.92))!important;border-radius:16px!important;padding:18px!important;box-shadow:0 8px 28px rgba(0,0,0,.12)}
.chess-turn-card strong{font-size:15px!important}.chess-status-dot{background:#b6f28b!important;box-shadow:0 0 15px rgba(182,242,139,.5)!important}
.chess-captured div{min-height:35px!important;line-height:1.5;font-size:27px!important;overflow-wrap:anywhere}
.chess-side-panel .primary-btn{min-height:46px;border-radius:12px!important;background:linear-gradient(110deg,#6852d9,#4736a8)!important;box-shadow:0 8px 24px rgba(78,58,188,.24)}
.chess-help{font-size:13px!important;line-height:1.7!important;color:#aeb9d0;opacity:1!important}
.chess-moving-piece{position:fixed;z-index:10020;display:flex;align-items:center;justify-content:center;pointer-events:none;font-family:"Segoe UI Symbol","Noto Sans Symbols 2",serif;line-height:1;text-shadow:0 5px 12px rgba(0,0,0,.32);will-change:transform;transition:transform .24s cubic-bezier(.2,.75,.25,1),opacity .24s ease}
.chess-captured-flash{animation:capturedFlash .45s ease}
@keyframes capturedFlash{0%{box-shadow:0 0 0 0 rgba(255,190,108,.0)}45%{box-shadow:0 0 0 3px rgba(255,190,108,.55)}100%{box-shadow:0 0 0 0 rgba(255,190,108,0)}}
@media(max-width:800px){.chess-game-modal{inset:5px!important;border-radius:16px!important}.chess-game-layout{grid-template-columns:minmax(0,1fr)!important;gap:14px!important}.chess-board-wrap{max-width:min(78vw,62vh)!important}.chess-side-panel{display:grid;grid-template-columns:1fr 1fr}.chess-side-panel .chess-turn-card,.chess-side-panel .chess-help,.chess-side-panel .full-width{grid-column:1/-1}.chess-captured{padding:12px!important}}
@media(prefers-reduced-motion:reduce){.chess-square,.chess-moving-piece{transition:none!important}}


/* Orbit Chess — Neutral Papyrus visual identity */
.chess-game-modal{background:radial-gradient(ellipse at 12% 0%,rgba(202,203,205,.12),transparent 44%),#202428!important;color:#f6f2ee!important;border-color:rgba(202,203,205,.28)!important}
.chess-board-wrap{background:linear-gradient(145deg,#b3b9c1,#77726e)!important;border:1px solid #cacbcd!important;box-shadow:0 24px 65px rgba(0,0,0,.32),inset 0 1px rgba(255,255,255,.5)!important}
.chess-square.light{background:#f6f2ee!important;color:#f6f2ee!important}
.chess-square.dark{background:#323841!important;color:#323841!important}
/* Piece fills make the two armies immediately distinguishable, even on similar silhouettes. */
.chess-square .chess-piece{display:inline-block;line-height:1;transform:translateY(-1px)}
.chess-square.white-piece{color:#f6f2ee!important;-webkit-text-stroke:1px #77726e;text-shadow:0 2px 0 #b3b9c1,0 4px 7px rgba(25,29,33,.5)!important}
.chess-square.black-piece{color:#242a30!important;-webkit-text-stroke:1px #111519;text-shadow:0 2px 0 #77726e,0 4px 7px rgba(0,0,0,.55)!important}
.chess-square.selected{box-shadow:inset 0 0 0 4px #b3b9c1!important;z-index:1}
.chess-square.last-move{background-image:linear-gradient(rgba(179,185,193,.3),rgba(179,185,193,.3))!important}
.chess-square.legal-target:after{background:#b3b9c1!important;box-shadow:0 0 12px rgba(179,185,193,.55)!important}
.chess-square.legal-capture:after{border-color:#f6f2ee!important;box-shadow:inset 0 0 0 2px rgba(50,56,65,.25)!important}
.chess-turn-card,.chess-captured{background:linear-gradient(145deg,rgba(50,56,65,.92),rgba(35,39,43,.96))!important;border-color:rgba(202,203,205,.2)!important}
.chess-side-panel .primary-btn{background:linear-gradient(110deg,#77726e,#323841)!important;box-shadow:0 8px 24px rgba(0,0,0,.2)!important}
.chess-result-overlay[hidden]{display:none!important}.chess-result-overlay{position:fixed;inset:0;z-index:10050;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(12,14,16,.72);backdrop-filter:blur(10px);animation:chessResultFade .22s ease}
.chess-result-card{width:min(100%,470px);padding:30px;border:1px solid rgba(202,203,205,.34);border-radius:24px;background:linear-gradient(145deg,#323841,#202428);box-shadow:0 30px 100px rgba(0,0,0,.5);text-align:center;color:#f6f2ee;animation:chessResultRise .28s cubic-bezier(.2,.8,.2,1)}
.chess-result-icon{display:grid;place-items:center;width:68px;height:68px;margin:0 auto 14px;border-radius:20px;background:rgba(179,185,193,.13);border:1px solid rgba(202,203,205,.28);font:48px/1 Georgia,serif;color:#f6f2ee}
.chess-result-card .games-eyebrow{margin:0 0 8px;color:#b3b9c1;letter-spacing:.14em;font-size:11px}.chess-result-card h2{font-size:30px;margin:0 0 8px}.chess-result-description{margin:0 auto 22px;max-width:350px;color:#cacbcd;line-height:1.55}
.chess-result-stats{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:22px;text-align:left}.chess-result-stats div{padding:13px;border-radius:13px;background:rgba(10,12,14,.22);border:1px solid rgba(202,203,205,.12)}.chess-result-stats span{display:block;font-size:11px;color:#b3b9c1;margin-bottom:6px}.chess-result-stats strong{font-size:20px;color:#f6f2ee;font-variant-numeric:tabular-nums}.chess-result-actions{display:flex;gap:10px}.chess-result-actions button{flex:1;min-height:44px;border-radius:12px!important}.chess-result-actions .primary-btn{background:#cacbcd!important;color:#202428!important;box-shadow:none!important}
@keyframes chessResultFade{from{opacity:0}to{opacity:1}}@keyframes chessResultRise{from{opacity:0;transform:translateY(12px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}
@media(max-width:500px){.chess-result-card{padding:22px 16px}.chess-result-actions{flex-direction:column}.chess-result-stats strong{font-size:18px}}


/* Phase 5: bot move animation, clear royal crown and pawn promotion choice */
.chess-piece-glyph{position:relative;z-index:1;display:inline-block;line-height:1;filter:drop-shadow(0 3px 2px rgba(0,0,0,.22))}
.chess-square.white-piece .chess-piece-glyph{color:#f6f2ee;text-shadow:0 1px 0 #8e9399,0 3px 4px rgba(24,30,38,.38);-webkit-text-stroke:.35px #7b828a}
.chess-square.black-piece .chess-piece-glyph{color:#323841;text-shadow:0 1px 0 #777f89,0 4px 5px rgba(0,0,0,.42);-webkit-text-stroke:.35px #151a20}
.chess-king-crown{position:absolute;z-index:3;top:7%;left:50%;transform:translateX(-50%);font-family:serif;font-size:clamp(10px,1.35vw,16px);line-height:1;color:#e9bd59;text-shadow:0 0 3px #fff0b5,0 1px 2px #6c4a0d;pointer-events:none}
.chess-square.white-piece .chess-king-crown{color:#e8bd58}.chess-square.black-piece .chess-king-crown{color:#f0c75f}
.chess-moving-piece.white-piece{color:#f6f2ee;text-shadow:0 0 10px rgba(255,255,255,.3),0 5px 12px rgba(0,0,0,.35)}
.chess-moving-piece.black-piece{color:#323841;text-shadow:0 0 7px rgba(191,204,222,.18),0 5px 12px rgba(0,0,0,.5)}
.chess-promotion-overlay{position:fixed;inset:0;z-index:10050;display:grid;place-items:center;padding:20px;background:rgba(8,11,17,.72);backdrop-filter:blur(12px)}
.chess-promotion-overlay[hidden]{display:none!important}.chess-promotion-card{width:min(480px,100%);padding:28px;border:1px solid rgba(179,185,193,.3);border-radius:22px;background:linear-gradient(145deg,#f6f2ee,#dfe2e5);color:#323841;box-shadow:0 28px 90px rgba(0,0,0,.48);animation:promotionEnter .22s ease-out}
.chess-promotion-card h2{margin:4px 0 8px;font-size:clamp(22px,4vw,28px)}.chess-promotion-card>p:not(.games-eyebrow){margin:0 0 20px;color:#626a73;font-size:14px;line-height:1.5}
.chess-promotion-options{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}.chess-promotion-options button{display:flex;flex-direction:column;align-items:center;gap:9px;padding:15px 6px;border:1px solid #c4c9cf;border-radius:14px;background:#fffdfa;color:#323841;cursor:pointer;transition:transform .16s ease,border-color .16s ease,box-shadow .16s ease}.chess-promotion-options button:hover,.chess-promotion-options button:focus-visible{transform:translateY(-3px);border-color:#7c69d7;box-shadow:0 8px 20px rgba(71,54,168,.15);outline:none}.chess-promotion-options button span{font-family:"Segoe UI Symbol","Noto Sans Symbols 2",serif;font-size:clamp(32px,8vw,48px);line-height:1}.chess-promotion-options button strong{font-size:12px}
.chess-game-ended .chess-king-crown{animation:kingCrownFall .6s cubic-bezier(.2,.7,.2,1) forwards;transform-origin:center}
@keyframes kingCrownFall{0%{transform:translateX(-50%) rotate(0) translateY(0);opacity:1}45%{transform:translateX(-35%) rotate(35deg) translateY(4px)}100%{transform:translateX(5%) rotate(95deg) translateY(17px);opacity:0}}
@keyframes promotionEnter{from{opacity:0;transform:translateY(8px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}
@media(max-width:460px){.chess-promotion-card{padding:20px 14px}.chess-promotion-options{gap:6px}.chess-promotion-options button{padding:12px 3px}.chess-promotion-options button strong{font-size:11px}}


/* Phase 6: stronger piece legibility and a brighter, properly seated royal crown. */
.chess-square{isolation:isolate}
.chess-square .chess-piece-glyph{font-size:clamp(34px,6vw,64px)!important;line-height:1!important;transform:translateY(1px) scale(1.04);filter:drop-shadow(0 3px 1px rgba(0,0,0,.5)) drop-shadow(0 0 1px rgba(0,0,0,.32))}
.chess-square.white-piece .chess-piece-glyph{color:#fffdf7!important;-webkit-text-stroke:1.15px #5e6268!important;text-shadow:0 1px 0 #fff,0 3px 0 #b3b9c1,0 5px 7px rgba(24,28,33,.58)!important}
.chess-square.black-piece .chess-piece-glyph{color:#252b33!important;-webkit-text-stroke:1.25px #080b0f!important;text-shadow:0 -1px 0 #7c8590,0 2px 0 #9aa1aa,0 5px 7px rgba(0,0,0,.68)!important}
.chess-king-crown{top:3%!important;left:50%!important;transform:translateX(-50%) rotate(-2deg)!important;font-size:clamp(13px,1.8vw,21px)!important;color:#ffcf45!important;-webkit-text-stroke:.6px #8e5b08;text-shadow:0 0 2px #fff4b0,0 0 8px rgba(255,190,35,.95),0 2px 1px #6a4100!important;filter:drop-shadow(0 2px 2px rgba(0,0,0,.7))}
.chess-square .chess-king-crown{line-height:.85!important}
.chess-game-ended .chess-king-crown{animation:kingCrownFall .62s cubic-bezier(.2,.7,.2,1) forwards!important}
.chess-fallen-crown{position:absolute;z-index:8;left:58%;top:58%;font-family:Georgia,serif;font-size:clamp(15px,2vw,24px);line-height:1;color:#ffca36;-webkit-text-stroke:.6px #7d4c00;text-shadow:0 0 5px rgba(255,207,69,.85),0 2px 1px #6a4100;transform:rotate(72deg) translate(3px,8px) scale(.75);opacity:0;pointer-events:none;filter:drop-shadow(0 2px 2px rgba(0,0,0,.75));animation:crownDropToFloor .7s cubic-bezier(.2,.75,.25,1) forwards}
.chess-fallen-crown.is-resting{opacity:1;transform:rotate(72deg) translate(3px,8px) scale(.75);animation:none}
@keyframes crownDropToFloor{0%{opacity:1;transform:translate(-10px,-20px) rotate(-15deg) scale(1.15)}55%{opacity:1;transform:translate(6px,10px) rotate(110deg) scale(.8)}78%{opacity:1;transform:translate(3px,5px) rotate(63deg) scale(.78)}100%{opacity:1;transform:rotate(72deg) translate(3px,8px) scale(.75)}}
@media(max-width:600px){.chess-square .chess-piece-glyph{font-size:clamp(27px,7vw,42px)!important}.chess-king-crown{font-size:clamp(10px,3vw,15px)!important}}


/* Phase 7 — mobile responsiveness, consistent piece silhouettes, reliable motion */
.chess-board{touch-action:manipulation;overscroll-behavior:contain;contain:layout paint;}
.chess-square{-webkit-tap-highlight-color:transparent;touch-action:manipulation;user-select:none;-webkit-user-select:none;}
.chess-square .chess-piece-glyph{pointer-events:none;font-family:'DejaVu Sans','Segoe UI Symbol','Noto Sans Symbols 2',serif;font-variant-emoji:text;}
/* Identical glyph silhouettes on both sides; side identity comes from contrasting material. */
.chess-square.white-piece .chess-piece-glyph{color:#fffdf7!important;-webkit-text-stroke:1.35px #505760!important;text-shadow:0 1px 0 #fff,0 3px 0 #c2c7cd,0 5px 7px rgba(24,28,33,.62)!important;}
.chess-square.black-piece .chess-piece-glyph{color:#20252c!important;-webkit-text-stroke:1.4px #080b0f!important;text-shadow:0 -1px 0 #9ba4af,0 2px 0 #59616b,0 5px 7px rgba(0,0,0,.78)!important;}
.chess-moving-piece{pointer-events:none;will-change:transform;backface-visibility:hidden;contain:layout paint;}
.chess-square.legal-target:after{pointer-events:none;}
@media(max-width:600px){.chess-square .chess-piece-glyph{font-size:clamp(29px,7.8vw,44px)!important;-webkit-text-stroke:1.1px!important}.chess-board-wrap{max-width:min(88vw,58vh)!important}.chess-board{border-radius:5px}}
@media(prefers-reduced-motion:reduce){.chess-moving-piece{transition:none!important}}


/* Chess mode picker and integrated chess leaderboard */
.chess-mode-selection{max-width:1120px;margin:0 auto;padding:8px 2px 24px}
.chess-mode-intro{margin:8px 0 24px}.chess-mode-intro h2{margin:5px 0 8px}.chess-mode-intro>p:last-child{opacity:.72;margin:0;max-width:680px}
.chess-mode-cards{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px;margin-bottom:24px}
.chess-mode-card{padding:clamp(18px,2.4vw,28px);border:1px solid rgba(160,175,205,.2);border-radius:20px;background:linear-gradient(145deg,rgba(255,255,255,.055),rgba(255,255,255,.018));display:flex;flex-direction:column;align-items:flex-start;min-width:0}
.chess-mode-featured{border-color:rgba(139,112,255,.45);background:radial-gradient(ellipse at 0 0,rgba(109,80,220,.18),transparent 62%),linear-gradient(145deg,rgba(255,255,255,.055),rgba(255,255,255,.018))}
.chess-mode-icon{width:48px;height:48px;display:grid;place-items:center;border-radius:15px;background:rgba(135,111,255,.13);font-size:29px;color:#d6c8ff;margin-bottom:15px}
.chess-mode-tag{font-size:10px;letter-spacing:.14em;font-weight:800;color:#b6a5ff}.chess-mode-card h3{font-size:23px;margin:7px 0}.chess-mode-card p{opacity:.75;line-height:1.55;margin:0 0 18px}.chess-difficulty-label{display:block;font-size:12px;font-weight:700;margin:0 0 9px}.chess-difficulty-control{margin:0 0 15px;padding:12px 13px 10px;border:1px solid rgba(160,175,205,.2);border-radius:12px;background:rgba(12,15,22,.48)}.chess-difficulty-readout{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}.chess-difficulty-readout strong{font-size:16px;color:#c7b8ff}.chess-difficulty-readout span{font-size:12px;opacity:.76}.chess-difficulty-slider{display:block;width:100%;height:22px;margin:0;accent-color:#9a7bff;cursor:pointer}.chess-difficulty-scale{display:flex;justify-content:space-between;gap:10px;font-size:10px;opacity:.65;margin-top:3px}.chess-difficulty-hint{font-size:10px!important;line-height:1.4!important;opacity:.62!important;margin:8px 0 0!important}.chess-mode-card .full-width{margin-top:auto}.chess-mode-note{display:block;opacity:.6;font-size:11px;line-height:1.5;margin-top:12px}.chess-mode-selection .games-ranking-card{margin-top:26px;background:rgba(255,255,255,.025)}
#chessBoardArea[hidden],#chessModeSelection[hidden]{display:none!important}
@media(max-width:680px){.chess-mode-cards{grid-template-columns:1fr}.chess-mode-card{padding:20px}.chess-mode-selection .games-ranking-tabs{flex-wrap:wrap}.chess-mode-selection .games-ranking-card{padding:15px}}


/* Phase 10.8 — Premium dimensional pieces, keep existing board colors */
.chess-square .chess-piece-glyph{
  display:inline-block;
  position:relative;
  z-index:1;
  line-height:1;
  font-weight:400;
  transform:translateY(-1px);
  transition:filter .14s ease,transform .14s ease;
  filter:drop-shadow(0 2px 0 rgba(0,0,0,.20)) drop-shadow(0 5px 4px rgba(0,0,0,.22));
}
.chess-square.white-piece .chess-piece-glyph{
  color:#f7f1e5!important;
  -webkit-text-stroke:1px #77736b!important;
  text-shadow:0 1px 0 #fffdf7,0 2px 0 #d1c9bb,0 4px 5px rgba(20,23,28,.36)!important;
}
.chess-square.black-piece .chess-piece-glyph{
  color:#303640!important;
  -webkit-text-stroke:1px #151a21!important;
  text-shadow:0 1px 0 #7a818a,0 2px 0 #252a32,0 5px 6px rgba(0,0,0,.48)!important;
}
.chess-square.white-piece:hover .chess-piece-glyph,
.chess-square.black-piece:hover .chess-piece-glyph{
  transform:translateY(-2px);
  filter:drop-shadow(0 3px 1px rgba(0,0,0,.24)) drop-shadow(0 7px 5px rgba(0,0,0,.26));
}
.chess-square.selected{
  box-shadow:inset 0 0 0 3px #c5a9ff, inset 0 0 16px rgba(159,124,255,.22);
}
.chess-moving-piece.white-piece{
  color:#f7f1e5!important;
  -webkit-text-stroke:1px #77736b;
  text-shadow:0 1px 0 #fffdf7,0 2px 0 #d1c9bb,0 5px 10px rgba(20,23,28,.36)!important;
}
.chess-moving-piece.black-piece{
  color:#303640!important;
  -webkit-text-stroke:1px #151a21;
  text-shadow:0 1px 0 #7a818a,0 2px 0 #252a32,0 5px 10px rgba(0,0,0,.48)!important;
}
@media(max-width:680px){
  .chess-square .chess-piece-glyph{
    -webkit-text-stroke-width:.8px;
  }
}


/* Phase 10.9 — Mobile chess animation performance */
@media (max-width: 680px), (pointer: coarse) {
  .chess-square { transition: background-color .08s linear !important; filter:none!important; }
  .chess-square .chess-piece-glyph { filter:none!important; transform:translateZ(0)!important; text-shadow:0 1px 0 rgba(255,255,255,.2),0 2px 3px rgba(0,0,0,.24)!important; will-change:auto; }
  .chess-square.white-piece .chess-piece-glyph { -webkit-text-stroke:.75px #5e6268!important; text-shadow:0 1px 0 rgba(255,255,255,.7),0 2px 3px rgba(20,23,28,.2)!important; }
  .chess-square.black-piece .chess-piece-glyph { -webkit-text-stroke:.8px #151a21!important; text-shadow:0 1px 0 rgba(230,234,240,.42),0 2px 3px rgba(0,0,0,.24)!important; }
  .chess-moving-piece { transition:none!important; filter:none!important; will-change:transform; text-shadow:0 2px 4px rgba(0,0,0,.24)!important; }
  .chess-moving-piece.white-piece,.chess-moving-piece.black-piece { text-shadow:0 2px 4px rgba(0,0,0,.24)!important; }
  .chess-captured-flash { animation-duration:.22s!important; }
  .chess-result-overlay { backdrop-filter:none!important; }
}
@media (hover:none) {
  .chess-square.white-piece:hover .chess-piece-glyph,.chess-square.black-piece:hover .chess-piece-glyph { transform:none!important; filter:none!important; }
}


/* Phase 11.0 — Restore subtle motion and improve side separation on mobile */
@media (max-width: 680px), (pointer: coarse) {
  .chess-moving-piece {
    transition: none !important;
    will-change: transform;
    filter: none !important;
    text-shadow: 0 2px 4px rgba(0,0,0,.25) !important;
  }
  .chess-square .chess-piece-glyph {
    transition: transform .12s ease-out !important;
    transform: translateY(-1px);
  }
  .chess-square.white-piece .chess-piece-glyph {
    color: #fff8e9 !important;
    -webkit-text-stroke: 1.25px #555b64 !important;
    text-shadow: 0 1px 0 #fffdf8, 0 2px 2px rgba(21,25,32,.24) !important;
  }
  .chess-square.black-piece .chess-piece-glyph {
    color: #272d36 !important;
    -webkit-text-stroke: 1.35px #080b10 !important;
    text-shadow: 0 -1px 0 rgba(230,235,242,.7), 0 2px 3px rgba(0,0,0,.38) !important;
  }
  .chess-square.white-piece::before,
  .chess-square.black-piece::before {
    content: "";
    position: absolute;
    width: 68%;
    height: 15%;
    left: 16%;
    bottom: 9%;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
  }
  .chess-square.white-piece::before {
    background: rgba(40,45,54,.14);
    box-shadow: 0 1px 0 rgba(255,255,255,.42);
  }
  .chess-square.black-piece::before {
    background: rgba(0,0,0,.28);
    box-shadow: 0 -1px 0 rgba(235,239,245,.18);
  }
  .chess-square.selected .chess-piece-glyph {
    transform: translateY(-2px) scale(1.035);
  }
}
@media (prefers-reduced-motion: reduce) {
  .chess-square .chess-piece-glyph {
    transition: none !important;
  }
}

.chess-square{position:relative;isolation:isolate}
.chess-square .chess-piece-glyph{z-index:1;position:relative}


/* Phase 11.1 — Remove artificial foot shadows; improve contrast and restore visible motion */
@media (max-width: 680px), (pointer: coarse) {
  .chess-square.white-piece::before,
  .chess-square.black-piece::before {
    content: none !important;
    display: none !important;
  }
  .chess-square .chess-piece-glyph {
    filter: none !important;
    transition: transform .14s ease-out !important;
    transform: translateY(-1px);
  }
  .chess-square.white-piece .chess-piece-glyph {
    color: #fffaf0 !important;
    -webkit-text-stroke: 1.55px #414852 !important;
    paint-order: stroke fill;
    text-shadow: 0 1px 0 rgba(255,255,255,.9), 0 2px 2px rgba(12,17,25,.22) !important;
  }
  .chess-square.black-piece .chess-piece-glyph {
    color: #242a33 !important;
    -webkit-text-stroke: 1.6px #070a0f !important;
    paint-order: stroke fill;
    text-shadow: 0 -1px 0 rgba(245,247,250,.85), 0 1px 0 rgba(0,0,0,.9) !important;
  }
  .chess-moving-piece {
    transition: none !important;
    filter: none !important;
    will-change: transform;
    backface-visibility: hidden;
  }
  .chess-moving-piece.white-piece {
    color: #fffaf0 !important;
    -webkit-text-stroke: 1.55px #414852;
    paint-order: stroke fill;
    text-shadow: 0 1px 0 rgba(255,255,255,.9), 0 2px 3px rgba(12,17,25,.25) !important;
  }
  .chess-moving-piece.black-piece {
    color: #242a33 !important;
    -webkit-text-stroke: 1.6px #070a0f;
    paint-order: stroke fill;
    text-shadow: 0 -1px 0 rgba(245,247,250,.85), 0 1px 0 rgba(0,0,0,.9) !important;
  }
  .chess-square.selected .chess-piece-glyph {
    transform: translateY(-2px) scale(1.04);
  }
}
@media (prefers-reduced-motion: reduce) {
  .chess-square .chess-piece-glyph { transition: none !important; }
}


/* Phase 12.0 — Chess player profile and local game history */
.chess-player-hub{margin:22px 0 4px;border:1px solid rgba(165,176,196,.18);border-radius:18px;padding:18px;background:rgba(20,24,32,.48)}
.chess-hub-tabs{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:16px}
.chess-hub-tab{border:1px solid rgba(165,176,196,.2);border-radius:10px;background:transparent;color:inherit;padding:10px 13px;font:inherit;font-size:13px;cursor:pointer}
.chess-hub-tab.is-active{background:rgba(153,125,255,.15);border-color:rgba(153,125,255,.55);color:#d3c5ff}
.chess-player-card{display:flex;align-items:center;gap:14px;padding:16px;border:1px solid rgba(165,176,196,.18);border-radius:14px;background:rgba(255,255,255,.025)}
.chess-player-avatar{width:52px;height:52px;flex:0 0 52px;border-radius:16px;display:grid;place-items:center;background:linear-gradient(145deg,#a58aff,#5c4b9b);color:#fff;font-size:24px;font-weight:800}
.chess-player-identity{min-width:0;flex:1}
.chess-player-identity .games-eyebrow{font-size:10px;letter-spacing:.12em}
.chess-player-identity h3{margin:4px 0;font-size:18px;overflow-wrap:anywhere}
.chess-player-identity p{margin:0;color:var(--muted,#a6a8b0);font-size:12px;line-height:1.4}
.chess-rating-pill{display:flex;flex-direction:column;align-items:center;justify-content:center;min-width:76px;padding:10px;border-radius:12px;background:rgba(153,125,255,.12);border:1px solid rgba(153,125,255,.25)}
.chess-rating-pill strong{font-size:24px;line-height:1.1}
.chess-rating-pill span{font-size:9px;color:var(--muted,#a6a8b0);text-align:center;margin-top:4px}
.chess-player-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:9px;margin-top:12px}
.chess-player-stats>div{padding:12px 10px;border-radius:12px;background:rgba(255,255,255,.035);border:1px solid rgba(165,176,196,.12);display:flex;flex-direction:column;gap:6px}
.chess-player-stats span{font-size:11px;color:var(--muted,#a6a8b0)}
.chess-player-stats strong{font-size:21px}
.chess-hub-note{font-size:12px;line-height:1.5;color:var(--muted,#a6a8b0);margin:13px 2px 0}
.chess-history-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px}
.chess-history-head h3{font-size:17px;margin:0 0 4px}
.chess-history-head p{font-size:12px;color:var(--muted,#a6a8b0);margin:0}
.chess-history-list{display:flex;flex-direction:column;gap:8px}
.chess-history-empty{padding:22px 12px;text-align:center;border:1px dashed rgba(165,176,196,.2);border-radius:12px;color:var(--muted,#a6a8b0);font-size:13px}
.chess-history-item{display:flex;align-items:center;gap:11px;padding:12px;border:1px solid rgba(165,176,196,.15);border-radius:12px;background:rgba(255,255,255,.025);min-width:0}
.chess-history-result{width:30px;height:30px;flex:0 0 30px;border-radius:9px;display:grid;place-items:center;font-weight:800}
.chess-history-result.win{background:rgba(96,196,135,.16);color:#8ce2aa}
.chess-history-result.loss{background:rgba(235,105,115,.15);color:#ff9da5}
.chess-history-result.draw{background:rgba(155,163,175,.16);color:#c5cbd4}
.chess-history-info{display:flex;flex:1;min-width:0;flex-direction:column;gap:4px}
.chess-history-info strong{font-size:13px}
.chess-history-info span{font-size:11px;color:var(--muted,#a6a8b0);overflow-wrap:anywhere}
.chess-history-mode{font-size:10px;color:#c5b7ff;white-space:nowrap}
@media(max-width:520px){
 .chess-player-hub{padding:12px;margin-top:16px}
 .chess-player-card{padding:12px;gap:10px;flex-wrap:wrap}
 .chess-player-avatar{width:44px;height:44px;flex-basis:44px;border-radius:13px}
 .chess-player-identity h3{font-size:16px}
 .chess-rating-pill{margin-left:auto;min-width:68px;padding:8px}
 .chess-player-stats{gap:6px}
 .chess-player-stats>div{padding:9px 7px}
 .chess-player-stats span{font-size:10px}
 .chess-player-stats strong{font-size:18px}
 .chess-history-mode{display:none}
}


/* Phase 13.0 — Online matchmaking status */
.chess-matchmaking-status{margin-top:10px;padding:12px 13px;border:1px solid rgba(165,176,196,.2);border-radius:11px;background:rgba(12,15,22,.42);font-size:12px;line-height:1.5;color:#d7d9e0}
.chess-matchmaking-status[data-kind="success"]{border-color:rgba(105,205,146,.38);color:#a6edbf;background:rgba(56,140,87,.09)}
.chess-matchmaking-status[data-kind="error"]{border-color:rgba(239,116,126,.38);color:#ffb5bc;background:rgba(140,56,65,.1)}
.chess-matchmaking-status[data-kind="muted"]{color:var(--muted,#a6a8b0)}
#btnRatedChess:disabled{opacity:.68;cursor:wait}


/* Phase 13.1 — Search timer, bot while waiting, match confirmation */
.chess-matchmaking-elapsed{margin-top:8px;font-size:12px;color:var(--muted,#a6a8b0)}
.chess-matchmaking-elapsed strong{font-variant-numeric:tabular-nums;color:#d3c5ff;margin-left:5px;font-size:14px}
.chess-bot-offer,.chess-match-found-offer,.chess-bot-resume-offer{margin-top:12px;padding:15px;border-radius:14px;border:1px solid rgba(153,125,255,.36);background:linear-gradient(145deg,rgba(80,59,142,.18),rgba(16,19,26,.9));box-shadow:0 10px 30px rgba(0,0,0,.16)}
.chess-bot-offer h4,.chess-match-found-offer h4,.chess-bot-resume-offer h4{margin:5px 0 7px;font-size:16px}
.chess-bot-offer p,.chess-match-found-offer p,.chess-bot-resume-offer p{margin:0 0 12px;font-size:12px;line-height:1.5;color:var(--muted,#a6a8b0)}
.chess-bot-offer-actions,.chess-match-found-actions,.chess-bot-resume-actions{display:flex;gap:8px;flex-wrap:wrap}
.chess-bot-offer-actions button,.chess-match-found-actions button,.chess-bot-resume-actions button{flex:1;min-width:130px}
.chess-match-found-offer{border-color:rgba(105,205,146,.4)}
@media(max-width:520px){.chess-bot-offer-actions,.chess-match-found-actions,.chess-bot-resume-actions{flex-direction:column}.chess-bot-offer-actions button,.chess-match-found-actions button,.chess-bot-resume-actions button{width:100%}}


/* Phase 13.2 — Persistent matchmaking timer while training against Stockfish */
.chess-search-persistent-widget{position:fixed;right:18px;bottom:18px;z-index:9999;display:flex;align-items:center;gap:12px;width:min(390px,calc(100vw - 24px));padding:13px 14px;border-radius:16px;border:1px solid rgba(153,125,255,.42);background:rgba(19,22,30,.96);box-shadow:0 14px 42px rgba(0,0,0,.38);backdrop-filter:blur(14px);color:#f0edf8}
.chess-search-persistent-widget[hidden]{display:none!important}
.chess-search-persistent-icon{width:38px;height:38px;flex:0 0 38px;border-radius:12px;display:grid;place-items:center;background:rgba(153,125,255,.15);font-size:20px}
.chess-search-persistent-copy{display:flex;flex:1;min-width:0;flex-direction:column;gap:3px}
.chess-search-persistent-label{font-size:9px;font-weight:800;letter-spacing:.08em;color:#c8b9ff}
.chess-search-persistent-copy strong{font-size:21px;line-height:1.05;font-variant-numeric:tabular-nums}
.chess-search-persistent-copy>span:last-child{font-size:10px;line-height:1.3;color:#b5b7c2}
.chess-search-return-btn{flex:0 0 auto;border:1px solid rgba(181,166,255,.36);border-radius:9px;padding:9px 11px;background:rgba(153,125,255,.13);color:#e6ddff;font:inherit;font-size:11px;font-weight:700;cursor:pointer}
@media(max-width:520px){
 .chess-search-persistent-widget{right:10px;bottom:10px;width:calc(100vw - 20px);gap:9px;padding:10px;border-radius:13px}
 .chess-search-persistent-icon{width:32px;height:32px;flex-basis:32px;font-size:17px}
 .chess-search-persistent-label{font-size:8px}
 .chess-search-persistent-copy strong{font-size:18px}
 .chess-search-persistent-copy>span:last-child{font-size:9px}
 .chess-search-return-btn{padding:8px;font-size:10px}
}


/* Phase 14.0 — online match status */
.chess-online-status{margin:0 0 12px;padding:10px 12px;border-radius:10px;border:1px solid rgba(153,125,255,.25);background:rgba(153,125,255,.08);font-size:12px;line-height:1.45;color:#d9d0ff}
.chess-online-status[hidden]{display:none!important}
.chess-online-status[data-kind="success"]{border-color:rgba(105,205,146,.35);color:#a6edbf}
.chess-online-status[data-kind="warning"]{border-color:rgba(220,184,90,.35);color:#efd69a}
.chess-online-status[data-kind="error"]{border-color:rgba(239,116,126,.4);color:#ffb5bc}


/* Phase 14.1 — online controls and confirmation modal */
.chess-online-actions{display:flex;gap:10px;margin:0 0 12px}
.chess-online-actions[hidden]{display:none!important}
.chess-online-actions button{flex:1;min-height:42px}
.danger-btn{border:1px solid rgba(245,104,116,.45)!important;background:rgba(142,38,49,.18)!important;color:#ffb8be!important;border-radius:10px;padding:10px 14px;font:inherit;font-weight:700;cursor:pointer}
.chess-online-confirm-backdrop{position:fixed;inset:0;z-index:10050;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(0,0,0,.64);backdrop-filter:blur(5px)}
.chess-online-confirm-backdrop[hidden]{display:none!important}
.chess-online-confirm{width:min(420px,100%);padding:22px;border:1px solid rgba(153,125,255,.4);border-radius:18px;background:#1b1d23;color:#f4f1f7;box-shadow:0 24px 70px rgba(0,0,0,.45)}
.chess-online-confirm h3{margin:7px 0 8px;font-size:20px}
.chess-online-confirm p{margin:0 0 18px;color:#b9bac5;line-height:1.5;font-size:14px}
.chess-online-confirm-actions{display:flex;gap:10px}
.chess-online-confirm-actions button{flex:1;min-height:42px}
.chess-online-status[data-kind="success"]{border-color:rgba(105,205,146,.35);color:#a6edbf}
@media(max-width:520px){.chess-online-actions{gap:8px}.chess-online-actions button{font-size:12px;padding:9px 6px}.chess-online-confirm{padding:18px}.chess-online-confirm-actions{flex-direction:column}}


/* Phase 14.3: online controls replace the local restart action in the side panel. */
#chessBoardArea #chessOnlineActions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 8px;
  width: 100%;
}
#chessBoardArea #chessOnlineActions[hidden] { display: none !important; }
#chessBoardArea #chessOnlineActions > button { flex: 1 1 150px; min-height: 44px; }
@media (max-width: 600px) {
  #chessBoardArea #chessOnlineActions { gap: 8px; }
  #chessBoardArea #chessOnlineActions > button { flex-basis: 100%; }
}

/* Phase 14.4: online controls are placed in the side panel and replace restart. */
#chessBoardArea .chess-online-actions { display:flex; flex-wrap:wrap; gap:10px; width:100%; margin:14px 0 8px; }
#chessBoardArea .chess-online-actions[hidden] { display:none !important; }
#chessBoardArea .chess-online-actions > button { flex:1 1 150px; min-height:44px; }
@media (max-width:600px) {
  #chessBoardArea .chess-online-actions { gap:8px; }
  #chessBoardArea .chess-online-actions > button { flex-basis:100%; }
}

/* Phase 14.5: reusable completed-game statistics control. */
#btnShowChessResultStats[hidden] { display: none !important; }
#chessBoardArea #btnShowChessResultStats { margin-top: 10px; }

/* Phase 14.6: one visible status area; keep the board header clean. */
#chessBoardArea #chessOnlineStatus { display: none !important; }
.chess-result-actions { flex-wrap: wrap; }
.chess-result-actions #btnChessResultExit { border-color: rgba(202,203,205,.24); }
@media (max-width: 500px) {
  .chess-result-actions { flex-direction: column; }
  .chess-result-actions button { width: 100%; }
}

/* Phase 14.7: gentle transition between bot-wait offer and match-found notice */
.chess-bot-offer, .chess-match-found-offer { transition: opacity .2s ease, transform .2s ease; }
.chess-bot-offer.is-leaving { opacity: 0; transform: translateY(6px); pointer-events: none; }
.chess-match-found-offer.is-entering { opacity: 0; transform: translateY(6px); }
@media (prefers-reduced-motion: reduce) {
 .chess-bot-offer, .chess-match-found-offer { transition: none !important; }
}

/* Phase 14.8: search tip and match confirmation countdown */
.chess-search-tip { border-color: rgba(164,132,255,.38); }
.chess-match-countdown { margin: 8px 0 12px; color: #c5b8ff; font-size: 13px; }
.chess-search-widget-actions { display:flex; gap:6px; align-items:center; }
.chess-search-widget-actions button { white-space:nowrap; }

/* Phase 15.0 — result-coded history and total local playtime */
.chess-history-item.result-win{border-color:rgba(96,196,135,.34);background:rgba(96,196,135,.055)}
.chess-history-item.result-loss{border-color:rgba(235,105,115,.34);background:rgba(235,105,115,.05)}
.chess-history-item.result-draw{border-color:rgba(155,163,175,.30);background:rgba(155,163,175,.045)}
.chess-player-stats .chess-playtime-stat{grid-column:span 2}
.chess-player-stats .chess-playtime-stat strong{font-size:18px}
@media(max-width:520px){.chess-player-stats .chess-playtime-stat{grid-column:span 2}}

/* Phase 16.1 — reconnect/disconnect grace-period dialog */
.chess-reconnect-backdrop{position:fixed;inset:0;z-index:10060;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(0,0,0,.66);backdrop-filter:blur(6px)}
.chess-reconnect-backdrop[hidden]{display:none!important}
.chess-reconnect-dialog{width:min(440px,100%);padding:24px;border:1px solid rgba(153,125,255,.42);border-radius:18px;background:#1b1d23;color:#f4f1f7;box-shadow:0 24px 70px rgba(0,0,0,.5)}
.chess-reconnect-kicker{font-size:11px;font-weight:800;letter-spacing:.16em;color:#b5a0ff}
.chess-reconnect-dialog h3{margin:10px 0 8px;font-size:21px}
.chess-reconnect-dialog p{margin:0 0 14px;color:#b9bac5;line-height:1.5;font-size:14px}
.chess-reconnect-clock{font-size:34px;font-weight:800;letter-spacing:.04em;margin:4px 0 18px;font-variant-numeric:tabular-nums}
.chess-reconnect-actions{display:flex;gap:10px}
.chess-reconnect-actions button{flex:1;min-height:44px;border-radius:10px;font:inherit;font-weight:750;cursor:pointer}
.chess-reconnect-actions button:first-child{border:0;background:#382477;color:#fff}
.chess-reconnect-actions button:disabled{opacity:.6;cursor:wait}
@media(max-width:520px){.chess-reconnect-dialog{padding:19px}.chess-reconnect-actions{flex-direction:column}}

/* Phase 16.2 — persistent disconnect countdown on the board */
.chess-board-reconnect-timer{display:flex;flex-direction:column;gap:6px;margin:0 0 12px;padding:12px 14px;border:1px solid rgba(255,170,80,.38);border-radius:12px;background:rgba(115,67,25,.22);color:#f5e7d4}
.chess-board-reconnect-timer[hidden]{display:none!important}
.chess-board-reconnect-timer strong{font-size:13px}
.chess-board-reconnect-timer span{font-size:24px;font-weight:850;font-variant-numeric:tabular-nums}
.chess-board-reconnect-timer small{font-size:11px;line-height:1.4;color:#d1bda7}
