/* ==========================================================================
   CPU-L Web 版样式
   色彩取自原版 res/values/colors.xml：
     colorPrimary #009688 / colorPrimaryDark #00796b / colorPrimaryLight #b2dfdb
     colorAccent #536dfe / red400 #ef5350 / bgNavigationBar #cecece
   布局结构复刻 activity_main.xml
   ========================================================================== */

:root {
  --color-primary: #009688;
  --color-primary-dark: #00796b;
  --color-primary-light: #b2dfdb;
  --color-accent: #536dfe;
  --color-red: #ef5350;
  --nav-bar-bg: #cecece;

  --surface: #ffffff;
  --surface-alt: #f5f5f5;
  --surface-muted: #eeeeee;
  --text: #212121;
  --text-muted: #757575;
  --text-faint: #9e9e9e;
  --border: rgba(0, 0, 0, 0.12);
  --divider: rgba(0, 0, 0, 0.08);

  --radius: 4px;
  --radius-card: 8px;
  --radius-full: 999px;
  --sp: 4px;

  --font-sans: "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --toolbar-h: 56px;
  --tab-h: 44px;
  --nav-h: 40px;
  --ad-h: 44px;
  --max-w: 900px;

  color-scheme: light;
}

[data-theme="dark"] {
  --surface: #121212;
  --surface-alt: #1e1e1e;
  --surface-muted: #2a2a2a;
  --text: #e8e8e8;
  --text-muted: #a0a0a0;
  --text-faint: #7c7c7c;
  --border: rgba(255, 255, 255, 0.14);
  --divider: rgba(255, 255, 255, 0.08);
  --nav-bar-bg: #2f2f2f;
  --color-primary-light: #004d40;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* hidden 属性必须始终生效：本文件多处用 display:flex/grid 覆盖了默认的 display:none，
   导致 [hidden] 元素（搜索栏、抽屉遮罩、弹窗遮罩、Toast）实际仍然可见并挡住点击。
   该规则必须放在所有组件样式之前，并加 !important 保证优先级最高。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--surface-alt);
  color: var(--text);
  font: 400 15px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* ---------------------------------------------------------------- 布局骨架 */
.drawer-layout {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

.drawer-content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
}

.drawer-layout.is-open .drawer-content { transform: translateX(280px); }

/* ---------------------------------------------------------------- Toolbar */
.toolbar {
  position: relative;
  flex: 0 0 auto;
  height: var(--toolbar-h);
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  gap: calc(var(--sp) * 2);
  padding: 0 calc(var(--sp) * 2);
  z-index: 40;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}

.tb-title {
  flex: 1 1 auto;
  font-size: 19px;
  font-weight: 500;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-actions { display: flex; align-items: center; gap: calc(var(--sp) * 1); }

.tb-btn {
  background: transparent;
  border: 0;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background .12s ease;
}
.tb-btn:hover { background: rgba(255,255,255,.16); }
.tb-btn:active { background: rgba(255,255,255,.28); }

.tb-btn-badge .badge {
  position: absolute;
  top: 3px; right: 2px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--color-red);
  color: #fff;
  font: 600 11px/17px var(--font-mono);
  text-align: center;
}

/* SearchView */
.search-bar {
  position: absolute;
  inset: 0;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  gap: var(--sp);
  padding: 0 calc(var(--sp) * 2);
  z-index: 5;
}
.search-bar input {
  flex: 1 1 auto;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,.6);
  color: #fff;
  font-size: 16px;
  padding: 6px 2px;
  outline: none;
}
.search-bar input::placeholder { color: rgba(255,255,255,.7); }

/* ---------------------------------------------------------------- 主区域 */
.main-area {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--surface);
}

/* TabLayout：仅 section 1 / 8 可见 */
.tab-layout {
  flex: 0 0 auto;
  height: var(--tab-h);
  display: none;
  background: var(--color-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,.14);
  z-index: 30;
}
.tab-layout.is-visible { display: flex; }

.tab {
  flex: 1 1 0;
  background: transparent;
  border: 0;
  color: rgba(255,255,255,.78);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .4px;
  position: relative;
}
.tab.is-active { color: #fff; }
.tab.is-active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: #fff;
}

/* 面包屑导航条 */
.nav-bar {
  flex: 0 0 auto;
  height: var(--nav-h);
  background: var(--nav-bar-bg);
  color: var(--text);
  font-size: 13px;
  display: flex;
  align-items: center;
  padding: 0 calc(var(--sp) * 4);
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-bar::-webkit-scrollbar { display: none; }
[data-theme="dark"] .nav-bar { color: #e8e8e8; }

/* fragment_container */
.fragment-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  outline: none;
  -webkit-overflow-scrolling: touch;
  contain: layout paint;
}

/* 广告位（原版贴底，Web 版保留占位说明） */
.ad-slot {
  flex: 0 0 auto;
  height: var(--ad-h);
  background: var(--surface-muted);
  border-top: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-note { font-size: 11px; color: var(--text-faint); }

/* ---------------------------------------------------------------- 列表通用 */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list-item {
  display: flex;
  align-items: center;
  gap: calc(var(--sp) * 2);
  padding: 0 calc(var(--sp) * 4);
  min-height: 48px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
  transition: background .1s ease;
}
.list-item:hover { background: var(--surface-alt); }

.list-item .li-text {
  flex: 1 1 auto;
  min-width: 0;
  padding: calc(var(--sp) * 3) 0;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-item .li-main { cursor: pointer; }
.list-item .li-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.li-actions { display: flex; align-items: center; gap: var(--sp); flex: 0 0 auto; }

.icon-btn {
  background: transparent;
  border: 0;
  width: 38px; height: 38px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background .12s ease, color .12s ease;
}
.icon-btn:hover { background: var(--surface-muted); }
.icon-btn.is-on { color: var(--color-primary); }
.icon-btn.is-danger:hover { color: var(--color-red); }

/* 空态 / 加载 */
.state {
  padding: calc(var(--sp) * 12) calc(var(--sp) * 4);
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.state-error { color: var(--color-red); }

.spinner {
  width: 26px; height: 26px;
  margin: 0 auto calc(var(--sp) * 3);
  border: 3px solid var(--divider);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- 详情页 */
.detail-head {
  background: var(--surface);
  padding: calc(var(--sp) * 4);
  border-bottom: 1px solid var(--divider);
  display: flex;
  gap: calc(var(--sp) * 4);
  align-items: flex-start;
}
.detail-thumb {
  flex: 0 0 auto;
  width: 96px; height: 96px;
  border-radius: var(--radius-card);
  background: var(--surface-muted);
  border: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.detail-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: calc(var(--sp) * 2);
}
.detail-meta { flex: 1 1 auto; min-width: 0; }
.detail-name {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 calc(var(--sp) * 2);
  word-break: break-word;
}
.detail-chips { display: flex; flex-wrap: wrap; gap: var(--sp); margin-bottom: calc(var(--sp) * 2); }
.chip {
  font: 500 11px/18px var(--font-mono);
  padding: 1px 8px;
  border-radius: var(--radius-full);
  background: var(--surface-muted);
  color: var(--text-muted);
  white-space: nowrap;
}
.chip-primary { background: var(--color-primary-light); color: var(--color-primary-dark); }

/* 进度条组 */
.spec-bars { margin-top: calc(var(--sp) * 3); display: grid; gap: calc(var(--sp) * 2); }
.spec-bar-row { display: grid; grid-template-columns: 84px 1fr 56px; align-items: center; gap: var(--sp); }
.spec-bar-label { font-size: 12px; color: var(--text-muted); }
/* track 与 fill 都是 span，必须显式 block 化，否则 width/height 不生效（填充条不可见） */
.spec-bar-track {
  display: block;
  height: 8px;
  background: var(--surface-muted);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.spec-bar-fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width .3s ease;
}
.spec-bar-val {
  display: block;
  font: 500 12px/1 var(--font-mono);
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* 未发布横幅 */
.unreleased {
  background: var(--color-red);
  color: #fff;
  padding: calc(var(--sp) * 2) calc(var(--sp) * 4);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: var(--sp);
}

/* 分组标题 */
.info-group {
  background: var(--color-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .3px;
  padding: calc(var(--sp) * 2) calc(var(--sp) * 4);
  position: sticky;
  top: 0;
  z-index: 2;
}

/* 规格行：键值两列 */
.info-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(var(--sp) * 3);
  padding: calc(var(--sp) * 3) calc(var(--sp) * 4);
  border-bottom: 1px solid var(--divider);
  font-size: 14px;
  background: var(--surface);
}
.info-row .k { color: var(--text-muted); }
.info-row .v {
  color: var(--text);
  text-align: right;
  word-break: break-word;
  white-space: pre-line;      /* 支持 m343w 等格式化结果中的换行 */
  font-variant-numeric: tabular-nums;
}
.info-row .v:empty::after { content: "—"; color: var(--text-faint); }

/* 备注行（上下两行） */
.info-notes {
  padding: calc(var(--sp) * 4);
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
  font-size: 14px;
}
.info-notes .k { color: var(--text-muted); font-size: 12px; margin-bottom: 2px; }
.info-notes .v { white-space: pre-wrap; }

/* 变体切换 */
.variant-bar {
  padding: calc(var(--sp) * 3) calc(var(--sp) * 4);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  gap: calc(var(--sp) * 2);
  position: sticky;
  top: 0;
  z-index: 3;
}
.variant-bar label { font-size: 12px; color: var(--text-muted); flex: 0 0 auto; }
.variant-bar select {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

/* ---------------------------------------------------------------- 高级搜索 */
.form { padding: calc(var(--sp) * 2) 0 calc(var(--sp) * 8); }
.form-row {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: calc(var(--sp) * 3);
  align-items: center;
  padding: calc(var(--sp) * 3) calc(var(--sp) * 4);
  border-bottom: 1px solid var(--divider);
}
.form-row > label { font-size: 13px; color: var(--text-muted); }
.form-row input[type="text"],
.form-row input[type="number"],
.form-row select {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.form-row input:focus, .form-row select:focus { border-color: var(--color-primary); }

.op-row { display: flex; gap: var(--sp); }
.op-row select { flex: 0 0 74px; }
.op-row input { flex: 1 1 auto; min-width: 0; }

.radio-group { display: flex; flex-wrap: wrap; gap: calc(var(--sp) * 3); }
.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--text);
}
.radio-group input { accent-color: var(--color-primary); }

.form-submit {
  margin: calc(var(--sp) * 5) calc(var(--sp) * 4) 0;
  width: calc(100% - var(--sp) * 8);
  padding: 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--color-primary);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.form-submit:hover { background: var(--color-primary-dark); }

/* ---------------------------------------------------------------- 对比清单 */
.compare-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: calc(var(--sp) * 2);
  padding: calc(var(--sp) * 3) calc(var(--sp) * 4);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 10;
}
.compare-bar button {
  flex: 1 1 0;
  padding: 11px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--color-primary);
  background: transparent;
  color: var(--color-primary);
}
.compare-bar button.primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* 简单对比表 */
.cmp-wrap { overflow-x: auto; padding: calc(var(--sp) * 4); }
.cmp-table { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 100%; }
.cmp-table th, .cmp-table td {
  border: 1px solid var(--divider);
  padding: calc(var(--sp) * 2) calc(var(--sp) * 3);
  text-align: left;
  vertical-align: top;
}
.cmp-table th { background: var(--surface-muted); font-weight: 600; position: sticky; top: 0; }
.cmp-table td.k { color: var(--text-muted); white-space: nowrap; }

/* ---------------------------------------------------------------- 抽屉 */
.drawer-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 50;
  border: 0;
  padding: 0;
}

.navigation-view {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 280px;
  max-width: 84vw;
  background: var(--surface);
  z-index: 60;
  transform: translateX(-100%);
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: 2px 0 12px rgba(0,0,0,.2);
}
.drawer-layout.is-open .navigation-view { transform: translateX(0); }

.nav-header {
  height: 150px;
  flex: 0 0 auto;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff;
  padding: calc(var(--sp) * 6);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.nav-header-title { font-size: 20px; font-weight: 600; }
.nav-header-sub { font-size: 12px; opacity: .85; margin-top: 2px; }

.nav-menu { list-style: none; margin: 0; padding: calc(var(--sp) * 2) 0; }
.nav-menu li { margin: 0; }
.nav-menu button {
  width: 100%;
  background: transparent;
  border: 0;
  text-align: left;
  padding: 13px calc(var(--sp) * 4);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: calc(var(--sp) * 4);
  color: var(--text);
}
.nav-menu button:hover { background: var(--surface-muted); }
.nav-menu button.is-checked { background: var(--color-primary-light); color: var(--color-primary-dark); font-weight: 600; }
.nav-menu .nav-ico { width: 20px; flex: 0 0 auto; opacity: .8; }
.nav-menu .nav-sep { height: 1px; background: var(--divider); margin: calc(var(--sp) * 2) 0; }
.nav-menu .nav-ext { font-size: 12px; color: var(--text-muted); }

/* ---------------------------------------------------------------- 弹窗 / Toast */
.dialog-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--sp) * 5);
}
.dialog {
  background: var(--surface);
  border-radius: var(--radius-card);
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
  overflow: hidden;
}
.dialog-title { padding: calc(var(--sp) * 5) calc(var(--sp) * 5) calc(var(--sp) * 2); font-size: 17px; font-weight: 600; }
.dialog-body { padding: 0 calc(var(--sp) * 5) calc(var(--sp) * 4); font-size: 14px; color: var(--text-muted); max-height: 50vh; overflow-y: auto; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp);
  padding: calc(var(--sp) * 2) calc(var(--sp) * 3) calc(var(--sp) * 3);
}
.dialog-actions button {
  background: transparent;
  border: 0;
  padding: 9px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-primary);
}
.dialog-actions button:hover { background: var(--surface-muted); }
.dialog-actions button.danger { color: var(--color-red); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 72px;
  transform: translateX(-50%);
  background: rgba(50,50,50,.94);
  color: #fff;
  font-size: 13.5px;
  padding: 11px 18px;
  border-radius: var(--radius-full);
  z-index: 300;
  max-width: 88vw;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  animation: toast-in .18s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------------------------------------------------------------- 响应式 */
@media (min-width: 900px) {
  .drawer-layout { justify-content: center; }
  .drawer-content, .navigation-view { max-width: none; }
  .navigation-view { position: fixed; }
  .drawer-layout.is-open .drawer-content { transform: none; }
  .fragment-container > * { max-width: var(--max-w); margin-left: auto; margin-right: auto; }
  .nav-bar, .tab-layout, .toolbar, .ad-slot { padding-left: max(0px, calc(50vw - var(--max-w) / 2)); padding-right: max(0px, calc(50vw - var(--max-w) / 2)); }
  .drawer-layout.is-open .toolbar,
  .drawer-layout.is-open .tab-layout,
  .drawer-layout.is-open .nav-bar,
  .drawer-layout.is-open .ad-slot { padding-left: 0; padding-right: 0; }
  .drawer-layout.is-open .fragment-container > * { max-width: none; }
}

@media (min-width: 900px) {
  /* 桌面端：抽屉常驻，内容区让出 280px */
  .drawer-layout { padding-left: 0; }
}

@media (max-width: 899px) {
  .info-row { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .toolbar, .tab-layout, .ad-slot, .navigation-view, .drawer-scrim { display: none !important; }
  .fragment-container { overflow: visible; }
  body { overflow: visible; }
}
