:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1a1d21;
  --muted: #8b909a;
  --line: rgba(0, 0, 0, 0.08);
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --up: #d92b2b;
  --down: #12924f;
  --tag-bg: rgba(37, 99, 235, 0.12);
  --tag-text: #2563eb;
  --feed-font-size: 15px;
  --topbar-h: 40px;
  --tabbar-h: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a20;
    --text: #e8eaee;
    --muted: #8b909a;
    --line: rgba(255, 255, 255, 0.09);
    --accent: #4c8dff;
    --accent-soft: rgba(76, 141, 255, 0.14);
    --up: #ff6b6b;
    --down: #3ecf8e;
    --tag-bg: rgba(76, 141, 255, 0.18);
    --tag-text: #8ab4ff;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  overflow: hidden;
}

.hidden {
  display: none !important;
}

button,
input,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.boot {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  padding: 32px;
  text-align: center;
  line-height: 1.6;
}

.auth {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: 18px;
  padding: 28px 22px 22px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.brand {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.5px;
}

.auth-sub {
  margin: 8px 0 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 12px;
  padding: 0 14px;
  margin-bottom: 12px;
  outline: none;
  font-size: 17px;
  letter-spacing: 2px;
}

.input:focus {
  border-color: var(--accent);
}

.error {
  min-height: 18px;
  color: var(--up);
  font-size: 13px;
  margin-bottom: 8px;
}

.btn {
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 14px;
  cursor: pointer;
}

.btn:active {
  opacity: 0.7;
}

.btn:disabled {
  opacity: 0.5;
}

.btn.primary {
  width: 100%;
  height: 48px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  border-radius: 12px;
}

.auth-tip {
  margin-top: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: var(--app-height, 100dvh);
}

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  gap: 4px;
}

.icon-btn {
  height: 32px;
  min-width: 44px;
  padding: 0 8px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  border-radius: 8px;
}

.icon-btn:active {
  background: var(--accent-soft);
}

.views {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
}

.seg {
  display: flex;
  gap: 6px;
  margin: 8px 12px;
  padding: 4px;
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--line);
}

.seg-btn {
  flex: 1;
  height: 34px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}

.seg-btn.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 6px;
}

.select {
  flex: 1;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 0 10px;
  font-size: 14px;
  min-width: 0;
}

.toolbar .btn {
  height: 36px;
  flex: none;
}

.status {
  flex: none;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.feed {
  padding: 0 12px;
  font-size: var(--feed-font-size);
}

.feed-item {
  position: relative;
  background: var(--card);
  border-radius: 12px;
  margin-bottom: 8px;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
}

.feed-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 46px;
}

.feed-time {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.feed-text {
  line-height: 1.72;
  word-break: break-word;
  white-space: pre-wrap;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.copy-btn:active {
  background: var(--accent-soft);
  color: var(--accent);
}

.interpretation {
  margin-top: 2px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--accent-soft);
  line-height: 1.7;
  font-size: calc(var(--feed-font-size) + 1px);
  word-break: break-word;
}

.tag {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  vertical-align: 1px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.chip {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.chip .up {
  color: var(--up);
}

.chip .down {
  color: var(--down);
}

.stock {
  color: var(--accent);
  font-weight: 600;
}

.cls-red .feed-text {
  color: var(--up);
}

.cls-strong .feed-text {
  font-weight: 700;
}

.feed-empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.more-wrap {
  padding: 4px 12px 16px;
}

.more-wrap .btn {
  width: 100%;
}

.tabbar {
  flex: none;
  display: flex;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.tab::before {
  content: '';
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid currentColor;
  opacity: 0.75;
}

.tab.active {
  color: var(--accent);
  font-weight: 600;
}

.tab.active::before {
  background: var(--accent-soft);
  border-color: var(--accent);
  opacity: 1;
}

.soon {
  margin: 16px 12px;
  padding: 22px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.soon-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 10px;
}

.soon-text {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.soon-list {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 2;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  max-width: 80vw;
  padding: 9px 16px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.copy-area {
  position: fixed;
  left: -9999px;
  top: 0;
  opacity: 0;
}

.card {
  margin: 12px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

.file-input {
  display: none;
}

.file-pick {
  display: block;
  height: 46px;
  line-height: 46px;
  text-align: center;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.file-pick:active {
  opacity: 0.75;
}

.file-pick.compact {
  height: 38px;
  line-height: 38px;
  margin-top: 8px;
  font-size: 14px;
  font-weight: 500;
  background: var(--bg);
  color: var(--accent);
  border: 1px dashed var(--accent);
}

.doc-hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}

.doc-divider {
  margin: 18px 0 10px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.doc-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.doc-url-row .input {
  flex: 1;
  width: auto;
  min-width: 0;
  margin-bottom: 0;
}

.btn.small {
  height: 44px;
  width: auto;
  padding: 0 14px;
  flex: none;
}

.btn.block {
  width: 100%;
  height: 48px;
  margin-top: 14px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
}

.input.flat {
  margin-bottom: 0;
  height: 42px;
  font-size: 15px;
  letter-spacing: 0;
}

.select.flat {
  flex: 1;
  width: auto;
  min-width: 0;
  height: 42px;
}

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

.field-label {
  flex: none;
  width: 76px;
  color: var(--muted);
  font-size: 13px;
}

.doc-status {
  min-height: 18px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.doc-status.error {
  color: #e5484d;
}

.doc-status.warn {
  color: #c77d00;
}

.doc-status.ok {
  color: var(--down);
}

.doc-text {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  max-height: 168px;
  overflow: hidden;
}

.doc-images {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.doc-thumb {
  position: relative;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  aspect-ratio: 1 / 1;
}

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

.doc-thumb.missing {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.thumb-idx {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 0 5px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
}

.switch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 6px 0;
}

.switch {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.img-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
  padding: 24px;
}

.img-overlay img {
  max-width: 100%;
  max-height: 88vh;
  object-fit: contain;
}

.overlay-close {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: 16px;
  height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 14px;
}

.ad-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.ad-toolbar .select {
  flex: 1;
}

.ad-toolbar .btn {
  flex: none;
}

.ad-grid {
  padding: 0 12px;
}

.ad-item {
  display: flex;
  gap: 10px;
  padding: 10px;
  margin-bottom: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.ad-item-img {
  width: 84px;
  height: 84px;
  flex: none;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg);
}

.ad-item-body {
  flex: 1;
  min-width: 0;
}

.ad-item-title {
  font-size: 14px;
  font-weight: 600;
  word-break: break-all;
}

.ad-item-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.ad-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.btn.tiny {
  width: auto;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--card);
  font-size: 12px;
}

.btn.tiny.danger {
  color: #e5484d;
  border-color: rgba(229, 72, 77, 0.4);
}

.ad-adcard {
  margin: 0 12px 10px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.ad-adhead {
  margin-bottom: 6px;
}

.ad-adname {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ad-adname-text {
  font-size: 15px;
  font-weight: 600;
  word-break: break-all;
}

.ad-badge {
  flex: none;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 11px;
}

.ad-badge.run {
  background: rgba(18, 146, 79, 0.15);
  color: var(--down);
}

.ad-badge.expired {
  background: rgba(37, 99, 235, 0.15);
  color: var(--accent);
}

.ad-badge.closed {
  background: rgba(229, 72, 77, 0.15);
  color: #e5484d;
}

.ad-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px dashed var(--line);
}

.ad-row-img {
  width: 64px;
  height: 64px;
  flex: none;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg);
}

.ad-row-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ad-row-line {
  color: var(--muted);
  font-size: 12px;
}

.ad-row-ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ad-row-label {
  margin-right: 4px;
}

.ad-order-input {
  width: 56px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  text-align: center;
  font-size: 13px;
}

.ad-row .btn.tiny {
  flex: none;
  align-self: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
}

.modal-card {
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  background: var(--card);
  border-radius: 16px 16px 0 0;
}

.modal-title {
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.modal-actions .btn {
  flex: 1;
  width: auto;
  height: 44px;
}

.modal .input {
  margin-bottom: 0;
}

.ad-search-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.ad-search-actions .btn {
  flex: 1;
}

.ad-badge.product {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--line);
}

.ad-item-url {
  margin-top: 4px;
  color: var(--accent);
  font-size: 11px;
  line-height: 1.4;
  word-break: break-all;
}

.ade-cache-row {
  margin: 10px 0 0;
}

.adc-control {
  flex: 1;
  min-width: 0;
}

.adc-slot {
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

.adc-slot-head {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.adc-slot-img {
  display: block;
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--card);
  margin-bottom: 8px;
}

.adc-slot-img.empty {
  visibility: hidden;
}

.adc-url {
  height: 34px;
  font-size: 12px;
}

.adc-slot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.adc-rows {
  margin: 10px 0;
}

.adc-row {
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.adc-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.adc-pre {
  margin: 0;
  max-height: 360px;
  overflow: auto;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}

.adc-pick {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--card);
  text-align: left;
}

.adc-pick img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.adc-pick-cap {
  display: block;
  padding: 4px 6px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.adc-art-item {
  padding: 10px 0;
  border-top: 1px dashed var(--line);
}

.adc-art-title {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-all;
}

.adc-art-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}
