:root {
  color-scheme: light;
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --ink: #162124;
  --muted: #647174;
  --line: #d7dfdc;
  --accent: #123234;
  --accent-2: #0e6b67;
  --blue: #315f9f;
  --green: #177055;
  --gold: #af7624;
  --red: #9b2c2c;
  --soft-blue: #e8eff8;
  --soft-green: #e5f2ed;
  --soft-gold: #f4ead7;
  --soft-red: #f5e4e2;
  --shadow: 0 18px 48px rgba(20, 35, 36, 0.1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
  overflow-x: hidden;
}

body.view-desktop {
  overflow-x: auto;
}

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

button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:active {
  transform: translateY(1px);
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid rgba(215, 223, 220, 0.82);
  background: rgba(244, 246, 244, 0.92);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.brand p {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.brand h1 {
  margin-bottom: 0;
  font-size: 23px;
  line-height: 1.1;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.ghost-button,
.icon-button,
.secondary-button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.ghost-button {
  width: 58px;
}

.icon-button {
  width: 44px;
  font-size: 20px;
  line-height: 1;
}

.secondary-button {
  width: 100%;
}

.app-container {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 16px 14px calc(30px + env(safe-area-inset-bottom));
}

.view-phone .app-container {
  max-width: 470px;
}

.view-desktop .app-container {
  width: min(1180px, calc(100vw - 28px));
  max-width: none;
}

.hidden {
  display: none !important;
}

.login-panel,
.hero-panel,
.side-panel,
.project-card,
.entry-panel,
.signal-panel,
.run-panel,
.top-panel,
.queue-panel,
.status-editor,
.history-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel {
  display: grid;
  gap: 12px;
  margin-top: 22px;
  padding: 18px;
}

.login-panel h2 {
  margin-bottom: 0;
  font-size: 22px;
}

.form-message {
  min-height: 20px;
  margin-bottom: 0;
  color: var(--red);
  font-size: 13px;
  line-height: 1.4;
}

.hero-panel {
  padding: 18px;
}

.hero-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.hero-title {
  margin-bottom: 4px;
  font-size: 21px;
  line-height: 1.25;
}

.hero-date {
  color: var(--muted);
  font-size: 13px;
}

.priority-pill {
  flex: 0 0 auto;
  min-width: 54px;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--soft-gold);
  color: var(--gold);
  font-weight: 800;
  text-align: center;
}

.answer-grid {
  display: grid;
  gap: 10px;
}

.answer {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.answer strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent-2);
  font-size: 13px;
}

.answer p {
  margin-bottom: 0;
  line-height: 1.55;
}

.workspace-nav {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.home-return {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tab {
  min-width: 0;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

.home-grid {
  display: grid;
  gap: 12px;
}

.entry-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(14, 107, 103, 0.08), rgba(49, 95, 159, 0.07)),
    var(--surface);
}

.entry-panel span {
  display: block;
  margin-bottom: 8px;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 750;
}

.entry-panel h2 {
  margin-bottom: 8px;
  font-size: 28px;
  line-height: 1.15;
}

.entry-panel p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.entry-actions {
  display: grid;
  gap: 9px;
}

.entry-actions button {
  width: 100%;
  min-height: 46px;
}

.entry-actions button:nth-child(2),
.entry-actions button:nth-child(3) {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.signal-panel,
.run-panel,
.top-panel,
.queue-panel {
  padding: 14px;
}

.signal-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.signal-title span,
.run-row em,
.queue-panel em,
.history-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.signal-title b {
  color: var(--accent-2);
}

.radar-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.radar-grid div {
  padding: 12px 8px;
  border-radius: 8px;
  background: var(--surface-2);
  text-align: center;
}

.radar-grid b {
  display: block;
  margin-bottom: 3px;
  font-size: 24px;
}

.radar-grid span {
  color: var(--muted);
  font-size: 12px;
}

.run-panel h3,
.top-panel h3,
.queue-panel h3,
.status-editor h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.run-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: baseline;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.run-row:first-of-type {
  border-top: 0;
}

.run-row span {
  color: var(--gold);
  font-weight: 800;
}

.run-row b {
  min-width: 0;
  font-size: 14px;
}

.run-row em {
  grid-column: 2;
}

.top-panel,
.queue-panel {
  display: grid;
  gap: 8px;
}

.top-panel button,
.queue-panel button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 10px;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.top-panel button span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
}

.queue-panel button div {
  min-width: 0;
}

.queue-panel b,
.pipeline-card b,
.history-card b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 138px;
  gap: 10px;
  margin-bottom: 14px;
}

.layout-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.side-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.account-panel,
.history-panel,
.push-panel {
  display: grid;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.account-panel {
  grid-template-columns: minmax(0, 1fr) 82px;
  align-items: center;
}

.account-panel span,
.history-panel label,
.push-panel span,
.status-editor label {
  color: var(--muted);
  font-size: 12px;
}

.account-panel b {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-panel .secondary-button {
  min-height: 36px;
}

.push-panel button {
  width: 100%;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  padding: 11px;
  border-radius: 8px;
  background: var(--surface-2);
}

.stat span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
}

.stat b {
  font-size: 22px;
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.filter {
  width: 100%;
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.filter.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.result-meta {
  margin: 2px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.project-list {
  display: grid;
  gap: 12px;
}

.project-card {
  overflow: clip;
}

.project-button {
  width: 100%;
  padding: 15px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.project-button:active {
  transform: none;
}

.project-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
}

.badge {
  display: inline-grid;
  min-width: 42px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.badge.small {
  min-width: 34px;
  height: 26px;
  font-size: 12px;
}

.badge.a {
  background: var(--accent-2);
}

.badge.b {
  background: var(--muted);
}

.source-line {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.source-line span:not(.source-icon) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-line .link-quality {
  flex: 0 0 auto;
  padding: 3px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.source-line .link-quality.exact {
  background: var(--soft-green);
  color: var(--green);
}

.source-line .link-quality.mirror,
.source-line .link-quality.detail {
  background: var(--soft-gold);
  color: var(--gold);
}

.source-icon {
  display: inline-grid;
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.source-icon.csg {
  background: var(--soft-green);
  color: var(--green);
}

.source-icon.chn {
  background: var(--soft-blue);
  color: var(--blue);
}

.source-icon.ctg {
  background: var(--soft-gold);
  color: var(--gold);
}

.source-icon.sz {
  background: var(--soft-red);
  color: var(--red);
}

.project-title {
  margin-bottom: 7px;
  font-size: 17px;
  line-height: 1.3;
}

.project-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}

.chip {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.chip.gold {
  background: var(--soft-gold);
  color: var(--gold);
}

.status-gray {
  background: var(--surface-2);
  color: var(--muted);
}

.status-blue {
  background: var(--soft-blue);
  color: var(--blue);
}

.status-green,
.status-teal {
  background: var(--soft-green);
  color: var(--green);
}

.status-gold {
  background: var(--soft-gold);
  color: var(--gold);
}

.status-red {
  background: var(--soft-red);
  color: var(--red);
}

.project-detail {
  display: none;
  padding: 0 15px 15px 67px;
  border-top: 1px solid var(--line);
  background: #fbfcfb;
}

.project-card.open .project-detail {
  display: block;
}

.detail-grid {
  display: grid;
  gap: 12px;
}

.field {
  margin-top: 13px;
}

.field strong {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.field p {
  margin-bottom: 0;
  line-height: 1.55;
}

.risk p {
  color: var(--red);
}

.project-toolbar,
.action-row,
.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.project-toolbar button,
.action-row button {
  width: auto;
  min-height: 36px;
  padding: 7px 10px;
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.project-toolbar button:first-child {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.action-row button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pipeline-layout {
  display: grid;
  gap: 14px;
}

.pipeline-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.status-tile {
  display: grid;
  min-height: 74px;
  place-items: center;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.status-tile b {
  font-size: 24px;
}

.status-tile span {
  font-size: 12px;
}

.pipeline-board {
  display: grid;
  gap: 12px;
}

.pipeline-column {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.pipeline-column header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.pipeline-column header em {
  margin-left: auto;
  color: var(--muted);
  font-style: normal;
}

.pipeline-column p {
  min-height: 34px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.status-dot.status-gray {
  background: var(--muted);
}

.status-dot.status-blue {
  background: var(--blue);
}

.status-dot.status-green,
.status-dot.status-teal {
  background: var(--green);
}

.status-dot.status-gold {
  background: var(--gold);
}

.status-dot.status-red {
  background: var(--red);
}

.pipeline-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  width: 100%;
  min-height: 64px;
  margin-top: 8px;
  padding: 10px;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.pipeline-card em {
  grid-column: 2;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-column {
  display: block;
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
}

.status-editor {
  display: grid;
  gap: 8px;
  padding: 14px;
}

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

.history-grid {
  display: grid;
  gap: 12px;
}

.history-card {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.history-card button {
  justify-self: start;
  min-height: 36px;
  padding: 7px 12px;
}

.source-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  background: rgba(12, 22, 24, 0.52);
}

.source-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(100%, 1100px);
  height: 100%;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
}

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

.source-head span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.source-head b {
  display: block;
  max-width: 680px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-actions {
  display: flex;
  gap: 8px;
}

.source-link {
  display: inline-grid;
  min-height: 40px;
  padding: 0 12px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}

.source-shell iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

footer {
  position: sticky;
  bottom: 0;
  z-index: 20;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(215, 223, 220, 0.82);
  background: rgba(244, 246, 244, 0.92);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  backdrop-filter: blur(18px);
}

@media (min-width: 820px) {
  .answer-grid,
  .home-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .entry-panel {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) 260px;
    align-items: center;
  }

  .layout-grid {
    align-items: start;
    grid-template-columns: 286px minmax(0, 1fr);
  }

  .side-panel {
    position: sticky;
    top: 86px;
  }

  .project-list {
    display: block;
    columns: 2 320px;
    column-gap: 12px;
  }

  .project-card {
    display: inline-block;
    width: 100%;
    margin: 0 0 12px;
    break-inside: avoid;
  }

  .pipeline-layout {
    align-items: start;
    grid-template-columns: minmax(0, 1fr) 340px;
  }

  .pipeline-board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .pipeline-summary {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .status-editor {
    position: sticky;
    top: 86px;
  }
}

.view-phone .control-strip,
.view-phone .layout-grid,
.view-phone .project-list,
.view-phone .home-grid,
.view-phone .pipeline-layout,
.view-phone .pipeline-board,
.view-phone .history-grid {
  grid-template-columns: 1fr;
}

.view-phone .project-list {
  display: grid;
  columns: auto;
}

.view-phone .project-card {
  display: block;
  margin: 0;
}

.view-phone .pipeline-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.view-phone .side-panel,
.view-phone .status-editor {
  position: static;
}

.view-phone .project-detail {
  padding-left: 15px;
}

.view-desktop .answer-grid,
.view-desktop .home-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.view-desktop .entry-panel {
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) 280px;
  align-items: center;
}

.view-desktop .layout-grid {
  align-items: start;
  grid-template-columns: 286px 1fr;
}

.view-desktop .project-list {
  display: block;
  columns: 2 320px;
  column-gap: 12px;
}

.view-desktop .project-card {
  display: inline-block;
  width: 100%;
  margin: 0 0 12px;
  break-inside: avoid;
}

.view-desktop .pipeline-layout {
  align-items: start;
  grid-template-columns: minmax(0, 1fr) 340px;
}

.view-desktop .pipeline-board {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
