/**
 * MoroisiHome unified shell.
 * One shared UI entrypoint for site pages, project directory pages and project pages.
 */
:root {
  --shell-brand: var(--accent, var(--brand, #ff6b61));
  --shell-brand-hover: var(--accent-dark, var(--brand-dark, var(--brand-hover, #d94c43)));
  --shell-ink: var(--text, var(--text-primary, var(--ink, #241d19)));
  --shell-muted: var(--muted, var(--text-secondary, #756a62));
  --shell-line: var(--line, var(--border-subtle, #efe8df));
  --shell-panel: var(--panel, var(--bg-panel, #f8f5f2));
  --shell-focus: 0 0 0 3px rgba(255, 107, 97, 0.22);
  --shell-font: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shell-text-xs: 12px;
  --shell-text-sm: 13px;
  --shell-text-base: 14px;
  --shell-text-md: 16px;
  --shell-text-lg: 20px;
  --shell-title: clamp(32px, 5vw, 56px);
  --shell-topbar-height: 64px;
  --shell-topbar-x: 24px;
  --shell-topbar-mobile-x: 10px;
  --shell-topbar-gap: 14px;
  --shell-topbar-mobile-gap: 8px;
  --shell-brand-width: 80px;
  --shell-brand-mobile-width: 72px;
  --shell-control-height: 40px;
  --shell-touch-height: 44px;
  --shell-stat-width: 132px;
  --shell-mode-card-min-height: 136px;
  --project-font: var(--shell-font);
  --project-title: var(--shell-title);
  --project-text-sm: var(--shell-text-sm);
  --project-text-base: var(--shell-text-base);
  --project-stat-width: var(--shell-stat-width);
}

html {
  scrollbar-gutter: stable;
}

body.moroisi-shell-page {
  font-family: var(--shell-font);
  text-rendering: optimizeLegibility;
}

body.moroisi-shell-page {
  padding-top: 0 !important;
}

body.moroisi-shell-page [hidden] {
  display: none !important;
}

body.moroisi-shell-page > :where(header, nav)[data-moroisi-topbar] {
  margin-top: 0 !important;
}

.moroisi-shell-topbar {
  min-height: var(--shell-topbar-height);
  border-bottom: 1px solid var(--shell-line);
  display: flex;
  align-items: center;
  gap: var(--shell-topbar-gap);
  padding: 9px var(--shell-topbar-x);
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
  z-index: 100;
  font-family: var(--shell-font);
}

.moroisi-shell-brand {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  width: var(--shell-brand-width);
  flex: 0 0 var(--shell-brand-width);
  height: var(--shell-control-height);
  min-height: var(--shell-control-height);
  color: var(--shell-brand);
  font-size: 20px;
  line-height: 1;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.moroisi-shell-back,
.moroisi-shell-btn {
  box-sizing: border-box;
  height: var(--shell-control-height);
  min-height: var(--shell-control-height);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--shell-text-base);
  line-height: 1;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .18s ease, color .18s ease, background .18s ease, box-shadow .18s ease, transform .18s ease;
}

.moroisi-shell-back {
  padding: 0 14px;
  border: 1px solid var(--shell-line);
  background: var(--shell-panel);
  color: var(--shell-ink);
}

.moroisi-shell-back:hover,
.moroisi-shell-btn:hover {
  border-color: var(--shell-brand);
  color: var(--shell-ink);
  box-shadow: inset 0 0 0 1px var(--shell-brand), 0 8px 18px rgba(72, 49, 36, .06);
  transform: translateY(-1px);
}

.moroisi-shell-back:active,
.moroisi-shell-btn:active {
  transform: translateY(0);
}

.moroisi-shell-topbar-spacer {
  flex: 1;
}

.moroisi-shell-topbar-extra {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.moroisi-shell-topbar-extra:empty {
  display: none;
}

.moroisi-shell-topbar-extra .user {
  color: var(--shell-muted);
  font-size: var(--shell-text-sm);
  line-height: 1.2;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.moroisi-shell-actions {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  justify-content: end;
  gap: 10px;
  min-width: 0;
}

.moroisi-shell-btn {
  min-width: 62px;
  min-height: var(--shell-touch-height);
  padding: 0 17px;
  border: 1px solid transparent;
  background: transparent;
}

.moroisi-shell-btn.primary {
  background: var(--shell-brand);
  border-color: var(--shell-brand);
  color: #fff;
}

.moroisi-shell-btn.primary:hover {
  background: var(--shell-brand-hover);
  border-color: var(--shell-brand-hover);
  color: #fff;
}

.moroisi-shell-btn.secondary {
  background: var(--shell-panel);
  color: var(--shell-ink);
  border-color: var(--shell-line);
}

.moroisi-shell-avatar-link {
  width: var(--shell-touch-height);
  height: var(--shell-touch-height);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}

.moroisi-shell-avatar-link img {
  width: var(--shell-touch-height);
  height: var(--shell-touch-height);
  border-radius: 50%;
  object-fit: cover;
}

.moroisi-shell-page :where(h1) {
  font-size: var(--shell-title);
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.moroisi-shell-page :where(h2, h3, p) {
  text-wrap: pretty;
}

.moroisi-shell-page :where(button, input, textarea, select) {
  font-family: var(--shell-font);
}

.moroisi-shell-page :where(.btn, button:not(.cell), input, select, textarea) {
  line-height: 1.2;
}

.moroisi-shell-stat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: var(--shell-stat-width);
  max-width: 100%;
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--shell-line);
  border-radius: 999px;
  background: var(--shell-panel);
  color: var(--shell-muted);
  font-size: var(--shell-text-sm);
  line-height: 1;
  font-weight: 800;
  white-space: nowrap;
}

.moroisi-shell-stat strong {
  color: var(--shell-brand);
  font-weight: 900;
}

.moroisi-shell-stat.is-loading {
  color: var(--shell-muted);
}

.moroisi-shell-stat[data-capacity-pending] {
  visibility: hidden;
}

.moroisi-shell-guide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
  margin: 0 0 20px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--shell-line);
}

.moroisi-shell-guide-main {
  min-width: 0;
}

.moroisi-shell-eyebrow {
  margin: 0 0 6px;
  color: var(--shell-brand);
  font-size: var(--shell-text-xs);
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.moroisi-shell-guide h1 {
  margin: 0 0 8px;
  color: var(--shell-ink);
  font-size: clamp(28px, 4.2vw, 42px);
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.moroisi-shell-guide p {
  max-width: 680px;
  margin: 0;
  color: var(--shell-muted);
  font-size: var(--shell-text-base);
  line-height: 1.58;
}

.moroisi-shell-panel,
.moroisi-shell-card {
  border: 1px solid var(--shell-line);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 16px 48px rgba(72, 49, 36, 0.06);
}

.moroisi-shell-panel {
  padding: 22px;
}

.moroisi-shell-project-setup {
  display: grid;
  gap: 14px;
}

.moroisi-shell-project-setup h2 {
  margin: 0;
  color: var(--shell-ink);
  font-size: 18px;
  line-height: 1.25;
  font-weight: 900;
}

.moroisi-shell-project-main {
  display: grid;
  gap: 14px;
}

.moroisi-shell-card {
  padding: 18px;
}

.moroisi-shell-mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.moroisi-shell-mode-card {
  min-height: var(--shell-mode-card-min-height);
  border: 1px solid var(--shell-line);
  border-radius: 18px;
  background: #fff;
  padding: 18px;
  text-align: left;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.moroisi-shell-mode-card:hover,
.moroisi-shell-mode-card.active {
  border-color: var(--shell-brand);
  box-shadow: 0 12px 28px rgba(72, 49, 36, 0.07);
  transform: translateY(-1px);
}

.moroisi-shell-mode-card.active {
  background: linear-gradient(180deg, #fff, rgba(255, 107, 97, 0.06));
}

.moroisi-shell-mode-card.compact {
  min-height: 96px;
  padding: 14px;
}

.moroisi-shell-mode-card.comfortable {
  min-height: 118px;
  padding: 17px;
}

.moroisi-shell-mode-card strong {
  display: block;
  font-size: var(--shell-text-lg);
  line-height: 1.25;
}

.moroisi-shell-mode-card p,
.moroisi-shell-note {
  color: var(--shell-muted);
  font-size: var(--shell-text-sm);
  line-height: 1.6;
}

.moroisi-shell-mode-card p {
  margin: 6px 0 0;
}

.moroisi-shell-game-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.moroisi-shell-game-head h2 {
  flex: 1;
  margin: 0;
}

.moroisi-shell-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.moroisi-shell-action-row.center {
  justify-content: center;
}

.moroisi-shell-action-row.project-primary {
  justify-content: center;
  margin-top: 2px;
}

.moroisi-shell-room-panel {
  display: grid;
  gap: 12px;
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--shell-line);
}

.moroisi-shell-room-tools {
  align-items: stretch;
}

.moroisi-shell-room-tools .moroisi-shell-input {
  flex: 1 1 180px;
}

.moroisi-shell-input {
  min-width: 0;
  min-height: 48px;
  flex: 1;
  border: 1px solid var(--shell-line);
  border-radius: 15px;
  background: #fff;
  padding: 0 14px;
  color: var(--shell-ink);
  outline: none;
}

.moroisi-shell-input:focus {
  border-color: var(--shell-brand);
  box-shadow: var(--shell-focus);
}

.moroisi-shell-message {
  min-height: 24px;
  color: var(--shell-muted);
  font-size: var(--shell-text-sm);
  line-height: 1.55;
}

.moroisi-shell-results {
  display: grid;
  gap: 7px;
  margin-top: 15px;
}

.moroisi-shell-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--shell-line);
  border-radius: 14px;
  padding: 10px 13px;
}

.moroisi-shell-score {
  color: var(--shell-brand);
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.moroisi-shell-bar {
  height: 6px;
  overflow: hidden;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--shell-panel);
}

.moroisi-shell-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--shell-brand);
}

.moroisi-shell-segment {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  border-radius: 16px;
  background: var(--shell-panel);
  padding: 5px;
}

.moroisi-shell-segment button {
  border: 0;
  border-radius: 12px;
  background: transparent;
  padding: 10px;
  color: var(--shell-muted);
  font-weight: 850;
}

.moroisi-shell-segment button.active {
  background: #fff;
  color: var(--shell-brand);
  box-shadow: 0 8px 18px rgba(72, 49, 36, 0.08);
}

.moroisi-shell-code {
  color: var(--shell-brand);
  font-size: 21px;
  font-weight: 950;
  letter-spacing: 0.08em;
}

.moroisi-shell-room-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  margin: 10px 0;
  padding: 10px 13px;
  border: 1px solid rgba(255, 107, 97, 0.18);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, rgba(255, 107, 97, 0.045));
}

.moroisi-shell-room-label {
  color: var(--shell-muted);
  font-size: var(--shell-text-xs);
  line-height: 1.2;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.moroisi-shell-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.moroisi-shell-pill {
  border-radius: 999px;
  background: var(--shell-panel);
  padding: 7px 11px;
  font-size: var(--shell-text-sm);
}

.moroisi-shell-btn.ghost {
  background: #fff;
  border-color: rgba(255, 107, 97, 0.35);
  color: var(--shell-brand);
}

.moroisi-shell-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.moroisi-shell-btn.is-placeholder {
  visibility: hidden;
  pointer-events: none;
}

html[data-project-auth="checking"] body {
  visibility: hidden;
}

html[data-project-auth="checking"]::before {
  content: "正在验证登录状态...";
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--shell-muted);
  font: 700 15px var(--shell-font);
  visibility: visible;
}

button,
a,
input,
textarea,
select,
[role="button"],
[tabindex]:not([tabindex="-1"]) {
  scroll-margin: 96px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible {
  outline: 2px solid var(--shell-brand);
  outline-offset: 3px;
  box-shadow: var(--shell-focus);
}

button,
.btn,
a.btn,
[role="button"] {
  min-height: 42px;
}

@media (pointer: coarse) {
  button,
  .btn,
  a.btn,
  [role="button"],
  input,
  select,
  textarea {
    min-height: var(--shell-touch-height);
  }
}

[data-ai-label] {
  -webkit-tap-highlight-color: rgba(255, 107, 97, 0.18);
}

@media (max-width: 640px) {
  .moroisi-shell-topbar {
    gap: var(--shell-topbar-mobile-gap);
    padding: 8px var(--shell-topbar-mobile-x);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .moroisi-shell-topbar::-webkit-scrollbar {
    display: none;
  }

  .moroisi-shell-brand {
    width: var(--shell-brand-mobile-width);
    flex-basis: var(--shell-brand-mobile-width);
    font-size: 18px;
  }

  .moroisi-shell-back {
    padding: 0 12px;
  }

  .moroisi-shell-actions,
  .moroisi-shell-topbar-extra {
    gap: 6px;
  }

  .moroisi-shell-btn {
    padding: 0 12px;
    font-size: var(--shell-text-sm);
  }

  .moroisi-shell-mode-grid {
    grid-template-columns: 1fr;
  }

  .moroisi-shell-guide {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 14px;
  }

  .moroisi-shell-guide h1 {
    font-size: clamp(28px, 9vw, 34px);
  }

  .moroisi-shell-panel {
    padding: 16px;
    border-radius: 20px;
  }

  .moroisi-shell-project-setup {
    gap: 12px;
  }

  .moroisi-shell-game-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .moroisi-shell-result {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (max-width: 430px) {
  .moroisi-shell-stat {
    white-space: normal;
    text-align: center;
  }

  .moroisi-shell-room-tools > .moroisi-shell-btn,
  .moroisi-shell-room-tools > .moroisi-shell-input {
    width: 100%;
    flex: 1 1 100%;
  }
}
