/* Daily Command Center (今日作战指挥室, TODAY / daily-desk).
   Follows docs/design.md & palette.css: warm paper ground, 1px square borders, no shadows,
   tabular numerals, red/green strictly on directional numbers, sea blue for 幕僚, magenta for user's own holdings. */
#dailyDesk {
  position: absolute;
  inset: 0;
  z-index: 6;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  caret-color: var(--mag);
  scrollbar-color: var(--line) var(--paper);
}
#dailyDesk[hidden] {
  display: none;
}
#dailyDesk ::selection {
  background: var(--sel);
  color: var(--ink);
}
#dailyDesk :is(button, input, a, summary):focus-visible {
  outline: 2px solid var(--sea);
  outline-offset: -2px;
}
#bar #todayBtn[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  box-shadow: inset 0 -2px 0 var(--mag);
  font-weight: 700;
}
/* In today-mode, hide tools that only mutate an active K-line canvas (docs/design.md: 东西放在它作用的对象旁边)
   and un-highlight the period pill so "You are here" is unambiguously 今日. */
body.today-mode #bar #periods button.on {
  background: #fff;
  color: var(--ink-soft);
}
body.today-mode #bar :is(#adj, #layoutBtn, #formulaBtn, #note, #eventControls) {
  display: none;
}
@media (max-width: 720px) {
  body.today-mode #bar #periods {
    display: none;
  }
}

.dd-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Buttons inside Daily Desk: 26px square 1px border on desktop, 34px touch target on mobile */
#dailyDesk button {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: 12px/1 var(--sans);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
#dailyDesk button:hover:not(:disabled) {
  border-color: var(--ink-soft);
  background: var(--hover);
}
#dailyDesk button.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
#dailyDesk button.primary:hover:not(:disabled) {
  background: var(--ink-soft);
}
#dailyDesk button.sea {
  border-color: var(--sea);
  color: var(--sea);
  background: #fff;
}
#dailyDesk button.sea:hover:not(:disabled) {
  background: var(--sel);
}
#dailyDesk button:disabled {
  opacity: 0.55;
  cursor: default;
}

/* Clickable card title button (opens chart or topic directly without adding extra button clutter) */
#dailyDesk button.dd-title-btn {
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 700 13.5px/1.25 var(--sans);
  text-align: left;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  white-space: normal;
}
#dailyDesk button.dd-title-btn:hover:not(:disabled) {
  background: transparent;
  color: var(--sea);
  text-decoration: underline;
  text-underline-offset: 3px;
}
#dailyDesk button.dd-link-btn {
  height: 20px;
  padding: 0 7px;
  font-size: 11px;
  color: var(--sea);
  border-color: var(--line);
  background: #fff;
}
.dd-title-arrow {
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 400;
}

/* Tier 1: Unified Command Header & Regime Gate */
.dd-command {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px double var(--mag);
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Phase Bar: Clean segmented phase tabs on left, live radar status & Esc on right */
.dd-phase-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}
.dd-phase-lead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}
.dd-slot-seg {
  display: inline-flex;
  border: 1px solid var(--line);
  background: #fff;
}
#dailyDesk button.dd-slot-tab {
  border: 0;
  border-right: 1px solid var(--rule);
  height: 24px;
  padding: 0 11px;
  background: #fff;
  color: var(--ink-soft);
  font: 700 12px/1 var(--serif);
}
#dailyDesk button.dd-slot-tab:last-child {
  border-right: 0;
}
#dailyDesk button.dd-slot-tab:hover:not(.on) {
  color: var(--ink);
  background: var(--hover);
}
#dailyDesk button.dd-slot-tab.on {
  background: var(--ink);
  color: #fff;
  box-shadow: inset 0 -2px 0 var(--mag);
}

.dd-radar-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--rule);
  background: var(--paper);
  font: 12px/1 var(--sans);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.dd-radar-pill b {
  color: var(--ink);
  font-family: var(--mono);
}
.dd-radar-pill .dd-urgent-num {
  color: var(--mustard);
}
.dd-radar-dot {
  width: 6px;
  height: 6px;
  background: var(--sea);
  flex: none;
}
.dd-radar-dot.is-live,
.dd-radar-pill.has-urgent .dd-radar-dot {
  background: var(--mag);
  animation: dd-pulse 2.2s ease-in-out infinite;
}
@keyframes dd-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.32; }
}

.dd-command-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: none;
}
.dd-date-pill {
  font: 12px/24px var(--mono);
  color: var(--ink-soft);
  padding: 0 8px;
  border: 1px solid var(--rule);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}
.dd-regime {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--ink);
  background: var(--paper);
  font: 700 12px/1 var(--serif);
  color: var(--ink);
}
.dd-regime.tone-mustard {
  border-color: var(--mustard);
  color: var(--mustard);
  background: #fff;
}
.dd-regime.tone-up {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}
.dd-regime.tone-muted {
  border-color: var(--ink-soft);
  color: var(--ink-soft);
}

/* Two-column Tactical Grid: Left = Rich Brief + Full Report Link; Right = Gate 100-bar Chart + 3-row Aligned Pulse Box */
.dd-tactical-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(420px, 1fr);
  gap: 14px;
  align-items: stretch;
}
.dd-thesis-col {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}
.dd-thesis-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dd-headline {
  margin: 0;
  font: 700 17px/1.35 var(--serif);
  color: var(--ink);
}
.dd-thesis-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
}
.dd-brief-list {
  margin: 0;
  padding: 8px 10px 8px 22px;
  background: var(--paper);
  border: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.dd-brief-list li {
  font-size: 12.5px;
  line-height: 1.48;
  color: var(--ink-soft);
}
.dd-brief-list li b {
  color: var(--ink);
  font-family: var(--serif);
}
.dd-brief-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding-top: 2px;
}
#dailyDesk button.dd-report-link {
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--sea);
  font: 700 12.5px/1.3 var(--serif);
  text-decoration: underline;
  text-underline-offset: 3px;
}
#dailyDesk button.dd-report-link:hover {
  color: var(--ink);
}
.dd-report-ext {
  font-size: 12px;
  color: var(--ink-soft);
  text-decoration: none;
}
.dd-report-ext:hover {
  color: var(--sea);
  text-decoration: underline;
}

/* Right Column: Gate Index 100-bar Chart + 3-Row Aligned Market Pulse Box */
.dd-gate-col {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0;
  min-width: 0;
}

/* 3-Row Aligned Market Pulse Box attached flush under the Gate Chart */
.dd-pulse-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 0;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.dd-pulse-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 22px;
}
.dd-pulse-row + .dd-pulse-row {
  border-top: 1px dashed var(--rule);
  padding-top: 4px;
}
.dd-pulse-label {
  font: 700 11.5px/1.2 var(--serif);
  color: var(--ink-soft);
  white-space: nowrap;
}
.dd-pulse-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
}
.dd-pulse-cell-between {
  justify-content: space-between;
}
.dd-pulse-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}
.dd-breadth-nums b {
  font-family: var(--mono);
}
.dd-breadth-bar {
  display: inline-flex;
  width: 72px;
  height: 6px;
  background: var(--down);
  border: 1px solid var(--line);
  overflow: hidden;
}
.dd-breadth-bar .up {
  background: var(--up);
  height: 100%;
}
.dd-breadth-bar .flat {
  background: var(--rule);
  height: 100%;
}
.dd-vol-badge {
  color: var(--ink-soft);
  padding-left: 6px;
  border-left: 1px solid var(--line);
}
.dd-vol-badge b {
  font-family: var(--mono);
  color: var(--ink);
}
.dd-sector-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 1px 6px;
  background: #fff;
  border: 1px solid var(--rule);
  font-size: 11.5px;
  color: var(--ink);
}
.dd-sector-chip b {
  font-family: var(--mono);
}

/* Inline full report drawer */
.dd-report-drawer {
  background: #fff;
  border: 1px solid var(--line);
  padding: 14px 18px;
}
.dd-report-drawer[hidden] {
  display: none;
}
.dd-report-drawer h2 {
  font: 700 15px/1.4 var(--serif);
  margin: 14px 0 6px;
  color: var(--ink);
}
.dd-report-drawer h2:first-child {
  margin-top: 0;
}
.dd-report-drawer p,
.dd-report-drawer li {
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink);
  max-width: 72ch;
}
.dd-report-drawer ul,
.dd-report-drawer ol {
  margin: 6px 0;
  padding-left: 1.4em;
}

/* Maximized 100-bar Tactical Chart with On-Chart HUD Overlay ("文字直接画在图上，让 K 线区域最大化") */
.dd-tactical-chart {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  overflow: hidden;
}
.dd-tactical-chart svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 148px;
}
.dd-chart-hud {
  position: absolute;
  top: 4px;
  left: 8px;
  right: 54px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: none;
}
.dd-chart-hud :is(button, a) {
  pointer-events: auto;
}
.dd-hud-head {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 1px 4px 1px 0;
  width: fit-content;
  max-width: 100%;
}
.dd-hud-tag {
  font: 700 11.5px/1.2 var(--serif);
  color: var(--ink-soft);
}
.dd-hud-note {
  font-size: 11px;
  line-height: 1.3;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.84);
  padding: 1px 4px 1px 0;
  width: fit-content;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dd-k-dot {
  animation: dd-pulse 2.2s ease-in-out infinite;
}

/* 1D Price Range Ruler (fallback only) */
.dd-ruler {
  background: var(--panel);
  border: 1px solid var(--rule);
  padding: 6px 10px 5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.dd-ruler-labels {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font: 11px/1.2 var(--mono);
  color: var(--ink-soft);
}
.dd-ruler-track {
  position: relative;
  height: 6px;
  background: var(--rule);
  border: 1px solid var(--line);
}
.dd-ruler-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--sel);
}
.dd-ruler-cost {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--mag);
  transform: translateX(-50%);
}
.dd-ruler-now {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  background: var(--ink);
  border: 1px solid #fff;
  transform: translate(-50%, -50%);
}
.dd-ruler-now.is-trig {
  background: var(--mustard);
}
.dd-ruler-now.is-danger {
  background: var(--seal);
}
.dd-ruler-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--ink-soft);
}
.dd-ruler-foot b {
  font-family: var(--mono);
  color: var(--ink);
}

/* Section Headers */
.dd-sec {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dd-sec-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 5px;
}
.dd-sec-title-group {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
}
.dd-sec-title {
  margin: 0;
  font: 700 15px/1.3 var(--serif);
  color: var(--ink);
}
.dd-sec-sub {
  font-size: 12px;
  color: var(--ink-soft);
}
.dd-sec-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.dd-sec-meta {
  font: 12px/1.3 var(--mono);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.dd-status-note {
  font-size: 12px;
  color: var(--sea);
}
.dd-status-note:empty {
  display: none;
}

/* Recent Fired Events Stream (最新战况流水) */
.dd-event-log {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 5px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 12px;
}
.dd-event-log-tag {
  font: 700 12px/1 var(--serif);
  color: var(--mustard);
  white-space: nowrap;
}
.dd-event-log-items {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
#dailyDesk button.dd-event-chip {
  height: 22px;
  padding: 0 8px;
  background: #fff;
  border: 1px solid var(--rule);
  font-size: 11px;
  gap: 5px;
}
#dailyDesk button.dd-event-chip.is-unseen {
  border-color: var(--mustard);
}
.dd-event-chip time {
  font-family: var(--mono);
  color: var(--ink-soft);
}

/* Tier 2: Battlefield Cards Grid (Compact, Maximized K-line Area) */
.dd-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.dd-card {
  background: #fff;
  border: 1px solid var(--line);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
}
.dd-card.is-position {
  border-left: 3px solid var(--mag);
}
.dd-card.is-urgent {
  border-color: var(--mustard);
  border-left: 3px solid var(--mustard);
  background: var(--card);
}
.dd-card.is-danger {
  border-color: var(--seal);
  border-left: 3px solid var(--seal);
}
.dd-card.is-topic {
  border-left: 3px solid var(--sea);
}
.dd-card-stack {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.dd-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}
.dd-card-id {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}
.dd-code {
  font: 11.5px/1 var(--mono);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.dd-quote {
  font: 700 12.5px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.dd-up {
  color: var(--up);
}
.dd-down {
  color: var(--down);
}

/* Semantic Status Badges */
.dd-badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
}
.dd-badge.pos {
  border-color: var(--mag);
  color: var(--mag);
  background: #fff;
}
.dd-badge.urgent {
  border-color: var(--mustard);
  color: var(--mustard);
  background: #fff;
}
.dd-badge.danger {
  border-color: var(--seal);
  color: var(--seal);
  background: #fff;
}
.dd-badge.topic {
  border-color: var(--sea);
  color: var(--sea);
  background: #fff;
}

.dd-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* Inline cost & size form inside a card */
.dd-enter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  padding: 6px 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 12px;
}
.dd-enter-form[hidden] {
  display: none;
}
.dd-enter-form label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.dd-enter-form input {
  width: 84px;
  height: 24px;
  padding: 0 6px;
  border: 1px solid var(--line);
  background: #fff;
  font: 12px var(--mono);
  color: var(--ink);
}

/* Calm / Empty / Quiet states */
.dd-calm-banner {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  font-size: 13px;
  color: var(--ink-soft);
}
.dd-quiet-bar {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 7px 12px;
}
.dd-quiet-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}
.dd-quiet-list {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  display: grid;
  gap: 6px;
}
.dd-quiet-list[hidden] {
  display: none;
}
.dd-quiet-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  padding: 4px 8px;
  background: #fff;
  border: 1px solid var(--rule);
  font-size: 12px;
}
.dd-quiet-row-left {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  min-width: 0;
}

/* Tier 3: Hotspots with Pre-calculated Odds */
.dd-hotspot-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 980px) {
  .dd-tactical-grid {
    grid-template-columns: 1fr;
  }
  .dd-hotspot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 720px) {
  .dd-wrap {
    padding: 8px 10px 28px;
    gap: 12px;
  }
  .dd-command {
    padding: 10px;
  }
  .dd-headline {
    font-size: 16px;
  }
  .dd-cards-grid,
  .dd-hotspot-grid {
    grid-template-columns: 1fr;
  }
  #dailyDesk button:not(.dd-title-btn):not(.dd-report-link) {
    min-height: 32px;
    padding: 0 9px;
  }
  .dd-enter-form input {
    height: 30px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .dd-radar-dot.is-live,
  .dd-radar-pill.has-urgent .dd-radar-dot,
  .dd-k-dot {
    animation: none;
  }
}
