:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #0f1722;
  --line: #30363d;
  --line-soft: #21262d;
  --text: #c9d1d9;
  --muted: #8b949e;
  --strong: #f0f6fc;
  --blue: #388bfd;
  --green: #56d364;
  --red: #f85149;
  --orange: #ffa657;
  --purple: #d2a8ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app {
  min-height: 100vh;
  padding-bottom: 76px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(13, 17, 23, 0.96);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(14px);
}

.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 10px;
}

.title {
  min-width: 0;
}

.title h1 {
  margin: 0;
  color: var(--strong);
  font-size: 18px;
  line-height: 1.2;
}

.title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  padding: 4px 8px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.online {
  color: var(--green);
  border-color: rgba(86, 211, 100, 0.45);
  background: rgba(46, 160, 67, 0.16);
}

.offline {
  color: var(--orange);
  border-color: rgba(255, 166, 87, 0.45);
  background: rgba(247, 133, 20, 0.16);
}

.tabs,
.filters,
.segmented {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar,
.filters::-webkit-scrollbar,
.segmented::-webkit-scrollbar {
  display: none;
}

.tabs {
  padding: 0 16px;
  border-top: 1px solid rgba(48, 54, 61, 0.42);
}

.tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  padding: 11px 8px 10px;
  font-weight: 800;
  white-space: nowrap;
}

.tab.active {
  color: var(--strong);
  border-bottom-color: var(--blue);
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--line-soft);
}

.search-row input,
.search-row select,
.note-box textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  outline: none;
}

.search-row input,
.search-row select {
  height: 38px;
  padding: 0 10px;
}

.search-row input:focus,
.search-row select:focus,
.note-box textarea:focus {
  border-color: var(--blue);
}

.filters {
  padding: 0 16px 10px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.chip.active {
  border-color: var(--blue);
  background: rgba(31, 111, 235, 0.2);
  color: #79c0ff;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  background: var(--line-soft);
}

.stat {
  background: var(--bg);
  padding: 9px 10px;
}

.stat strong,
.stat span {
  display: block;
}

.stat strong {
  color: var(--strong);
  font-size: 17px;
  line-height: 1;
}

.stat span {
  color: var(--muted);
  margin-top: 4px;
  font-size: 11px;
}

.source-line {
  padding: 7px 16px;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list {
  padding: 8px 8px 18px;
}

.row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 46px;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg);
  padding: 10px 8px;
}

.row:active {
  background: var(--panel);
}

.rank {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.main-cell {
  min-width: 0;
}

.row-title {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.row-title strong {
  overflow: hidden;
  color: var(--strong);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.type {
  flex: 0 0 auto;
  border: 1px solid rgba(210, 168, 255, 0.45);
  border-radius: 4px;
  background: rgba(163, 113, 247, 0.16);
  color: var(--purple);
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 800;
}

.meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
}

.meta span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.score {
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
  text-align: right;
}

.score-bar {
  margin-top: 5px;
  height: 4px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
}

.score-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.detail {
  display: none;
  grid-column: 1 / 4;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  margin-top: 10px;
  overflow: hidden;
}

.row.open .detail {
  display: block;
}

.detail-img {
  width: 100%;
  aspect-ratio: 16 / 8;
  object-fit: cover;
  display: block;
  background: #10151f;
}

.detail-body {
  padding: 12px;
}

.detail-body p {
  margin: 0 0 10px;
  color: var(--text);
  line-height: 1.6;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.tag {
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  padding: 2px 6px;
  font-size: 11px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.action,
.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 800;
}

.primary-action {
  border-color: var(--blue);
  background: rgba(31, 111, 235, 0.24);
  color: #79c0ff;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--line);
  background: rgba(13, 17, 23, 0.96);
  backdrop-filter: blur(14px);
}

.nav-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 60px;
  font-size: 11px;
  font-weight: 800;
}

.nav-btn.active {
  color: #79c0ff;
}

.social-actions {
  grid-template-columns: 1fr;
}

.sheet {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  max-height: 82vh;
  transform: translateY(105%);
  border-top: 1px solid var(--line);
  border-radius: 12px 12px 0 0;
  background: var(--panel);
  box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.34);
  transition: transform 0.22s ease;
}

.sheet.open {
  transform: translateY(0);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.sheet-head h2 {
  margin: 0;
  color: var(--strong);
  font-size: 16px;
}

.sheet-body {
  overflow: auto;
  max-height: calc(82vh - 58px);
  padding: 12px 16px 18px;
}

.icon-btn {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  width: 38px;
  height: 34px;
}

.saved-item,
.plan-step {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg);
  padding: 10px;
  margin-bottom: 8px;
}

.saved-item strong,
.plan-step strong {
  display: block;
  color: var(--strong);
}

.saved-item span,
.plan-step span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  font-size: 12px;
}

.note-box {
  display: grid;
  gap: 8px;
}

.note-box textarea {
  min-height: 120px;
  resize: vertical;
  padding: 10px;
}

.empty {
  padding: 46px 18px;
  color: var(--muted);
  text-align: center;
}

@media (min-width: 820px) {
  .app {
    max-width: 920px;
    margin: 0 auto;
    border-right: 1px solid var(--line-soft);
    border-left: 1px solid var(--line-soft);
  }

  .bottom-nav,
  .sheet {
    right: calc((100vw - 920px) / 2);
    left: calc((100vw - 920px) / 2);
  }
}
