:root {
  --navy: #0b1f3a;
  --blue: #1d5fd0;
  --blue-deep: #154aa8;
  --blue-soft: #e8f0fb;
  --ink: #142033;
  --muted: #5d6b7c;
  --line: #e3e8ee;
  --surface: #f4f6f9;
  --card: #fff;
  --danger: #b42318;
  --ok: #0f7a45;
  --hover: #f3f6fa;
  --fill: #f7f9fc;
  --chip: #e8edf3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 51, 0.05);
}

html {
  font-size: 15px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e7edf5;
  --muted: #a8b4c4;
  --line: #2c3c50;
  --surface: #101820;
  --card: #1a2633;
  --blue-soft: #1c3358;
  --hover: #243246;
  --fill: #1c2a3c;
  --chip: #243246;
  --shadow: none;
  --bs-body-color: #e7edf5;
  --bs-body-bg: #101820;
  --bs-emphasis-color: #e7edf5;
  --bs-heading-color: #e7edf5;
  --bs-secondary-color: #a8b4c4;
  --bs-border-color: #2c3c50;
  --bs-tertiary-bg: #1c2a3c;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
  background-color: var(--card);
  color: var(--ink);
}

html[data-theme="dark"] .alert-success {
  --bs-alert-color: #d5f5e3;
  --bs-alert-bg: #143226;
  --bs-alert-border-color: transparent;
}

html[data-theme="dark"] .alert-danger {
  --bs-alert-color: #ffd7d3;
  --bs-alert-bg: #3a1d1b;
  --bs-alert-border-color: transparent;
}

html[data-theme="dark"] .btn-outline-danger {
  --bs-btn-border-color: #6e3330;
  --bs-btn-hover-bg: #3a2224;
}

html[data-theme="dark"] .icon-btn.danger:hover {
  background: #3a2224;
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--surface);
  font-family: "Segoe UI", system-ui, sans-serif;
}

.icon {
  width: 18px;
  height: 18px;
  display: block;
  flex: 0 0 auto;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 56px minmax(0, 1fr);
  grid-template-areas: "top" "main";
}

.is-auth .app-shell {
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-areas:
    "top top"
    "side main";
}

.topbar {
  grid-area: top;
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 16px;
  background: var(--navy);
  color: #fff;
}

.is-auth .topbar,
.is-auth .sidebar,
.is-auth .offcanvas {
  background: var(--bar, var(--navy));
  color: var(--bar-ink, #fff);
}

.brand {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  font-weight: 650;
  letter-spacing: 0;
  text-decoration: none;
  font-size: 1.05rem;
}

.is-guest .brand {
  letter-spacing: 0.06em;
}

.brand:hover {
  color: inherit;
}

.top-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
}

.top-count {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bar-ink, #fff);
  box-shadow: 0 0 0 2px var(--bar, var(--navy));
}

.is-auth .top-icon {
  color: var(--bar-ink, #fff);
}

.top-icon:hover,
.is-auth .sidebar .side-link:hover,
.is-auth .sidebar .side-button:hover,
.is-auth .sidebar .rail-toggle:hover,
.is-auth .offcanvas .side-link:hover,
.is-auth .offcanvas .side-button:hover {
  background: color-mix(in srgb, var(--bar-ink, #fff) 14%, transparent);
  color: var(--bar-ink, #fff);
}

.top-mail {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.86rem;
}

.me-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.page-title .me-dot {
  margin-right: 8px;
  vertical-align: 1px;
}

.sidebar {
  grid-area: side;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow: auto;
  background: var(--card);
  border-right: 1px solid transparent;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.is-auth .sidebar .side-link,
.is-auth .sidebar .side-button,
.is-auth .sidebar .rail-toggle,
.is-auth .sidebar .side-label,
.is-auth .sidebar .side-email,
.is-auth .offcanvas .side-link,
.is-auth .offcanvas .side-button,
.is-auth .offcanvas .side-label,
.is-auth .offcanvas .side-email,
.is-auth .offcanvas-title {
  color: var(--bar-ink, #fff);
}

.is-auth .sidebar .side-link.active,
.is-auth .offcanvas .side-link.active {
  background: color-mix(in srgb, var(--bar-ink, #fff) 22%, transparent);
  color: var(--bar-ink, #fff);
}

.is-auth .side-account {
  border-top-color: color-mix(in srgb, var(--bar-ink, #fff) 28%, transparent);
}

.is-auth.bar-dark .offcanvas .btn-close {
  filter: invert(1) grayscale(1);
}

.rail-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: 0 0 8px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.rail-toggle:hover {
  background: var(--hover);
  color: var(--ink);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-label {
  margin: 16px 10px 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side-link,
.side-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  font-weight: 550;
  font-size: 0.95rem;
}

.side-link:hover,
.side-button:hover {
  background: var(--hover);
  color: var(--ink);
}

.side-link.active {
  background: var(--blue-soft);
  color: var(--blue-deep);
}

.side-link.is-primary {
  padding-top: 10px;
  padding-bottom: 10px;
}

.side-count {
  margin-left: auto;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bar-ink, #fff);
  color: var(--bar, #0b1f3a);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25rem;
  text-align: center;
}

.side-spacer {
  flex: 1;
}

.side-account {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.side-email {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 10px 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.side-who {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-main {
  grid-area: main;
  min-width: 0;
  padding: 24px 28px 40px;
}

.is-guest.is-bare .topbar {
  display: none;
}

.is-guest.is-bare .app-shell {
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "main";
}

.is-guest.is-bare .app-main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.is-guest.is-bare .app-main > main {
  width: 100%;
  display: flex;
  justify-content: center;
}

.sign-card {
  width: min(100%, 22rem);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.sign-mark {
  margin: 0 0 2px;
  color: var(--navy);
  font-weight: 650;
  letter-spacing: 0.08em;
  font-size: 0.95rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

.page-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.page-kicker {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.panel,
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.card .card-body {
  padding: 16px;
}

.btn {
  border-radius: 8px;
}

.btn-primary {
  --bs-btn-bg: var(--blue);
  --bs-btn-border-color: var(--blue);
  --bs-btn-hover-bg: var(--blue-deep);
  --bs-btn-hover-border-color: var(--blue-deep);
  --bs-btn-active-bg: var(--blue-deep);
  --bs-btn-active-border-color: var(--blue-deep);
  --bs-btn-disabled-bg: var(--blue);
  --bs-btn-disabled-border-color: var(--blue);
}

.btn-outline-primary {
  --bs-btn-color: var(--blue);
  --bs-btn-border-color: #b9ccef;
  --bs-btn-hover-bg: var(--blue-soft);
  --bs-btn-hover-border-color: var(--blue);
  --bs-btn-hover-color: var(--blue-deep);
}

.btn-outline-secondary {
  --bs-btn-color: var(--ink);
  --bs-btn-border-color: var(--line);
  --bs-btn-hover-bg: var(--hover);
  --bs-btn-hover-color: var(--ink);
  --bs-btn-hover-border-color: var(--line);
}

.btn-outline-danger {
  --bs-btn-color: var(--danger);
  --bs-btn-border-color: #f0c9c6;
  --bs-btn-hover-bg: #fdecec;
  --bs-btn-hover-color: var(--danger);
}

.form-control,
.form-select {
  border-color: var(--line);
  border-radius: 8px;
  color: var(--ink);
}

.form-control:focus,
.form-select:focus,
.btn:focus-visible,
.icon-btn:focus-visible,
.side-link:focus-visible,
.top-icon:focus-visible,
.rail-toggle:focus-visible,
.dest:focus-visible {
  border-color: #9db7e6;
  box-shadow: 0 0 0 3px rgba(29, 95, 208, 0.18);
  outline: 0;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--muted);
}

.alert {
  border: 0;
  border-radius: 10px;
}

.table {
  --bs-table-bg: transparent;
  margin-bottom: 0;
}

.table > :not(caption) > * > * {
  padding: 10px 12px;
  border-bottom-color: var(--line);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
}

.icon-btn[hidden] {
  display: none;
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--ink);
}

.icon-btn.danger:hover {
  background: #fdecec;
  color: var(--danger);
}

.icon-btn.is-copied {
  color: var(--blue);
  background: var(--blue-soft);
}

.icon-btn .icon-hide {
  display: none;
}

.icon-btn.is-revealed .icon-show {
  display: none;
}

.icon-btn.is-revealed .icon-hide {
  display: block;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--muted);
}

.search-field:focus-within {
  border-color: #9db7e6;
  box-shadow: 0 0 0 3px rgba(29, 95, 208, 0.18);
  background: var(--card);
}

.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 8px 0;
  outline: 0;
  color: var(--ink);
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.composer {
  position: sticky;
  top: 72px;
}

.vault-dropzone {
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  color: var(--ink);
}

.vault-dropzone .icon {
  margin: 0 auto 8px;
  width: 22px;
  height: 22px;
  color: var(--blue);
}

.vault-dropzone.is-over {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.vault-dropzone ul {
  list-style: none;
  padding: 0;
  text-align: left;
}

.composer-options {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.composer-options summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  border-radius: 6px;
}

.composer-options summary:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(29, 95, 208, 0.18);
}

.composer-options summary::-webkit-details-marker {
  display: none;
}

.composer-options summary::marker {
  content: "";
}

.composer-options-label {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--ink);
}

.composer-options-label::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 6px;
  border-style: solid;
  border-width: 4px 0 4px 5px;
  border-color: transparent transparent transparent var(--muted);
  vertical-align: 1px;
}

.composer-options[open] .composer-options-label::before {
  border-width: 5px 4px 0 4px;
  border-color: var(--muted) transparent transparent transparent;
}

.composer-options-summary {
  margin-left: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

.composer-options-body {
  padding-top: 12px;
}

.field-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.short-target {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.browser-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.story-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.story-thumb {
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--chip);
}

.story-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-lead {
  margin: 0 0 16px;
}

.story-reader-files {
  margin-top: 18px;
}

.section-label {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.vault-summary-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 8px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--fill);
  font-size: 0.82rem;
  color: var(--muted);
}

.vault-summary-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.vault-datasaver-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.vault-datasaver-pill.is-active {
  background: var(--blue-soft);
  color: var(--blue-deep);
}

.vault-summary-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.vault-summary-sep {
  color: var(--muted);
}

.vault-link-btn {
  padding: 2px 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--blue);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.vault-link-btn:hover:not(:disabled) {
  color: var(--blue-deep);
  text-decoration: underline;
}

.vault-link-btn:disabled {
  color: var(--muted);
  opacity: 0.55;
  cursor: default;
}

.vault-category {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  margin-bottom: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.vault-category.is-open {
  border-color: color-mix(in srgb, var(--blue) 32%, var(--line));
  box-shadow: var(--shadow);
}

.vault-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.vault-category-header:hover {
  background: var(--hover);
}

.vault-category-header:focus-visible {
  outline: 0;
  box-shadow: inset 0 0 0 2px rgba(29, 95, 208, 0.35);
}

.vault-category.is-open .vault-category-header {
  border-bottom: 1px solid var(--line);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: var(--fill);
}

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

.vault-category-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transition: transform 0.18s ease, color 0.18s ease;
  flex: 0 0 auto;
}

.vault-category.is-open .vault-category-chevron {
  transform: rotate(90deg);
  color: var(--blue);
}

.vault-category-glyph {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue-deep);
  flex: 0 0 auto;
}

.vault-category-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.vault-category-header .section-label {
  margin: 0;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  text-transform: none;
  line-height: 1.2;
}

.vault-category-sub {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.3;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vault-category-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  flex: 0 0 auto;
}

.vault-meta-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
}

.vault-meta-pill.is-size {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 550;
}

.vault-category-body {
  padding: 12px 14px;
}

.vault-category-body[hidden] {
  display: none;
}

.vault-category-body > .file-row:first-child {
  border-top: 0;
  padding-top: 2px;
}

.vault-category-body > .photo-grid {
  margin-bottom: 4px;
}

.vault-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
}

.vault-pager-info {
  min-width: 0;
}

.vault-pager-loaded {
  color: var(--muted);
}

.vault-pager-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.vault-pager-limit {
  margin: 0;
}

.vault-pager-limit .vault-page-size {
  width: auto;
  min-width: 92px;
  height: 30px;
  padding-top: 2px;
  padding-bottom: 2px;
  font-size: 0.78rem;
  border-radius: 6px;
}

.vault-pager-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.vault-page-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
}

.vault-page-btn.is-active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.vault-page-ellipsis {
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
  user-select: none;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.photo-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
}

.photo-open {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--chip);
}

.photo-open img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-name {
  margin-top: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-meta {
  color: var(--muted);
  font-size: 0.75rem;
}

.photo-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
}

.file-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  padding: 10px 4px;
  border-top: 1px solid var(--line);
}

.file-row.is-selected {
  background: var(--blue-soft);
  border-radius: 8px;
}

.url-detail {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--fill);
}

.url-detail[hidden] {
  display: none;
}

.url-kind {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.url-target,
.url-when {
  overflow-wrap: anywhere;
}

.url-when {
  color: var(--muted);
  font-size: 0.85rem;
}

.url-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-glyph {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue-deep);
}

.file-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.tag-select {
  width: 148px;
  height: 32px;
  padding-top: 2px;
  padding-bottom: 2px;
  font-size: 0.8rem;
}

.member-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.member-pill {
  display: inline-block;
  max-width: 140px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.member-menu {
  position: fixed;
  z-index: 1100;
  width: min(240px, calc(100vw - 16px));
  max-height: min(280px, calc(100vh - 16px));
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 8px 24px rgba(11, 31, 58, 0.12);
}

.member-menu[hidden] {
  display: none;
}

.member-menu-empty {
  margin: 0;
  padding: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.member-menu-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.member-menu-row:hover {
  background: var(--hover);
}

.member-menu-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-swatch {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 50%;
}

.from-others {
  margin-top: 18px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.from-others[hidden] {
  display: none;
}

.from-others-title {
  margin: 8px 0 10px;
  font-size: 0.95rem;
  font-weight: 650;
}

.empty {
  margin: 0;
  padding: 28px 8px;
  text-align: center;
  color: var(--muted);
}

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-viewer[hidden] {
  display: none;
}

body.photo-viewer-open {
  overflow: hidden;
}

.photo-viewer-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(8, 16, 28, 0.88);
}

.photo-viewer-frame {
  position: relative;
  z-index: 1;
  width: min(1100px, 96vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.photo-viewer-frame img {
  width: min(1100px, 94vw);
  height: calc(100vh - 7.5rem);
  object-fit: contain;
  background: transparent;
}

.photo-viewer-bar {
  width: min(1100px, 94vw);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #fff;
}

.photo-viewer-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.photo-viewer-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.photo-viewer-buttons .icon-btn {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.photo-viewer-buttons .icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.share-preview {
  display: block;
  max-width: 100%;
  max-height: 420px;
  border-radius: 10px;
}

.paste-preview {
  white-space: pre-wrap;
  max-height: 240px;
  overflow: auto;
  background: var(--surface);
  padding: 12px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.file-title-btn {
  display: block;
  width: 100%;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.file-title-btn:hover {
  color: var(--blue-deep);
}

.note-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 12px 0 0;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.55;
}

.note-body.is-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  tab-size: 4;
}

.note-skip {
  margin: 12px 0 0;
  color: var(--muted);
}

.md-view {
  margin-top: 12px;
  overflow-wrap: anywhere;
  font-size: 1rem;
  line-height: 1.6;
}

.md-view > :first-child {
  margin-top: 0;
}

.md-view h1,
.md-view h2,
.md-view h3,
.md-view h4,
.md-view h5,
.md-view h6 {
  font-weight: 650;
  line-height: 1.25;
  margin: 1.15em 0 0.4em;
}

.md-view h1 { font-size: 1.55rem; }
.md-view h2 { font-size: 1.28rem; }
.md-view h3 { font-size: 1.1rem; }

.md-view p,
.md-view ul,
.md-view ol,
.md-view blockquote,
.md-view pre {
  margin: 0.7em 0;
}

.md-view ul,
.md-view ol {
  padding-left: 1.3rem;
}

.md-view blockquote {
  border-left: 3px solid var(--blue);
  padding-left: 12px;
  color: var(--ink);
}

.md-view a {
  color: var(--blue-deep);
}

.md-view code {
  font-family: Consolas, "Cascadia Mono", ui-monospace, monospace;
  font-size: 0.9em;
  background: var(--surface);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.md-view pre:not(.mermaid) {
  background: var(--surface);
  padding: 12px 14px;
  border-radius: 8px;
  overflow: auto;
}

.md-view pre:not(.mermaid) code {
  padding: 0;
  background: transparent;
}

.md-view pre.mermaid {
  background: transparent;
  padding: 0;
  overflow: auto;
  text-align: center;
}

.md-view pre.mermaid iframe,
.md-view pre.mermaid svg {
  max-width: 100%;
  height: auto;
}

.md-view table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.7em 0;
  font-size: 0.95rem;
}

.md-view th,
.md-view td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}

.md-view th {
  background: var(--surface);
}

.md-view input[type="checkbox"] {
  margin-right: 0.4em;
}

.md-view img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.md-view hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.2em 0;
}

.note-reader {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.note-reader[hidden] {
  display: none;
}

body.note-reader-open {
  overflow: hidden;
}

.note-reader-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(8, 16, 28, 0.72);
}

.note-reader-frame {
  position: relative;
  z-index: 1;
  width: min(64rem, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  color: var(--ink);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(8, 16, 28, 0.28);
}

.note-reader-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 12px 16px;
  border-bottom: 1px solid var(--line);
}

.note-reader-name {
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-reader-buttons {
  display: flex;
  gap: 4px;
}

.note-reader-body {
  overflow: auto;
  padding: 16px 20px 24px;
}

.note-reader-body .note-body,
.note-reader-body .note-skip,
.note-reader-body .md-view {
  margin-top: 0;
}

.password-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.password-shell {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  min-height: 420px;
}

.password-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.password-list {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  max-height: calc(100vh - 280px);
  overflow: auto;
}

.password-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  padding: 12px;
  color: var(--ink);
}

.password-item:last-child {
  border-bottom: 0;
}

.password-item:hover {
  background: var(--fill);
}

.password-item.active {
  background: var(--blue-soft);
}

.pw-mark {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface);
  color: var(--blue-deep);
  flex: 0 0 auto;
}

.password-item.active .pw-mark {
  background: var(--card);
}

.pw-favicon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: contain;
}

.pw-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pw-name {
  display: block;
  font-weight: 650;
}

.pw-sub {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.password-detail {
  min-height: 280px;
}

.message-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

.message-toolbar {
  display: flex;
  gap: 8px;
}

.message-shell {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  min-height: 480px;
}

.message-list,
.message-people {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.message-people {
  border: 0;
  border-radius: 0;
  max-height: none;
  flex: 1;
}

.message-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 12px;
  color: var(--ink);
}

.message-item:last-child {
  border-bottom: 0;
}

.message-item:hover,
.message-item.active {
  background: var(--blue-soft);
}

.message-avatar {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  flex: 0 0 auto;
}

.message-copy {
  min-width: 0;
  flex: 1;
}

.message-unread {
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25rem;
  text-align: center;
}

.message-thread {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 480px;
  max-height: calc(100vh - 200px);
  max-height: calc(100dvh - 200px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  overflow: hidden;
}

.message-thread-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.message-who {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
}

.message-who-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.message-who-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-who-members {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.message-avatar.is-group .icon {
  width: 18px;
  height: 18px;
}

.message-back {
  display: none;
}

.message-group-panel {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--fill);
}

.message-add-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.message-people {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.message-people-head {
  padding: 12px 16px 6px;
  border-bottom: 1px solid var(--line);
}

.message-people-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.message-people-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--card);
}

.message-pick-row.is-picked {
  background: var(--blue-soft);
}

.message-pick-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  flex: 0 0 auto;
}

.message-pick-row.is-picked .message-pick-check {
  background: var(--blue);
  border-color: var(--blue);
}

.message-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}

.message-bubble {
  position: relative;
  align-self: flex-start;
  max-width: min(32rem, 86%);
  padding: 10px 13px;
  border-radius: 18px 18px 18px 5px;
  background: var(--surface);
  transition: box-shadow 0.25s ease;
}

.message-bubble.mine {
  align-self: flex-end;
  border-radius: 18px 18px 5px 18px;
  background: var(--blue-soft);
}

.message-bubble.is-sticker-only {
  background: transparent;
  padding: 4px 6px;
}

.message-bubble.is-flash {
  box-shadow: 0 0 0 2px var(--blue);
}

.message-sender {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
}

.message-sender-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.message-quote {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  margin-bottom: 6px;
  padding: 5px 9px;
  border: 0;
  border-left: 3px solid var(--blue);
  border-radius: 6px;
  background: rgba(20, 32, 51, 0.05);
  color: var(--ink);
  font-size: 0.8rem;
}

html[data-theme="dark"] .message-quote {
  background: rgba(255, 255, 255, 0.06);
}

.message-quote-author {
  font-weight: 700;
  font-size: 0.75rem;
}

.message-quote-snippet {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-photo-btn {
  display: block;
  padding: 0;
  margin-bottom: 6px;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  background: transparent;
  cursor: pointer;
}

.message-photo {
  display: block;
  max-width: min(260px, 68vw);
  max-height: 240px;
  width: auto;
  height: auto;
  object-fit: cover;
  border-radius: 12px;
}

.message-sticker {
  display: block;
  width: 120px;
  height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.16));
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.message-sticker:hover {
  transform: scale(1.06) rotate(1deg);
}

.message-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
}

.message-file-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.message-file-name {
  font-weight: 600;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-file-size {
  font-size: 0.74rem;
  color: var(--muted);
}

.message-audio {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: min(230px, 65vw);
  margin-bottom: 4px;
  padding: 4px 2px;
}

.message-audio-play {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.message-audio-seek {
  flex: 1;
  min-width: 70px;
  accent-color: var(--blue);
}

.message-audio-time {
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.message-audio-ttl {
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
}

.message-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-body.is-jumbo {
  font-size: 2.5rem;
  line-height: 1.15;
}

.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.message-reactions[hidden] {
  display: none;
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.3;
}

.reaction-pill.mine {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.reaction-count {
  font-size: 0.74rem;
  font-weight: 600;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.message-when {
  color: var(--muted);
  font-size: 0.72rem;
}

.message-receipt {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}

.message-receipt.is-read {
  color: var(--blue);
}

.message-bubble-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.message-bubble:hover .message-bubble-actions,
.message-bubble:focus-within .message-bubble-actions {
  opacity: 1;
}

.bubble-action-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bubble-action-btn:hover {
  background: var(--hover);
  color: var(--ink);
}

.bubble-action-btn .icon {
  width: 15px;
  height: 15px;
}

.message-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
  animation: mcwut-bounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes mcwut-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.message-earlier {
  align-self: center;
  padding-top: 0;
}

.message-form {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--card);
}

.message-stage-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--surface);
  border-left: 3px solid var(--blue);
  font-size: 0.84rem;
}

.message-stage-thumb {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 6px;
  flex: 0 0 auto;
}

.message-stage-copy {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.message-compose-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.message-compose-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

.msg-tool-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

.message-compose-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.message-form textarea {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  max-height: 112px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  resize: none;
  line-height: 1.35;
}

.message-form textarea:focus {
  outline: 2px solid var(--blue);
  outline-offset: -1px;
  background: var(--card);
}

.message-send-btn {
  border-radius: 18px;
  min-height: 40px;
  padding: 0 16px;
  font-weight: 600;
  flex: 0 0 auto;
}

.message-voice-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--surface);
}

.voice-rec-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--danger);
  animation: mcwut-pulse 1s infinite ease-in-out;
}

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

.message-sticker-pop {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 10px 30px rgba(11, 31, 58, 0.16);
  max-width: 440px;
  width: 100%;
}

.message-quick-emojis {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}

.quick-emoji-btn {
  min-width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  font-size: 1.3rem;
  flex: 0 0 auto;
  touch-action: manipulation;
  transition: transform 0.15s ease, background 0.15s ease;
}

.quick-emoji-btn:hover,
.quick-emoji-btn:active {
  background: var(--blue-soft);
  transform: scale(1.12);
}

.message-sticker-creator {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.sticker-theme-select {
  flex: 1 1 140px;
  min-width: 130px;
  border-radius: 8px;
  background-color: var(--surface);
  color: var(--ink);
  border-color: var(--line);
  font-size: 0.8rem;
}

.sticker-prompt-input {
  flex: 2 1 160px;
  min-width: 140px;
  border-radius: 8px;
  background-color: var(--surface);
  color: var(--ink);
  border-color: var(--line);
  font-size: 0.82rem;
}

.sticker-create-btn {
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0 12px;
  min-height: 31px;
  flex: 0 0 auto;
}

.sticker-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  vertical-align: middle;
}

.sticker-dots span {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: currentColor;
  animation: mcwut-bounce 1.2s infinite ease-in-out;
}

.sticker-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.sticker-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

.sticker-create-status {
  padding: 2px 4px 6px;
  line-height: 1.25;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sticker-pick-cell {
  position: relative;
  display: flex;
}

.sticker-pick-cell .sticker-pick-btn {
  width: 100%;
}

.sticker-del-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 0;
  background: rgba(15, 23, 42, 0.72);
  color: #ffffff;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  padding: 0;
}

.sticker-pick-cell:hover .sticker-del-btn,
.sticker-del-btn:focus-visible {
  opacity: 1;
}

.sticker-del-btn:hover {
  background: var(--danger);
}

.message-sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
  padding: 4px;
}

@media (min-width: 768px) {
  .message-sticker-grid {
    max-height: 320px;
  }
}

.sticker-pick-btn {
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  overflow: hidden;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.sticker-pick-btn:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.sticker-pick-btn:active {
  background: var(--blue-soft);
}

.sticker-pick-btn img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.12));
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sticker-pick-btn:hover img {
  transform: scale(1.1);
}

.message-react-menu {
  position: fixed;
  z-index: 1120;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 8px 24px rgba(11, 31, 58, 0.18);
}

.react-menu-emoji {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.react-menu-emoji:hover {
  background: var(--blue-soft);
  transform: scale(1.15);
}

.react-menu-reply {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 4px;
  padding: 4px 10px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
}

.message-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  text-align: left;
}

.message-picker-item:hover {
  background: var(--blue-soft);
  border-color: var(--blue);
}

.message-picker-thumb {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  flex: 0 0 auto;
}

.message-picker-icon {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.message-picker-copy {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.doodle-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.doodle-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.doodle-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--line);
  padding: 0;
}

.doodle-swatch.active {
  outline: 3px solid var(--blue);
  outline-offset: 1px;
}

.doodle-sizes {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.doodle-size-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.doodle-size-btn span {
  display: block;
  border-radius: 50%;
  background: var(--ink);
}

.doodle-size-btn.active,
#doodle-eraser-btn.active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.doodle-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
  touch-action: none;
  user-select: none;
}

.doodle-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.msg-top-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.message-log[hidden],
.message-people[hidden],
.message-form[hidden],
.message-group-panel[hidden],
.message-typing[hidden],
.message-stage-bar[hidden],
.message-voice-bar[hidden],
.message-compose-row[hidden],
.message-sticker-pop[hidden],
.message-react-menu[hidden],
.msg-top-btn[hidden] {
  display: none !important;
}

.secret {
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.04em;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 38px;
}

.password-value {
  min-width: 0;
  overflow-wrap: anywhere;
}

.password-notes {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface);
  border-radius: 8px;
  padding: 10px 12px;
}

.field-tools {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
}

.home {
  max-width: 880px;
}

.dest-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}

.dest {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 140px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.dest:hover {
  border-color: #b9ccef;
  color: var(--ink);
}

.dest .icon {
  width: 22px;
  height: 22px;
  color: var(--blue);
}

.dest strong {
  font-size: 1.1rem;
}

.dest span {
  color: var(--muted);
  font-size: 0.9rem;
}

.ai-key {
  margin-bottom: 16px;
}

.ai-key-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.ai-key-field {
  flex: 1 1 220px;
  min-width: 0;
}

.ai-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 16px;
  min-height: 420px;
}

.ai-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.ai-model {
  flex: 1 1 220px;
  min-width: 0;
}

.ai-alert {
  margin: 0;
  color: var(--danger);
}

.ai-alert:empty,
.ai-alert[hidden] {
  display: none;
}

.ai-log {
  flex: 1;
  min-height: 240px;
  max-height: calc(100vh - 420px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-msg {
  max-width: min(42rem, 100%);
  padding: 10px 12px;
  border-radius: 12px;
  overflow-wrap: anywhere;
}

.ai-msg.user {
  align-self: flex-end;
  background: var(--blue-soft);
}

.ai-msg.assistant {
  align-self: flex-start;
  max-width: 100%;
  background: var(--surface);
}

.ai-who {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
}

.ai-msg .ai-body {
  white-space: pre-wrap;
}

.ai-msg .ai-body.md-view {
  margin-top: 0;
  white-space: normal;
  overflow-x: auto;
}

.ai-msg.is-waiting .ai-body {
  color: var(--muted);
}

.ai-form {
  display: flex;
  gap: 8px;
  align-items: end;
}

.ai-form textarea {
  flex: 1;
  min-width: 0;
  resize: vertical;
}

.ai-shell[hidden],
.ai-setup[hidden],
.ai-about[hidden] {
  display: none;
}

.ai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ai-key-link {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.ai-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: space-between;
}

.ai-md {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--ink);
  font-size: 0.85rem;
}

.ai-key-link:hover {
  color: var(--ink);
}

.ai-meta,
.ai-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.ai-note[hidden] {
  display: none;
}

.ai-about {
  color: var(--muted);
  font-size: 0.9rem;
}

.ai-about summary {
  width: fit-content;
  cursor: pointer;
}

.ai-about p {
  margin: 6px 0 0;
}

.ai-steps {
  margin: 0 0 12px;
  padding-left: 1.2rem;
}

.ai-steps li + li {
  margin-top: 6px;
}

.profile-sheet {
  max-width: 32rem;
}

.color-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-pick {
  width: 52px;
  height: 40px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
}

.theme-choice {
  display: flex;
  gap: 8px;
}

.theme-btn[aria-pressed="true"] {
  background: var(--blue-soft);
  border-color: var(--blue);
  color: var(--blue-deep);
}

.color-pick::-webkit-color-swatch {
  border: 0;
  border-radius: 4px;
}

.color-pick::-moz-color-swatch {
  border: 0;
  border-radius: 4px;
}

.color-hex {
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

html.is-rail .is-auth .app-shell {
  grid-template-columns: 76px minmax(0, 1fr);
}

html.is-rail .sidebar {
  padding: 10px 8px;
  align-items: center;
}

html.is-rail .sidebar .rail-toggle {
  margin: 0 0 8px;
}

html.is-rail .sidebar .side-nav,
html.is-rail .sidebar .side-account {
  align-items: center;
  width: 100%;
}

html.is-rail .sidebar .side-link,
html.is-rail .sidebar .side-button {
  position: relative;
  justify-content: center;
  width: 44px;
  height: 40px;
  padding: 0;
  gap: 0;
}

html.is-rail .sidebar .side-link span,
html.is-rail .sidebar .side-button span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html.is-rail .sidebar .side-link .side-count {
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  min-width: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  clip: auto;
  color: transparent;
  line-height: 0;
}

html.is-rail .sidebar .side-email,
html.is-rail .sidebar .side-label {
  display: none;
}

.status-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.status-list div {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.status-list dt {
  margin: 0;
  color: var(--muted);
  font-weight: 650;
}

.status-list dd {
  margin: 0;
}

@media (max-width: 991.98px) {
  html.is-rail .is-auth .app-shell,
  .is-auth .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "top" "main";
  }

  .sidebar {
    display: none;
  }

  .app-main {
    padding: 16px;
  }

  .workspace,
  .password-shell,
  .message-shell,
  .dest-grid {
    grid-template-columns: 1fr;
  }

  .message-shell {
    min-height: 0;
  }

  .message-shell:not(.is-open) .message-thread {
    display: none;
  }

  .message-shell.is-open .message-side {
    display: none;
  }

  .message-back {
    display: inline-flex;
  }

  .message-list {
    max-height: none;
  }

  .message-thread {
    min-height: 260px;
    height: calc(100vh - 175px);
    height: calc(100dvh - 175px);
    max-height: calc(100vh - 175px);
    max-height: calc(100dvh - 175px);
  }

  .message-form {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .message-form textarea,
  #message-search,
  #message-group-title,
  #message-group-rename,
  #message-files-search {
    font-size: 16px;
  }

  .browser {
    order: -1;
  }

  .composer {
    position: static;
  }

  .password-list {
    max-height: 16rem;
  }

  .ai-log {
    max-height: 50vh;
  }

  .ai-form {
    flex-direction: column;
    align-items: stretch;
  }

  .top-mail {
    display: none;
  }
}

@media (max-width: 640px) {
  .file-row {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .file-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .tag-select {
    width: 100%;
  }

  .status-list div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .password-toolbar {
    flex-direction: column;
  }

  .message-compose-row {
    flex-wrap: wrap;
    gap: 6px;
  }

  .message-compose-tools {
    width: 100%;
    justify-content: flex-start;
    gap: 6px;
  }

  .message-compose-main {
    width: 100%;
  }

  .message-react-menu {
    max-width: calc(100vw - 16px);
    overflow-x: auto;
  }
}

@media (pointer: coarse) {
  .msg-tool-btn {
    width: 44px;
    height: 44px;
  }

  .message-send-btn {
    min-height: 44px;
    padding: 0 18px;
  }

  .message-form textarea {
    min-height: 44px;
    font-size: 16px;
  }

  .message-bubble-actions {
    opacity: 0.85;
  }

  .bubble-action-btn {
    width: 34px;
    height: 34px;
  }

  .quick-emoji-btn,
  .react-menu-emoji {
    min-width: 44px;
    width: 44px;
    height: 44px;
  }

  .reaction-pill {
    min-height: 32px;
    padding: 4px 10px;
  }

  .message-item {
    min-height: 52px;
  }

  .doodle-swatch {
    width: 36px;
    height: 36px;
  }

  .doodle-size-btn {
    width: 38px;
    height: 38px;
  }
}

.pw-warning {
  color: var(--danger);
  font-weight: 600;
}

.pw-health {
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface);
  border-left: 3px solid var(--danger);
}

.ai-context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--blue-soft);
  font-size: 0.85rem;
}

.ai-context-bar[hidden] {
  display: none !important;
}

#message-notify {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#message-notify[hidden] {
  display: none !important;
}

/* --- Personalization: Header Badge, Motif, Background Tile & Profile Studio --- */
.topbar {
  overflow: hidden;
}

.topbar > * {
  position: relative;
  z-index: 2;
}

.topbar-motif {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-image: var(--bar-motif);
  background-repeat: repeat-x;
  background-position: right center;
  background-size: auto 56px;
  opacity: 0.28;
  pointer-events: none;
  mask-image: linear-gradient(to right, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.95) 35%, rgba(0, 0, 0, 0.95));
  -webkit-mask-image: linear-gradient(to right, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.95) 35%, rgba(0, 0, 0, 0.95));
}

.brand-badge {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  object-fit: contain;
  border-radius: 6px;
}

.topbar-status {
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.16);
  color: inherit;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-pale .topbar-status {
  background: rgba(11, 31, 58, 0.12);
}

.home-badge {
  width: 30px;
  height: 30px;
  vertical-align: -6px;
  margin-right: 6px;
  object-fit: contain;
}

.home-status-tag {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--chip);
  color: var(--ink);
}

body.has-bg-tile::before {
  content: "";
  position: fixed;
  inset: 56px 0 0 0;
  z-index: 0;
  background-image: var(--bg-tile);
  background-repeat: repeat;
  background-size: 84px 84px;
  opacity: 0.08;
  pointer-events: none;
}

html[data-theme="dark"] body.has-bg-tile::before {
  opacity: 0.11;
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.color-swatch-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--card);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.color-swatch-dot:hover {
  transform: scale(1.2);
  box-shadow: 0 0 0 2px var(--blue);
}

.color-swatch-dot:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.color-swatch-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--fill);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.color-swatch-chip:hover {
  border-color: var(--blue);
  background: var(--hover);
}

.swatch-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.flair-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.flair-custom-wrap {
  position: relative;
  display: inline-flex;
}

.flair-custom-wrap .flair-option {
  width: 100%;
}

.flair-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  background: var(--fill);
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
}

.flair-grid-compact .flair-option {
  width: 50px;
  height: 50px;
  min-height: 50px;
  padding: 6px;
}

.flair-grid-wide .flair-option {
  width: 96px;
  height: 44px;
  min-height: 44px;
  padding: 6px;
}

.flair-grid-tile .flair-option {
  width: 58px;
  height: 48px;
  min-height: 48px;
  padding: 6px;
}

.flair-option:hover {
  border-color: var(--blue);
  background: var(--hover);
}

.flair-option.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: 0 0 0 1px var(--blue);
}

.flair-thumb-badge {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.flair-thumb-motif {
  display: block;
  width: 80px;
  height: 28px;
  border-radius: 4px;
  background-color: var(--bar, var(--navy));
  background-repeat: repeat-x;
  background-position: center;
  background-size: auto 28px;
}

.flair-thumb-tile {
  display: block;
  width: 42px;
  height: 32px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background-color: var(--surface);
  background-repeat: repeat;
  background-position: center;
  background-size: 32px 32px;
}

.flair-none {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-weight: 600;
}

.flair-label {
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flair-delete {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.flair-delete:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.flair-ai-box {
  padding: 10px;
  border-radius: 10px;
  background: var(--fill);
  border: 1px solid var(--line);
}

.flair-ai-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.flair-theme-select {
  flex: 0 1 190px;
}

.flair-prompt-input {
  flex: 1 1 200px;
}

.flair-gen-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

@media (max-width: 575.98px) {
  .topbar {
    gap: 4px;
    padding: 0 10px;
  }

  .brand-badge {
    width: 22px;
    height: 22px;
  }

  .vault-category-header {
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .vault-category-body {
    padding: 10px 12px;
  }

  .vault-pager {
    flex-direction: column;
    align-items: stretch;
  }

  .vault-pager-controls {
    margin-left: 0;
    justify-content: space-between;
  }
}

/* --- Proper Game Hub Landing Page --- */
.game-hub-view {
  animation: fadeIn 0.18s ease-in-out;
}

.game-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.game-tile-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  cursor: pointer;
}

.game-tile-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.08);
}

.game-tile-card.is-stack:hover {
  border-color: #38bdf8;
  box-shadow: 0 10px 28px rgba(56, 189, 248, 0.14);
}

.game-tile-card.is-crossword:hover {
  border-color: #f43f5e;
  box-shadow: 0 10px 28px rgba(244, 63, 94, 0.14);
}

.game-tile-card.is-minesweeper:hover {
  border-color: #fb7185;
  box-shadow: 0 10px 28px rgba(251, 113, 133, 0.14);
}

.game-tile-card.is-slope:hover {
  border-color: #22d3ee;
  box-shadow: 0 10px 28px rgba(34, 211, 238, 0.14);
}

.game-tile-card.is-2048:hover {
  border-color: #f59e0b;
  box-shadow: 0 10px 28px rgba(245, 158, 11, 0.14);
}

.game-tile-card.is-wheels:hover {
  border-color: #22c55e;
  box-shadow: 0 10px 28px rgba(34, 197, 94, 0.16);
}

.game-tile-card.is-soon {
  opacity: 0.72;
  cursor: default;
}

.game-tile-card.is-soon:hover {
  transform: none;
  box-shadow: var(--shadow);
  border-color: var(--line);
}

.game-tile-badge-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.game-tile-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
}

.game-tile-visual {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.game-tile-visual .game-hub-icon {
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  border-radius: 14px;
}

.game-tile-visual .game-hub-icon svg {
  width: 34px;
  height: 34px;
}

.game-tile-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.game-tile-title {
  font-size: 1.18rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--ink);
}

.game-tile-desc {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 14px;
}

.game-tile-features {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.game-tile-features span {
  font-size: 0.72rem;
  font-weight: 550;
  padding: 3px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--line) 45%, transparent);
  color: var(--ink);
}

.game-tile-foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.game-tile-launch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 650;
  font-size: 0.88rem;
  padding: 8px 16px;
  border-radius: 8px;
  width: 100%;
  transition: transform 0.12s ease, background 0.12s ease;
}

.game-tile-launch-btn svg {
  width: 16px;
  height: 16px;
}

.game-tile-card:hover .game-tile-launch-btn:not(:disabled) {
  transform: translateY(-1px);
}

/* --- Hub Hall of Fame Card --- */
.game-hub-hall-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.game-hub-hall-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.game-hub-hall-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.game-hall-pill {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.game-hall-pill:hover {
  color: var(--ink);
  border-color: var(--blue);
}

.game-hall-pill.is-active {
  background: var(--blue);
  color: #ffffff;
  border-color: var(--blue);
}

.game-hall-launch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 650;
  border-radius: 8px;
}

/* --- Stage Navigation Bar --- */
.game-stage-nav-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.game-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 650;
  font-size: 0.85rem;
  padding: 8px 14px;
  border-radius: 8px;
  white-space: nowrap;
}

.game-back-btn svg {
  width: 15px;
  height: 15px;
}

.game-stage-nav-bar .game-hub-strip {
  flex: 1 1 auto;
  margin-bottom: 0;
}

.game-hub-icon.is-breakout {
  background: rgba(168, 85, 247, 0.14);
}

/* --- Games Hub & Stack 3D --- */
.game-hub-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.game-hub-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

button.game-hub-card {
  cursor: pointer;
}

button.game-hub-card:hover {
  transform: translateY(-1px);
  border-color: var(--blue);
}

.game-hub-card.is-active {
  border-color: var(--blue);
  background: linear-gradient(135deg, color-mix(in srgb, var(--blue) 9%, var(--card)), var(--card));
  box-shadow: 0 4px 14px rgba(29, 95, 208, 0.12);
}

.game-hub-card.is-soon {
  opacity: 0.68;
  user-select: none;
}

.game-hub-icon {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.game-hub-icon svg {
  width: 28px;
  height: 28px;
}

.game-hub-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.game-hub-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.game-hub-title-row strong {
  font-size: 0.95rem;
  font-weight: 650;
}

.game-hub-info > span {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.3;
}

.game-hub-tag {
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  white-space: nowrap;
}

.game-hub-tag.is-live {
  background: rgba(56, 189, 248, 0.16);
  color: #0284c7;
}

html[data-theme="dark"] .game-hub-tag.is-live {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
}

.games-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.95fr);
  gap: 16px;
  align-items: start;
}

.game-stage-card {
  overflow: hidden;
  border: 1px solid var(--line);
}

.game-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.game-stage-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.game-stage-hint {
  font-size: 0.82rem;
  color: var(--muted);
}

.game-stage-hint kbd,
.game-overlay-keys kbd {
  display: inline-block;
  padding: 1px 6px;
  font-size: 0.74rem;
  font-family: inherit;
  font-weight: 600;
  border-radius: 5px;
  background: var(--chip);
  color: var(--ink);
  border: 1px solid var(--line);
}

.game-stage-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  background: var(--fill);
  border: 1px solid var(--line);
  color: var(--muted);
}

.game-stat-pill strong {
  color: var(--ink);
  font-weight: 700;
}

.game-viewport-wrap {
  position: relative;
  width: 100%;
  height: 540px;
  background: radial-gradient(circle at 50% 28%, #163052 0%, #0b1628 58%, #060b14 100%);
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
  cursor: pointer;
}

#stack-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.game-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 20px;
}

.game-hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.game-hud-target {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f8fafc;
  font-size: 0.8rem;
}

.game-hud-target-label {
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

.game-hud-speed {
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  font-size: 0.76rem;
  font-weight: 600;
}

.game-hud-center {
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.game-hud-score {
  font-size: 4.2rem;
  font-weight: 800;
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 6px 24px rgba(0, 0, 0, 0.45), 0 0 18px rgba(56, 189, 248, 0.35);
  letter-spacing: -0.03em;
}

.game-hud-combo {
  margin-top: 8px;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: rgba(56, 189, 248, 0.22);
  border: 1px solid rgba(56, 189, 248, 0.55);
  color: #e0f2fe;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.game-hud-combo.is-hot {
  background: rgba(250, 204, 21, 0.24);
  border-color: rgba(250, 204, 21, 0.75);
  color: #fef08a;
  box-shadow: 0 0 18px rgba(250, 204, 21, 0.35);
}

.game-hud-pop {
  margin-top: 10px;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #38bdf8;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.65);
  animation: gamePopFloat 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.game-hud-pop.is-gold {
  color: #facc15;
  text-shadow: 0 0 14px rgba(250, 204, 21, 0.65), 0 2px 10px rgba(0, 0, 0, 0.7);
}

@keyframes gamePopFloat {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.85);
  }
  22% {
    opacity: 1;
    transform: translateY(0) scale(1.06);
  }
  100% {
    opacity: 0;
    transform: translateY(-18px) scale(0.96);
  }
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 11, 20, 0.48);
  backdrop-filter: blur(5px);
  z-index: 5;
}

.game-overlay-card {
  max-width: 390px;
  width: 100%;
  padding: 26px 24px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  color: #f8fafc;
  text-align: center;
  cursor: default;
}

.game-overlay-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
  margin-bottom: 10px;
}

.game-record-banner {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, #f59e0b, #eab308);
  color: #0f172a;
  margin-bottom: 10px;
  box-shadow: 0 0 20px rgba(250, 204, 21, 0.45);
}

.game-overlay-title {
  font-size: 1.65rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: #ffffff;
}

.game-overlay-desc {
  font-size: 0.9rem;
  color: #cbd5e1;
  line-height: 1.45;
  margin-bottom: 18px;
}

.game-play-btn {
  padding: 10px 28px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 999px;
  background: linear-gradient(135deg, #2563eb, #0284c7);
  border: none;
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.45);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.game-play-btn:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 8px 25px rgba(2, 132, 199, 0.6);
}

.game-overlay-keys {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: #94a3b8;
}

.game-overlay-keys kbd {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: #f8fafc;
}

.game-over-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.game-over-stat {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.game-over-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
}

.game-over-val {
  font-size: 1.35rem;
  font-weight: 800;
  color: #f8fafc;
}

.game-over-val.is-primary {
  color: #38bdf8;
}

.game-save-status {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-bottom: 14px;
}

/* --- Leaderboard Card --- */
.game-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.game-trophy-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(234, 179, 8, 0.15);
  color: #d97706;
}

html[data-theme="dark"] .game-trophy-icon {
  background: rgba(250, 204, 21, 0.16);
  color: #facc15;
}

.game-board-sub {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.game-board-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-board-empty {
  padding: 28px 16px;
  text-align: center;
  border-radius: 10px;
  background: var(--fill);
  border: 1px dashed var(--line);
}

.game-board-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--fill);
  border: 1px solid var(--line);
  transition: border-color 0.12s ease;
}

.game-board-row.is-me {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 6%, var(--fill));
}

.game-rank-badge {
  flex: 0 0 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 750;
  background: var(--chip);
  color: var(--muted);
}

.game-rank-badge.is-gold {
  background: linear-gradient(135deg, #fef08a, #f59e0b);
  color: #451a03;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.game-rank-badge.is-silver {
  background: linear-gradient(135deg, #f1f5f9, #94a3b8);
  color: #0f172a;
}

.game-rank-badge.is-bronze {
  background: linear-gradient(135deg, #fed7aa, #d97706);
  color: #431407;
}

.game-board-player {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.game-board-identity {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.game-board-badge {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  object-fit: contain;
  flex: 0 0 auto;
}

.game-board-you {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
}

html[data-theme="dark"] .game-board-you {
  color: #60a5fa;
}

.game-board-tag {
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--chip);
  padding: 1px 6px;
  border-radius: 6px;
}

.game-board-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.74rem;
  color: var(--muted);
}

.game-board-combo {
  font-weight: 600;
  color: #0284c7;
}

html[data-theme="dark"] .game-board-combo {
  color: #38bdf8;
}

.game-board-score {
  flex: 0 0 auto;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}

.game-board-score strong {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink);
}

.game-board-score span {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--muted);
}

/* --- Mini Crossword Stage --- */
.game-hub-icon.is-crossword {
  background: rgba(244, 63, 94, 0.14);
}

.cw-stage {
  position: relative;
  padding: 18px 20px 22px;
  background:
    radial-gradient(circle at 15% 10%, rgba(244, 63, 94, 0.08), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(56, 189, 248, 0.08), transparent 45%),
    var(--card);
  min-height: 540px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cw-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.cw-puzzle-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cw-picker-label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0;
}

.cw-select {
  width: auto;
  min-width: 190px;
  font-size: 0.85rem;
  font-weight: 650;
  border-radius: 9px;
  background-color: var(--fill);
  color: var(--ink);
  border-color: var(--line);
}

.cw-solved-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.16);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

html[data-theme="dark"] .cw-solved-pill {
  color: #34d399;
}

.cw-toolbar-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.cw-timer-pill,
.cw-score-pill {
  font-size: 0.8rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--fill);
  border: 1px solid var(--line);
  color: var(--ink);
}

.cw-score-pill {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: color-mix(in srgb, var(--blue) 24%, var(--line));
}

html[data-theme="dark"] .cw-score-pill {
  color: #38bdf8;
}

.cw-tool-btn {
  font-size: 0.78rem;
  font-weight: 650;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--fill);
  border: 1px solid var(--line);
  color: var(--ink);
  transition: all 0.12s ease;
}

.cw-tool-btn:hover {
  border-color: var(--blue);
  background: var(--chip);
}

.cw-tool-btn[aria-pressed="true"] {
  background: #f59e0b;
  border-color: #d97706;
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

.cw-layout {
  display: grid;
  grid-template-columns: minmax(280px, 370px) 1fr;
  gap: 22px;
  align-items: start;
}

.cw-board-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.cw-grid {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 4px;
  padding: 6px;
  border-radius: 14px;
  background: #1e293b;
  border: 2px solid #334155;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
  user-select: none;
  touch-action: manipulation;
}

.cw-cell {
  position: relative;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s ease, background-color 0.12s ease, border-color 0.12s ease;
}

html[data-theme="dark"] .cw-cell {
  background: #0f172a;
  color: #f8fafc;
}

.cw-cell.is-block {
  background: #090d16;
  cursor: default;
  pointer-events: none;
  border-color: transparent;
}

.cw-cell.is-word {
  background: #e0f2fe;
}

html[data-theme="dark"] .cw-cell.is-word {
  background: rgba(56, 189, 248, 0.18);
}

.cw-cell.is-active {
  background: #fef08a;
  border-color: #eab308;
  color: #0f172a;
  transform: scale(1.02);
  z-index: 2;
  box-shadow: 0 3px 10px rgba(234, 179, 8, 0.35);
}

html[data-theme="dark"] .cw-cell.is-active {
  background: #facc15;
  border-color: #fef08a;
  color: #0f172a;
}

.cw-cell-num {
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 0.64rem;
  font-weight: 800;
  line-height: 1;
  color: #64748b;
  pointer-events: none;
}

html[data-theme="dark"] .cw-cell-num {
  color: #94a3b8;
}

.cw-cell.is-active .cw-cell-num {
  color: #422006;
}

.cw-cell-letter {
  font-size: 1.55rem;
  font-weight: 850;
  line-height: 1;
  margin-top: 6px;
  letter-spacing: -0.02em;
  pointer-events: none;
}

.cw-cell.is-pencil .cw-cell-letter {
  color: #64748b;
  font-style: italic;
  font-weight: 700;
}

html[data-theme="dark"] .cw-cell.is-pencil .cw-cell-letter {
  color: #94a3b8;
}

.cw-cell.is-active.is-pencil .cw-cell-letter {
  color: #475569;
}

.cw-cell.is-correct::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #10b981;
}

.cw-cell.is-error {
  border-color: #f43f5e;
  animation: cwShake 0.28s ease;
}

.cw-cell.is-error .cw-cell-letter {
  color: #e11d48;
}

html[data-theme="dark"] .cw-cell.is-error .cw-cell-letter {
  color: #fb7185;
}

.cw-cell.is-wave {
  animation: cwWave 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  border-color: #10b981;
}

@keyframes cwShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

@keyframes cwWave {
  0% { transform: scale(1); }
  45% { transform: translateY(-6px) scale(1.06); background: #a7f3d0; color: #064e3b; }
  100% { transform: scale(1); }
}

/* Active Clue Banner */
.cw-clue-bar {
  width: 100%;
  max-width: 360px;
  display: flex;
  align-items: stretch;
  gap: 6px;
  background: var(--blue-soft);
  border: 1px solid color-mix(in srgb, var(--blue) 28%, var(--line));
  border-radius: 11px;
  padding: 5px;
}

.cw-clue-nav {
  flex: 0 0 34px;
  border: none;
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.cw-clue-nav:hover {
  background: var(--chip);
}

.cw-active-clue {
  flex: 1 1 auto;
  border: none;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  min-width: 0;
}

.cw-active-clue-tag {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--blue);
  color: #ffffff;
}

.cw-active-clue-text {
  font-size: 0.84rem;
  font-weight: 650;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* On-Screen Touch QWERTY Keyboard */
.cw-keyboard {
  width: 100%;
  max-width: 370px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  user-select: none;
  touch-action: manipulation;
}

.cw-kb-row {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.cw-key {
  flex: 1 1 0;
  min-width: 0;
  height: 38px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--fill);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 750;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition: transform 0.06s ease, background-color 0.1s ease;
}

.cw-key.is-wide {
  flex: 1.55 1 0;
  font-size: 0.74rem;
  background: var(--chip);
}

.cw-key:hover {
  border-color: var(--blue);
}

.cw-key:active {
  transform: translateY(1px) scale(0.97);
  background: var(--blue);
  color: #ffffff;
}

/* Clues Columns */
.cw-clues-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  min-width: 0;
}

.cw-clue-group {
  background: var(--fill);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cw-clue-heading {
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.cw-clue-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cw-clue-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 6px 8px;
  border-radius: 8px;
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 0.82rem;
  line-height: 1.3;
  cursor: pointer;
  transition: background-color 0.1s ease, border-color 0.1s ease;
}

.cw-clue-item:hover {
  background: var(--chip);
}

.cw-clue-item.is-active {
  background: var(--blue-soft);
  border-color: color-mix(in srgb, var(--blue) 35%, var(--line));
  font-weight: 650;
}

.cw-clue-item.is-done {
  opacity: 0.55;
}

.cw-clue-item.is-done .cw-clue-item-text {
  text-decoration: line-through;
}

.cw-clue-item-num {
  flex: 0 0 20px;
  font-weight: 800;
  color: var(--blue);
  font-size: 0.78rem;
}

html[data-theme="dark"] .cw-clue-item-num {
  color: #38bdf8;
}

.cw-clue-item-text {
  flex: 1 1 auto;
}

/* --- Minesweeper Stage --- */
.game-hub-icon.is-minesweeper {
  background: rgba(244, 63, 94, 0.13);
}

.ms-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px 18px;
  background:
    radial-gradient(circle at 12% 8%, rgba(56, 189, 248, 0.08), transparent 42%),
    radial-gradient(circle at 88% 92%, rgba(244, 63, 94, 0.08), transparent 42%),
    var(--card);
}

.ms-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ms-diff-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--fill);
  border: 1px solid var(--line);
}

.ms-diff-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.ms-diff-btn span {
  margin-left: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  opacity: 0.62;
}

.ms-diff-btn:hover {
  color: var(--ink);
}

.ms-diff-btn.is-active {
  background: linear-gradient(135deg, #2563eb, #0284c7);
  color: #f8fafc;
  box-shadow: 0 3px 10px rgba(2, 132, 199, 0.35);
}

.ms-diff-btn.is-active span {
  opacity: 0.82;
}

.ms-toolbar-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}

.ms-stat-pill {
  gap: 5px;
  font-variant-numeric: tabular-nums;
}

.ms-stat-pill strong {
  font-variant-numeric: tabular-nums;
  min-width: 1.2em;
  text-align: left;
}

.ms-stat-pill.is-score strong {
  color: #0284c7;
}

html[data-theme="dark"] .ms-stat-pill.is-score strong {
  color: #38bdf8;
}

.ms-pill-icon {
  width: 14px;
  height: 14px;
  opacity: 0.8;
  flex: 0 0 auto;
}

.ms-flag-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--fill);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.1;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.ms-flag-btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.ms-flag-btn:hover {
  color: var(--ink);
  border-color: rgba(244, 63, 94, 0.5);
}

.ms-flag-btn.is-active {
  background: linear-gradient(135deg, #f97316, #f43f5e);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.35);
}

.ms-arena {
  position: relative;
  height: clamp(440px, 66vh, 620px);
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 8%, #132844 0%, #08111f 52%, #04080f 100%);
  border: 1px solid rgba(56, 189, 248, 0.14);
  box-shadow: inset 0 0 46px rgba(2, 132, 199, 0.09);
}

#ms-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#ms-canvas:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(56, 189, 248, 0.6);
}

.ms-arena .game-overlay {
  border-radius: 16px;
}

@media (max-width: 991.98px) {
  .ms-arena {
    height: clamp(420px, 62vh, 560px);
  }
}

@media (max-width: 575.98px) {
  .ms-stage {
    padding: 10px;
  }

  .ms-toolbar {
    gap: 8px;
  }

  .ms-diff-group {
    flex: 1 1 auto;
  }

  .ms-diff-btn {
    flex: 1 1 0;
    padding: 6px 8px;
  }

  .ms-diff-btn span {
    display: none;
  }

  .ms-toolbar-stats {
    order: 3;
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .ms-stat-pill {
    padding: 4px 8px;
    font-size: 0.78rem;
  }

  .ms-flag-btn {
    padding: 6px 11px;
  }

  .ms-arena {
    height: clamp(430px, 66vh, 590px);
  }
}

@media (max-width: 991.98px) {
  .games-workspace {
    grid-template-columns: 1fr;
  }

  .game-viewport-wrap {
    height: 440px;
  }

  .cw-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 575.98px) {
  .game-catalog-grid {
    grid-template-columns: 1fr;
  }

  .game-stage-nav-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .game-stage-nav-bar .game-back-btn {
    width: 100%;
    justify-content: center;
  }

  .game-hub-strip {
    grid-template-columns: 1fr 1fr;
  }

  .game-hub-card {
    min-width: 0;
    padding: 10px;
    gap: 8px;
  }

  .game-hub-title-row {
    flex-wrap: wrap;
    gap: 4px;
  }

  .game-hub-card .game-hub-tag {
    font-size: 0.58rem;
    padding: 2px 5px;
  }

  .game-hub-info > span {
    display: none;
  }

  .game-viewport-wrap {
    height: 390px;
  }

  .game-hud-score {
    font-size: 3.2rem;
  }

  .cw-stage {
    padding: 12px;
  }

  .cw-grid {
    max-width: 300px;
  }

  .cw-cell-letter {
    font-size: 1.35rem;
  }

  .cw-clues-col {
    grid-template-columns: 1fr;
  }

  .cw-key {
    height: 40px;
  }
}

/* --- Neon Slope Stage --- */
.game-hub-icon.is-slope {
  background: rgba(34, 211, 238, 0.14);
}

.slope-stage {
  position: relative;
  width: 100%;
}

.slope-viewport-wrap {
  position: relative;
  width: 100%;
  height: 540px;
  background: radial-gradient(circle at 50% 18%, #1e1035 0%, #0c0818 55%, #05020a 100%);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  cursor: pointer;
  border-radius: 16px;
}

#slope-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.slope-gem-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--fill);
  border: 1px solid rgba(34, 211, 238, 0.4);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  color: #22d3ee;
}

.slope-gem-icon {
  width: 14px;
  height: 14px;
}

.slope-touch-zones {
  position: absolute;
  bottom: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  z-index: 8;
  pointer-events: none;
}

.slope-touch-btn {
  pointer-events: auto;
  border: 1px solid rgba(34, 211, 238, 0.35);
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(8px);
  color: #f8fafc;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 750;
  padding: 9px 18px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  transition: transform 0.08s ease, background-color 0.12s ease;
}

.slope-touch-btn:active {
  transform: scale(0.94);
  background: rgba(34, 211, 238, 0.3);
}

.slope-touch-btn.is-jump {
  padding: 10px 24px;
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.8), rgba(168, 85, 247, 0.8));
  border-color: rgba(244, 63, 94, 0.5);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@media (max-width: 991.98px) {
  .slope-viewport-wrap {
    height: 440px;
  }
}

@media (max-width: 575.98px) {
  .slope-viewport-wrap {
    height: 390px;
  }
  .slope-touch-btn {
    padding: 8px 14px;
    font-size: 0.82rem;
  }
}

/* --- 2048 Neon Stage --- */
.game-hub-icon.is-2048 {
  background: rgba(245, 158, 11, 0.14);
}

.n2048-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px 20px;
  background:
    radial-gradient(circle at 14% 10%, rgba(245, 158, 11, 0.08), transparent 44%),
    radial-gradient(circle at 86% 90%, rgba(16, 185, 129, 0.08), transparent 44%),
    var(--card);
}

.n2048-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.n2048-toolbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.n2048-stat-pill {
  font-variant-numeric: tabular-nums;
  gap: 5px;
}

.n2048-stat-pill.is-tile strong {
  color: #f59e0b;
}

.n2048-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.n2048-tool-btn {
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--fill);
  color: var(--ink);
  padding: 5px 12px;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.n2048-tool-btn:hover:not(:disabled) {
  background: var(--chip);
  border-color: var(--blue);
}

.n2048-arena {
  position: relative;
  border-radius: 16px;
  background: radial-gradient(circle at 50% 20%, #111a2e 0%, #080d17 65%, #04070d 100%);
  border: 1px solid rgba(56, 189, 248, 0.18);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5);
  padding: 20px 14px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.n2048-board-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 380px;
}

.n2048-board {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #090e18;
  border: 2px solid rgba(56, 189, 248, 0.22);
  border-radius: 16px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), inset 0 0 24px rgba(2, 132, 199, 0.12);
  touch-action: none;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
}

.n2048-board:focus-visible {
  box-shadow: 0 0 0 2px var(--blue);
}

.n2048-cell {
  background: rgba(15, 23, 42, 0.65);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 800;
  font-size: clamp(1.15rem, 4.8vw, 1.85rem);
  border: 1px solid rgba(255, 255, 255, 0.04);
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.n2048-cell.is-pop {
  animation: n2048Pop 0.18s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes n2048Pop {
  0% { transform: scale(0.78); }
  50% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

@keyframes n2048Glow {
  0% { box-shadow: 0 0 20px rgba(251, 191, 36, 0.6), inset 0 0 10px rgba(251, 191, 36, 0.3); }
  100% { box-shadow: 0 0 38px rgba(251, 191, 36, 0.95), inset 0 0 18px rgba(251, 191, 36, 0.6); }
}

/* Neon Tile Colors */
.n2048-cell.tile-2 {
  background: rgba(6, 182, 212, 0.16);
  color: #00f0ff;
  border-color: rgba(6, 182, 212, 0.45);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.22);
}

.n2048-cell.tile-4 {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.26);
}

.n2048-cell.tile-8 {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.55);
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.3);
}

.n2048-cell.tile-16 {
  background: rgba(132, 204, 22, 0.22);
  color: #a3e635;
  border-color: rgba(132, 204, 22, 0.6);
  box-shadow: 0 0 16px rgba(132, 204, 22, 0.35);
}

.n2048-cell.tile-32 {
  background: rgba(245, 158, 11, 0.24);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.65);
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.4);
}

.n2048-cell.tile-64 {
  background: rgba(249, 115, 22, 0.26);
  color: #fb923c;
  border-color: rgba(249, 115, 22, 0.7);
  box-shadow: 0 0 20px rgba(249, 115, 22, 0.45);
}

.n2048-cell.tile-128 {
  background: rgba(244, 63, 94, 0.28);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.75);
  box-shadow: 0 0 24px rgba(244, 63, 94, 0.5);
  font-size: clamp(1rem, 4vw, 1.6rem);
}

.n2048-cell.tile-256 {
  background: rgba(236, 72, 153, 0.3);
  color: #f472b6;
  border-color: rgba(236, 72, 153, 0.8);
  box-shadow: 0 0 28px rgba(236, 72, 153, 0.55);
  font-size: clamp(1rem, 4vw, 1.6rem);
}

.n2048-cell.tile-512 {
  background: rgba(168, 85, 247, 0.32);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.85);
  box-shadow: 0 0 32px rgba(168, 85, 247, 0.6);
  font-size: clamp(0.92rem, 3.8vw, 1.5rem);
}

.n2048-cell.tile-1024 {
  background: rgba(99, 102, 241, 0.35);
  color: #818cf8;
  border-color: rgba(99, 102, 241, 0.9);
  box-shadow: 0 0 36px rgba(99, 102, 241, 0.7);
  font-size: clamp(0.82rem, 3.4vw, 1.3rem);
}

.n2048-cell.tile-2048 {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.45), rgba(236, 72, 153, 0.45));
  color: #fef08a;
  border-color: #fbbf24;
  font-size: clamp(0.82rem, 3.4vw, 1.3rem);
  animation: n2048Glow 2.2s infinite alternate;
}

.n2048-cell.tile-super {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.5), rgba(251, 191, 36, 0.5));
  color: #ffffff;
  border-color: #00f0ff;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.8);
  font-size: clamp(0.78rem, 3.2vw, 1.2rem);
}

/* Touch D-Pad */
.n2048-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  user-select: none;
  -webkit-user-select: none;
}

.n2048-dpad-row {
  display: flex;
  gap: 6px;
}

.n2048-dpad-btn {
  width: 48px;
  height: 42px;
  border-radius: 9px;
  border: 1px solid rgba(56, 189, 248, 0.28);
  background: rgba(15, 23, 42, 0.85);
  color: #f8fafc;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, background-color 0.1s ease, border-color 0.1s ease;
}

.n2048-dpad-btn:active {
  transform: scale(0.92);
  background: var(--blue);
  border-color: var(--blue);
}

@media (max-width: 575.98px) {
  .n2048-stage {
    padding: 10px;
  }
  .n2048-board {
    gap: 7px;
    padding: 8px;
  }
  .n2048-cell {
    border-radius: 8px;
  }
  .n2048-dpad-btn {
    width: 44px;
    height: 38px;
    font-size: 1rem;
  }
}

/* --- Wacky Wheels Stage --- */
.game-hub-icon.is-wheels {
  background: rgba(34, 197, 94, 0.15);
}

.ww-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px 16px;
  background:
    radial-gradient(circle at 12% 10%, rgba(34, 197, 94, 0.08), transparent 44%),
    radial-gradient(circle at 88% 90%, rgba(250, 204, 21, 0.08), transparent 44%),
    var(--card);
}

.ww-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.ww-mode-tabs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  background: var(--fill);
  border: 1px solid var(--line);
  max-width: 100%;
  overflow-x: auto;
}

.ww-mode-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.14s ease, color 0.14s ease;
}

.ww-mode-tab:hover {
  color: var(--ink);
}

.ww-mode-tab.is-active {
  background: linear-gradient(135deg, #16a34a, #0284c7);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.ww-count-badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  color: inherit;
}

.ww-mode-tab:not(.is-active) .ww-count-badge {
  background: var(--chip);
}

.ww-custom-playing-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--ink);
}

.ww-mini-btn {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--fill);
  color: var(--ink);
}

.ww-mini-btn:hover {
  background: var(--chip);
  border-color: var(--blue);
}

.ww-editor-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 12px;
  background: var(--fill);
  border: 1px solid var(--line);
}

.ww-tool-palette {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.ww-tool-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.ww-tool-btn:hover {
  border-color: var(--blue);
}

.ww-tool-btn.is-active {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

.ww-tool-btn.is-danger.is-active {
  background: #e11d48;
  border-color: #e11d48;
  color: #ffffff;
}

.ww-editor-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ww-ed-act-btn {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
}

.ww-ed-act-btn.is-test {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
}

.ww-ed-act-btn.is-publish {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  margin-left: auto;
}

.ww-restart-pill.is-edit-return {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.55);
  color: var(--ink);
}

.ww-editor-hint-pill {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #e2e8f0;
  font-size: 0.76rem;
  padding: 5px 14px;
  border-radius: 999px;
  pointer-events: none;
  z-index: 7;
  white-space: nowrap;
  max-width: calc(100% - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.ww-levels-card {
  width: min(640px, 100%);
  max-height: 92%;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 18px 20px;
}

.ww-levels-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.ww-levels-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 360px;
  padding-right: 4px;
}

.ww-level-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.ww-level-row-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.ww-level-title {
  font-size: 0.96rem;
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 2px;
}

.ww-level-desc {
  font-size: 0.8rem;
  color: #cbd5e1;
  margin-bottom: 4px;
}

.ww-level-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: #94a3b8;
}

.ww-level-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ww-publish-card {
  width: min(440px, 100%);
}

.ww-dark-input {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #f8fafc;
}

.ww-dark-input:focus {
  background: rgba(15, 23, 42, 0.95);
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.ww-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.ww-toolbar-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ww-stat-pill {
  font-variant-numeric: tabular-nums;
  gap: 5px;
}

.ww-stat-pill.is-stars strong {
  color: #eab308;
}

html[data-theme="dark"] .ww-stat-pill.is-stars strong {
  color: #facc15;
}

.ww-stat-pill.is-combo strong {
  color: #16a34a;
}

html[data-theme="dark"] .ww-stat-pill.is-combo strong {
  color: #4ade80;
}

.ww-mini-track {
  display: inline-block;
  width: 48px;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.28);
  overflow: hidden;
  vertical-align: middle;
}

.ww-mini-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, #facc15);
  transition: width 0.1s linear;
}

.ww-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.ww-restart-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--fill);
  color: var(--ink);
  padding: 5px 12px;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.ww-restart-pill:hover {
  background: var(--chip);
  border-color: var(--blue);
}

.ww-viewport {
  position: relative;
  width: 100%;
  height: clamp(460px, 66vh, 580px);
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, #0b1930 0%, #153154 55%, #1e4268 100%);
  border: 1px solid rgba(56, 189, 248, 0.2);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.35);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.ww-viewport .game-overlay {
  padding: 14px;
  overflow-y: auto;
}

.ww-viewport .game-overlay-card {
  padding: 20px 22px;
}

#ww-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.ww-center-hud {
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  z-index: 6;
}

.ww-score-readout {
  font-size: 2.3rem;
  font-weight: 900;
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.55);
  font-variant-numeric: tabular-nums;
}

.ww-streak-pill {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.9), rgba(16, 185, 129, 0.9));
  color: #ffffff;
  font-weight: 800;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.ww-pop-banner {
  color: #fde047;
  font-weight: 900;
  font-size: 1.05rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.75);
}

/* Touch Control Pad */
.ww-touch-pad {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 8;
}

.ww-touch-cluster {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.ww-touch-cluster.is-right {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  gap: 8px;
  justify-items: end;
}

.ww-touch-cluster.is-right .is-eject {
  grid-column: 2;
  grid-row: 1;
}

.ww-touch-cluster.is-right .is-brake {
  grid-column: 1;
  grid-row: 2;
}

.ww-touch-cluster.is-right .is-gas {
  grid-column: 2;
  grid-row: 2;
}

.ww-touch-btn {
  pointer-events: auto;
  width: 62px;
  height: 54px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(15, 23, 42, 0.74);
  backdrop-filter: blur(8px);
  color: #f8fafc;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.36);
  transition: transform 0.06s ease, background-color 0.1s ease, border-color 0.1s ease;
}

.ww-touch-btn .ww-btn-glyph {
  font-size: 1.2rem;
  line-height: 1;
  font-weight: 800;
}

.ww-touch-btn .ww-btn-sub {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  opacity: 0.82;
}

.ww-touch-btn:active,
.ww-touch-btn.is-pressed {
  transform: scale(0.92);
  background: rgba(56, 189, 248, 0.42);
  border-color: #38bdf8;
}

.ww-touch-btn.is-gas {
  background: linear-gradient(145deg, rgba(34, 197, 94, 0.82), rgba(21, 128, 61, 0.86));
  border-color: rgba(74, 222, 128, 0.6);
}

.ww-touch-btn.is-gas:active,
.ww-touch-btn.is-gas.is-pressed {
  background: rgba(34, 197, 94, 0.98);
  border-color: #bbf7d0;
}

.ww-touch-btn.is-brake {
  background: linear-gradient(145deg, rgba(239, 68, 68, 0.78), rgba(185, 28, 28, 0.84));
  border-color: rgba(252, 165, 165, 0.5);
}

.ww-touch-btn.is-brake:active,
.ww-touch-btn.is-brake.is-pressed {
  background: rgba(239, 68, 68, 0.96);
  border-color: #fecaca;
}

.ww-touch-btn.is-eject {
  width: 62px;
  height: 46px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.88), rgba(236, 72, 153, 0.88));
  border-color: rgba(253, 224, 71, 0.65);
}

.ww-touch-btn.is-eject:active,
.ww-touch-btn.is-eject.is-pressed {
  background: linear-gradient(135deg, #f59e0b, #ec4899);
}

@media (max-width: 991.98px) {
  .ww-viewport {
    height: clamp(400px, 60vh, 500px);
  }
}

@media (max-width: 575.98px) {
  .ww-stage {
    padding: 10px;
    gap: 8px;
  }

  .ww-mode-tab {
    padding: 5px 8px;
    font-size: 0.71rem;
    gap: 3px;
  }

  .ww-toolbar-stats {
    gap: 4px;
  }

  .ww-stat-pill {
    padding: 4px 7px;
    font-size: 0.74rem;
  }

  .ww-mini-track {
    width: 30px;
  }

  .ww-restart-pill span {
    display: none;
  }

  .ww-viewport {
    height: clamp(390px, 60vh, 470px);
  }

  .ww-score-readout {
    font-size: 1.9rem;
  }

  .ww-touch-pad {
    left: 8px;
    right: 8px;
    bottom: 8px;
  }

  .ww-touch-cluster,
  .ww-touch-cluster.is-right {
    gap: 6px;
  }

  .ww-touch-btn {
    width: 54px;
    height: 48px;
    border-radius: 12px;
  }

  .ww-touch-btn.is-eject {
    width: 54px;
    height: 42px;
  }
}




