:root {
  --brand-primary: #2563eb;
  --brand-primary-dark: #1d4ed8;
  --brand-primary-soft: #eaf1ff;
  --brand-accent: #0891b2;
  --brand-accent-soft: #e6f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --surface-muted: #f3f7fc;
  --text-strong: #172033;
  --text-muted: #64748b;
  --border-subtle: #dbe5ef;
  --border-soft: #edf2f8;
  --success: #0f9f78;
  --success-soft: #e7f8f2;
  --warning: #b7791f;
  --warning-soft: #fff7db;
  --danger: #d64545;
  --danger-soft: #fff0f0;
  --radius-control: 8px;
  --radius-panel: 10px;
  --space-control-x: 16px;
  --space-panel: 24px;
  --space-card: 20px;
  --font-ui: "Inter", "HarmonyOS Sans SC", "MiSans", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --shadow-panel: 0 14px 34px rgba(24, 32, 51, 0.08);
  --shadow-float: 0 18px 45px rgba(15, 23, 42, 0.12);
  --primary: var(--brand-primary);
  --primary-dark: var(--brand-primary-dark);
  --primary-soft: var(--brand-primary-soft);
}

html {
  color-scheme: light;
}

body {
  background:
    radial-gradient(circle at 10% -8%, rgba(37, 99, 235, 0.10), transparent 30rem),
    linear-gradient(180deg, #fbfdff 0%, #f4f7fb 100%) !important;
  color: var(--text-strong);
  font-family: var(--font-ui) !important;
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: 0;
}

button,
a,
input,
select,
textarea {
  font-family: var(--font-ui) !important;
  outline-color: var(--brand-primary);
}

h1,
h2,
h3,
.brand-name,
.page-title,
.card-title {
  letter-spacing: 0;
  line-height: 1.25;
}

h1 {
  font-size: clamp(24px, 2.4vw, 34px);
  font-weight: 900;
}

h2 {
  font-size: clamp(20px, 1.8vw, 26px);
  font-weight: 900;
}

h3 {
  font-size: 17px;
  font-weight: 850;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25) !important;
  outline-offset: 2px;
}

.platform-logo {
  width: 52px !important;
  height: 52px !important;
  flex: 0 0 52px !important;
  object-fit: contain !important;
  border-radius: 10px !important;
  background: transparent !important;
  box-shadow: none !important;
}

.rail .platform-logo {
  width: 46px !important;
  height: 46px !important;
  flex-basis: 46px !important;
}

.logo:not(.platform-logo),
.mark,
.brand-mark {
  border-radius: 10px !important;
  background: linear-gradient(145deg, var(--brand-primary), var(--brand-accent)) !important;
  color: #fff !important;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.20) !important;
}

.brand,
.topbar,
.sidebar,
.side-panel,
.assist,
.panel,
.card,
.table-panel,
.main,
.drawer,
.dialog,
.modal,
.user-popover-card,
.chapter-card,
.question-card,
.metric-card,
.stat-card,
.book-card,
.assignment-card {
  border-color: var(--border-subtle) !important;
}

.topbar,
.rail,
.sidebar,
.side-panel,
.assist {
  background: rgba(255, 255, 255, 0.94) !important;
  backdrop-filter: blur(18px);
}

.panel,
.card,
.table-panel,
.drawer,
.dialog,
.modal-card,
.user-popover-card,
.chapter-card,
.question-card,
.metric-card,
.stat-card,
.book-card,
.assignment-card {
  background: var(--surface) !important;
  border-radius: var(--radius-panel) !important;
  box-shadow: var(--shadow-panel);
}

.panel,
.table-panel,
.drawer,
.dialog,
.modal-card,
.user-popover-card {
  padding: max(var(--space-panel), 20px) !important;
}

.card,
.chapter-card,
.question-card,
.metric-card,
.stat-card,
.book-card,
.assignment-card {
  padding: var(--space-card) !important;
}

.book-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 315px;
}

.book-card .cover {
  min-height: 165px;
  margin: calc(var(--space-card) * -1) calc(var(--space-card) * -1) 0 !important;
  padding: 18px !important;
  border-bottom: 1px solid var(--border-soft);
}

.book-card > div:not(.cover),
.book-card .book-body,
.book-card .info,
.book-card .meta,
.book-card .actions {
  padding-left: 0;
  padding-right: 0;
}

.book-card h3,
.book-card .book-title,
.question-card h3,
.assignment-card h3 {
  margin-top: 0;
  font-size: 17px !important;
  line-height: 1.35 !important;
  font-weight: 750 !important;
}

.book-card p,
.book-card .meta,
.question-card p,
.assignment-card p {
  line-height: 1.5;
}

.primary,
.btn-primary,
.tool.primary,
.btn.primary,
.tool-chip.primary-tool {
  border-color: var(--brand-primary) !important;
  background: var(--brand-primary) !important;
  color: #fff !important;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.16);
}

.primary,
.secondary,
.btn-primary,
.btn-secondary,
.icon-btn,
.tool,
.tab,
.chip,
.date-chip,
.top-tab,
.subject-tab,
.store-action {
  min-height: 42px !important;
  padding-left: var(--space-control-x) !important;
  padding-right: var(--space-control-x) !important;
  font-size: 15px !important;
  font-weight: 850 !important;
  line-height: 1.2;
}

.icon-btn {
  min-width: 42px !important;
}

.subject-tab,
.tab,
.chip,
.date-chip {
  gap: 8px;
}

.primary:hover,
.btn-primary:hover,
.tool.primary:hover,
.btn.primary:hover,
.tool-chip.primary-tool:hover {
  background: var(--brand-primary-dark) !important;
  border-color: var(--brand-primary-dark) !important;
}

.secondary,
.btn-secondary,
.icon-btn,
.tool,
.tab,
.chip,
.date-chip,
.top-tab,
.nav button,
.rail-tab,
.rail-more-trigger {
  border-radius: var(--radius-control) !important;
}

.secondary,
.btn-secondary,
.icon-btn,
.tool,
.chip,
.date-chip {
  border-color: var(--border-subtle) !important;
  background: #fff !important;
  color: #40536b !important;
}

.secondary:hover,
.btn-secondary:hover,
.icon-btn:hover,
.tool:hover,
.chip:hover,
.date-chip:hover {
  border-color: #b7cffb !important;
  background: var(--brand-primary-soft) !important;
  color: var(--brand-primary-dark) !important;
}

.tab.active,
.chip.active,
.date-chip.active,
.top-tab.active,
.rail-tab.active,
.secondary.active,
.primary.active,
.icon-btn.active,
.tool.active,
.btn.active,
.nav .active,
.nav button.active {
  background: var(--brand-primary-soft) !important;
  color: var(--brand-primary-dark) !important;
  border-color: #b7cffb !important;
}

input,
select,
textarea {
  border-color: var(--border-subtle) !important;
  border-radius: var(--radius-control) !important;
  background-color: #fff;
  min-height: 42px;
  padding-left: 14px;
  padding-right: 14px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-primary) !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12) !important;
}

table {
  border-color: var(--border-soft) !important;
}

thead,
th {
  background: var(--surface-soft) !important;
  color: #46566d !important;
}

td,
th {
  border-color: var(--border-soft) !important;
  padding: 14px 16px !important;
}

.badge,
.status,
.tag {
  border-radius: 999px !important;
  font-weight: 800;
}

.assignment-table .status,
.table-panel .status {
  min-height: auto !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.assignment-table .status.done,
.table-panel .status.done {
  color: #08745a !important;
}

.assignment-table .status.progress,
.table-panel .status.progress {
  color: #f59e0b !important;
}

.assignment-table .status.review,
.table-panel .status.review {
  color: #4b5563 !important;
}

.assignment-table .status.late,
.table-panel .status.late {
  color: var(--danger) !important;
}

.danger,
.error,
.wrong {
  color: var(--danger) !important;
}

.success,
.correct {
  color: var(--success) !important;
}

.progress,
.progress-fill,
.score-fill,
.progress-track span,
.bar span,
.score-bar span,
.score-progress span,
.progress-panel .bar span,
.result-panel .bar span,
.score-card .bar span,
.score-card .progress span {
  background: linear-gradient(90deg, var(--brand-primary), #7c3aed) !important;
}

#progressBar,
[data-progress-bar],
[data-ai-progress-bar],
.upload-progress-fill {
  background: linear-gradient(90deg, #2563eb 0%, #7c3aed 100%) !important;
}

.metric-icon,
.result-icon,
.ds-icon-badge {
  display: inline-grid !important;
  place-items: center !important;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand-primary-soft) !important;
  color: var(--brand-primary-dark) !important;
}

.ds-icon {
  display: inline-flex;
  width: 1.15em;
  height: 1.15em;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  color: currentColor;
  line-height: 1;
  vertical-align: -0.16em;
}

.ds-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.35;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.35));
}

.ds-icon-decorated {
  width: 24px !important;
  height: 24px !important;
  margin-left: -4px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(234, 241, 255, 0.72)),
    var(--brand-primary-soft);
  color: var(--brand-primary-dark);
  box-shadow:
    inset 0 0 0 1px rgba(37, 99, 235, 0.12),
    0 5px 12px rgba(37, 99, 235, 0.10);
}

.primary .ds-icon-decorated,
.btn-primary .ds-icon-decorated,
.tool.primary .ds-icon-decorated,
.store-action.open .ds-icon-decorated {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.26),
    0 5px 12px rgba(10, 37, 96, 0.12);
}

.store-action.bind .ds-icon-decorated,
.store-action.buy .ds-icon-decorated {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(234, 241, 255, 0.78)),
    var(--brand-primary-soft);
  color: var(--brand-primary-dark);
  box-shadow:
    inset 0 0 0 1px rgba(37, 99, 235, 0.16),
    0 5px 12px rgba(37, 99, 235, 0.12);
}

button .ds-icon,
a .ds-icon {
  margin-right: 6px;
}

.icon-btn .ds-icon,
.ai-icon-btn .ds-icon {
  margin-right: 0;
}

.icon-btn.ds-has-label .ds-icon {
  margin-right: 6px;
}

.top-tab .ds-icon,
.primary .ds-icon,
.secondary .ds-icon,
.btn-primary .ds-icon,
.btn-secondary .ds-icon {
  width: 18px;
  height: 18px;
}

.store-action .ds-icon {
  display: none !important;
}

.top-tab {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  gap: 6px !important;
}

.top-tab.active,
.top-tab:hover {
  background: transparent !important;
  border-color: transparent !important;
  color: var(--brand-primary) !important;
  box-shadow: none !important;
}

.top-tab .ds-icon,
.top-tab .ds-icon-decorated {
  width: 18px !important;
  height: 18px !important;
  margin-right: 0 !important;
  margin-left: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.top-tab .ds-icon svg {
  filter: none !important;
}

.metric-icon .ds-icon,
.result-icon .ds-icon,
.ds-icon-badge .ds-icon {
  width: 20px;
  height: 20px;
}

.metric-icon,
.result-icon,
.ds-icon-badge {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 8px 18px rgba(37, 99, 235, 0.12);
}

.rail-tab svg,
.rail-more-trigger svg,
.top-tab svg,
.ai-icon-btn svg,
.media-action-btn svg {
  stroke-width: 2.25;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.45));
}

.top-tab .ds-icon,
.rail-tab svg,
.rail-more-trigger svg {
  color: currentColor;
}

.cover-tag,
.badge,
.tag,
.status {
  padding: 6px 12px !important;
  border: 1px solid rgba(37, 99, 235, 0.18);
  background: rgba(234, 241, 255, 0.92) !important;
  color: var(--brand-primary-dark) !important;
}

#storeGrid.book-grid,
#ownedGrid.book-grid {
  gap: 26px !important;
  align-items: stretch;
}

#storeGrid .book-card,
#ownedGrid .book-card {
  --book-cover-height: 176px;
  padding: 0 !important;
  overflow: hidden;
  align-self: stretch;
  border: 1px solid rgba(191, 205, 224, 0.82) !important;
  border-radius: 12px !important;
  background: rgba(255, 255, 255, 0.96) !important;
  box-shadow: 0 12px 28px rgba(28, 48, 76, 0.08) !important;
  transform-origin: center center;
}

#storeGrid .book-card .cover,
#ownedGrid .book-card .cover {
  margin: 0 !important;
  height: var(--book-cover-height) !important;
  min-height: var(--book-cover-height) !important;
  max-height: var(--book-cover-height) !important;
  flex: 0 0 var(--book-cover-height) !important;
  padding: 14px !important;
  isolation: isolate;
  background:
    radial-gradient(circle at 78% 20%, rgba(118, 88, 255, 0.15), transparent 9rem),
    radial-gradient(circle at 20% 82%, rgba(16, 185, 214, 0.13), transparent 10rem),
    linear-gradient(135deg, #edf6ff 0%, #eaf0ff 48%, #f5edff 100%) !important;
}

#storeGrid .book-card .cover::before,
#ownedGrid .book-card .cover::before {
  content: "";
  position: absolute;
  top: 30px;
  right: 56px;
  z-index: -1;
  width: 84px;
  height: 104px;
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 12px 18px 18px 12px;
  background:
    linear-gradient(90deg, rgba(90, 95, 255, 0.16) 0 9px, rgba(255, 255, 255, 0.55) 9px 12px, transparent 12px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 255, 0.68));
  box-shadow:
    inset 10px 0 16px rgba(37, 99, 235, 0.07),
    0 18px 30px rgba(57, 78, 128, 0.15);
  opacity: 0.96;
}

#storeGrid .book-card .cover::after,
#ownedGrid .book-card .cover::after {
  content: "";
  position: absolute;
  right: 74px;
  top: 70px;
  z-index: -1;
  width: 42px;
  height: 32px;
  border-top: 2px solid rgba(37, 99, 235, 0.14);
  border-bottom: 2px solid rgba(37, 99, 235, 0.10);
  box-shadow: 0 14px 26px rgba(37, 99, 235, 0.10);
  opacity: 0.8;
}

#storeGrid .book-card > div:not(.cover),
#ownedGrid .book-card > div:not(.cover) {
  padding: 18px 22px 20px !important;
}

#storeGrid .book-card {
  height: 370px;
}

#ownedGrid .book-card {
  height: 350px;
}

#storeGrid .book-card .book-body,
#ownedGrid .book-card .book-body {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: column !important;
  min-height: 0;
}

#storeGrid .book-card h3,
#ownedGrid .book-card h3 {
  margin-bottom: 8px !important;
  color: #071936 !important;
  font-size: 18px !important;
  font-weight: 800 !important;
  line-height: 1.34 !important;
  letter-spacing: 0 !important;
}

#storeGrid .book-card .book-title {
  display: -webkit-box;
  min-height: auto;
  max-height: calc(2 * 1.42em);
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: anywhere;
}

#ownedGrid .book-card .book-title {
  display: -webkit-box;
  min-height: calc(2 * 1.34em);
  max-height: calc(2 * 1.34em);
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: anywhere;
}

#storeGrid .book-card p,
#ownedGrid .book-card p {
  margin-top: 6px !important;
}

#storeGrid .book-card .book-body,
#ownedGrid .book-card .book-body {
  gap: 8px !important;
}

#storeGrid .book-card .meta,
#ownedGrid .book-card .meta {
  line-height: 1.25 !important;
}

#storeGrid .book-card .price-action-row,
#ownedGrid .book-card .price-action-row {
  margin-top: 4px !important;
  padding-top: 4px;
  min-height: 38px;
  flex: 0 0 auto;
}

#storeGrid .book-card .store-action {
  min-width: 96px;
  min-height: 34px !important;
  font-weight: 500 !important;
}

#storeGrid .book-card .price,
#ownedGrid .book-card .price {
  min-width: 72px;
  font-weight: 500 !important;
}

#storeGrid .book-card .cover img,
#ownedGrid .book-card .cover img {
  width: min(128px, 72%) !important;
  height: calc(var(--book-cover-height) - 52px) !important;
  max-height: calc(var(--book-cover-height) - 52px) !important;
  object-fit: cover !important;
  border-radius: 8px !important;
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.22) !important;
}

#storeGrid .book-card .cover-tag,
#ownedGrid .book-card .cover-tag {
  top: 14px !important;
  left: 16px !important;
  max-width: calc(100% - 32px);
  overflow: hidden;
  border-color: rgba(69, 105, 235, 0.20) !important;
  background: rgba(238, 245, 255, 0.82) !important;
  color: #1554d1 !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#ownedGrid .book-card .progress-row {
  gap: 14px !important;
  margin-top: auto !important;
  padding-top: 14px;
}

#ownedGrid .book-card .progress-track {
  height: 10px !important;
  background: #e7eef8 !important;
}

#ownedGrid .book-card .progress-track span {
  background: linear-gradient(90deg, #3158f6 0%, #6f48f6 78%, #8b5cf6 100%) !important;
}

#ownedGrid .book-card .percent {
  min-width: 42px;
  color: #06142d;
  font-size: 16px;
  text-align: right;
}

.toolbar,
.filters,
.actions,
.top-actions,
.page-actions,
.button-row,
.tabs,
.subject-tabs {
  gap: 12px !important;
}

.content,
.main,
.page,
.shell > .body {
  gap: 24px;
}

@media (max-width: 768px) {
  .topbar {
    gap: 10px !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  .platform-logo {
    width: 44px !important;
    height: 44px !important;
    flex-basis: 44px !important;
  }

  .primary,
  .secondary,
  .btn-primary,
  .btn-secondary {
    min-height: 40px;
  }
}
