:root {
  --cws-paper: #f5f1e8;
  --cws-paper-deep: #e9dfd0;
  --cws-surface: rgba(250, 248, 242, .35);
  --cws-ink: #2d2323;
  --cws-ink-soft: #66564e;
  --cws-gold: #a87d2a;
  --cws-gold-light: #e6cf91;
  --cws-focus: #77521b;
  --cws-header-background: #59665d;
}

html { background: var(--cws-paper); }

body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 50% 24%, rgba(255, 255, 255, .84), transparent 42%),
    radial-gradient(circle at 12% 72%, rgba(168, 125, 42, .08), transparent 36%),
    linear-gradient(135deg, var(--cws-paper) 0%, #f2ede3 55%, var(--cws-paper-deep) 100%);
  color: var(--cws-ink);
}

.cyber-wabi-sabi-art {
  position: fixed;
  inset: auto 0 0;
  height: min(43vw, 520px);
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: .46;
  background: url('./assets/cyber-wabi-sabi-bottom-v1.png') center bottom / 100% auto no-repeat;
  transform: translateY(4%);
  transition: transform 1.8s ease-out, opacity .8s ease;
}

body > :not(.cyber-wabi-sabi-art) { position: relative; z-index: 1; }

body::after {
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: .52;
  background: radial-gradient(220px circle at var(--cws-pointer-x, 50%) var(--cws-pointer-y, 45%), rgba(228, 201, 139, .20), transparent 68%);
  transition: opacity .35s ease;
}

html[data-cyber-wabi-sabi-state="calculating"] body::before {
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  content: "";
  background: radial-gradient(circle at 50% 46%, rgba(45, 35, 35, .18), transparent 34%), radial-gradient(circle at 50% 46%, transparent 0 23%, rgba(168, 125, 42, .32) 24%, transparent 25%);
  animation: cws-ink-pulse 1.25s ease-in-out infinite alternate;
}

html[data-cyber-wabi-sabi-state="calculating"] .cyber-wabi-sabi-art { opacity: .65; transform: translateY(0); }

@keyframes cws-ink-pulse { from { opacity: .35; transform: scale(.94); } to { opacity: .85; transform: scale(1.04); } }

.topbar, .app-shell, .service-promo, .brand-banner, .reading-sidebar .sidebar-panel,
.dialog, .card, .content, .page-intro, .sub-tab-nav {
  backdrop-filter: blur(8px);
}

.topbar {
  background: var(--cws-header-background);
  background-image: linear-gradient(115deg, rgba(238, 241, 231, .04), rgba(25, 41, 31, .08));
  color: #fff6df;
  border-bottom-color: #ac9869;
  box-shadow: 0 3px 14px rgba(39, 42, 39, .035);
}
.topbar :is(.brand, .brand strong, .brand small, .profile-summary) { color: #fff6df; }
.topbar .button-quiet { background: rgba(255, 250, 239, .08); color: #fff6df; border-color: #b7a77e; text-shadow: none; }
.topbar .button-quiet:hover { background: #fff6df; color: var(--cws-header-background); }

:is(.tabs, .card, .page-intro, .dialog, .reading-sidebar .sidebar-panel, .service-promo,
    .reading-topic, .palace, .overlay-placement-list > div, .overlay-summary,
    .classic-reading, .modern-reading, .callout, .list li, .identity-panel,
    .star-story, .star-pair-portrait, .field, .hour-option, .radio-card,
    .reading-glance > div, .service-product, .service-catalog-end,
    .member-products button, .member-subtabs [role="tab"], .member-system-details,
    .member-renewal, .interview-choice, .member-branches > details, .script-logic li,
    .natal-prose-item, .reading-slider-track > .natal-reading, .reading-slider-btn,
    .designed-bullet-item, .tech-radar-box, .tech-oracle-box, .tech-panel, .reaction-axis) {
  background-color: var(--cws-surface) !important;
}

.reading-slider-wrapper[data-slider-wrap] .natal-prose-item,
.reading-slider-wrapper .reading-slider-track > .natal-reading,
.reading-slider-wrapper .reading-slider-btn,
#app[data-ux] :is(.tech-radar-box, .tech-oracle-box, .tech-panel) {
  background: var(--cws-surface) !important;
}

.topbar, .dialog, .card, .content, .page-intro {
  border-color: color-mix(in srgb, var(--cws-gold) 38%, transparent);
}

.button, button, input, select, textarea {
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

.button, button:not(.sidebar-toggle), .sub-tab-nav, .dialog, input, select, textarea {
  border-color: color-mix(in srgb, var(--cws-gold) 48%, #c8bda8);
}

.button:hover, button:not(.sidebar-toggle):hover { border-color: var(--cws-gold); }

.dashboard-summary-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 12px;
}

.app-shell { margin-top: 12px; }

.dashboard-summary-row > :is(#service-promo#service-promo, #identity-panel#identity-panel) {
  display: flex;
  align-items: center;
  width: auto;
  min-width: 0;
  min-height: 84px;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid #b79558;
  border-left: 4px solid #65502d;
  border-radius: 14px;
  background: var(--cws-surface) !important;
}

.dashboard-summary-row .service-promo {
  padding: 14px 16px;
  gap: 14px;
}

.dashboard-summary-row .service-promo p { min-width: 0; }
.dashboard-summary-row .service-promo p > strong,
.dashboard-summary-row .service-promo p > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dashboard-summary-row .identity-heading { width: 100%; }
.dashboard-summary-row .identity-heading > div { min-width: 0; }
.dashboard-summary-row .identity-heading h2 { margin: 0 0 3px; }
.dashboard-summary-row .identity-note { display: none; }

:is(.button, .tab, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--cws-gold-light) 76%, white);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(168, 125, 42, .2);
}

@media (min-width: 768px) {
  .cyber-wabi-sabi-art { background-size: min(1500px, 108vw) auto; }
}

@media (max-width: 480px) {
  body::after { display: none; }
  .topbar, .app-shell, .service-promo { backdrop-filter: none; }
}

@media (max-width: 700px) {
  #app.content { background-color:rgba(250,248,242,.5)!important; }
  .cyber-wabi-sabi-art {
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100svh;
    opacity: .58;
    background-image: url('./assets/cyber-wabi-sabi-mobile-left.webp');
    background-position: left bottom;
    background-size: cover;
    background-repeat: no-repeat;
    transform: none;
    -webkit-mask-image: none;
    mask-image: none;
  }
  .content, .card { backdrop-filter: blur(3px); }
  .topbar.topbar { display: flex; flex-wrap: nowrap; min-height: 48px; gap: 6px !important; padding: 6px !important; align-items: center; }
  .topbar .brand { min-width: 0; width: auto; flex: 1 1 auto; gap: 4px; white-space: nowrap; }
  .topbar .brand-mark { width: 24px; height: 24px; }
  .topbar.topbar .brand strong { font-size: 12px !important; line-height: 1.5 !important; letter-spacing: 0; }
  .topbar.topbar .brand small { margin-top: 0; font-size: 9px !important; line-height: 1.5 !important; }
  .topbar .top-actions { display: flex; flex-wrap: nowrap; flex: 0 0 auto; width: auto; gap: 3px; }
  .topbar.topbar .top-actions .button { min-width: 0; min-height: 32px; padding: 0 4px !important; font-size: 10px !important; line-height: 1.5 !important; font-weight: 800; white-space: nowrap; }
  .dashboard-summary-row { gap: 8px; }
  .dashboard-summary-row > :is(#service-promo#service-promo, #identity-panel#identity-panel) { min-height: 64px; padding: 8px; }
  .dashboard-summary-row #service-promo#service-promo { flex-direction: column; align-items: stretch; justify-content: center; gap: 2px; }
  .dashboard-summary-row #service-promo#service-promo .service-promo-copy { display: block; flex: 0 0 auto; }
  .dashboard-summary-row #service-promo#service-promo p strong,
  .dashboard-summary-row #identity-panel#identity-panel .identity-heading h2 { margin: 0; font-size: 12px !important; line-height: 1.5 !important; }
  .dashboard-summary-row #service-promo#service-promo p span { display: none; }
  .dashboard-summary-row #service-promo#service-promo > button { width: auto; max-width: none; min-height: 0; padding: 0; border: 0; justify-content: flex-start; gap: 5px; font-size: 12px !important; line-height: 1.5 !important; white-space: nowrap; }
  .dashboard-summary-row #identity-panel#identity-panel .identity-birth-info { font-size: 10px !important; line-height: 1.5 !important; white-space: nowrap; }
  .dashboard-summary-row #identity-panel#identity-panel .identity-heading h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .cyber-wabi-sabi-art, html[data-cyber-wabi-sabi-state="calculating"] body::before {
    animation: none !important;
    transition: none !important;
  }
}
