:root {
  color-scheme: light;
  --canvas: #f2f4f7;
  --surface: #ffffff;
  --surface-subtle: #f8f9fb;
  --surface-raised: #ffffff;
  --text: #17212b;
  --muted: #687386;
  --line: #dce1e8;
  --line-strong: #bcc5d1;
  --brand: #2456a6;
  --brand-strong: #193f7c;
  --brand-soft: #eaf1fb;
  --buy: #087a50;
  --buy-soft: #e7f6ef;
  --sell: #c63e32;
  --sell-soft: #fdecea;
  --warning: #a35f00;
  --warning-soft: #fff4df;
  --chart-line: #356fbd;
  --chart-buy: #0b8a5a;
  --chart-sell: #dc4c40;
  --shadow-small: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-menu: 0 12px 28px rgba(16, 24, 40, 0.12);
  --topbar-height: 64px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #111417;
  --surface: #181c20;
  --surface-subtle: #20252b;
  --surface-raised: #22272d;
  --text: #f1f4f7;
  --muted: #a8b1bd;
  --line: #343a42;
  --line-strong: #4a535f;
  --brand: #8fb8ff;
  --brand-strong: #b7d0ff;
  --brand-soft: #202f45;
  --buy: #6fd4a6;
  --buy-soft: #17372c;
  --sell: #ff9188;
  --sell-soft: #442521;
  --warning: #ffc46b;
  --warning-soft: #3b3020;
  --chart-line: #a8c8ff;
  --chart-buy: #ffbf69;
  --chart-sell: #ff8d84;
  --shadow-small: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-menu: 0 16px 32px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

.d-none {
  display: none !important;
}

.visually-hidden {
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  height: 1px !important;
  overflow: hidden !important;
  position: absolute !important;
  white-space: nowrap !important;
  width: 1px !important;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-height) + 16px);
}

body {
  background: var(--canvas);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Segoe UI", sans-serif;
  letter-spacing: 0;
  margin: 0;
  min-width: 320px;
}

button,
input {
  font: inherit;
}

button,
a,
summary,
input {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 32%, transparent);
  outline-offset: 2px;
}

.app-shell {
  margin: 0 auto;
  max-width: 1240px;
  width: 100%;
}

.topbar {
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--line);
  height: var(--topbar-height);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.topbar-inner {
  align-items: center;
  display: flex;
  height: 100%;
  justify-content: space-between;
  padding: 0 24px;
}

.brand {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  background: var(--text);
  border-radius: 6px;
  color: var(--surface);
  display: inline-flex;
  flex: 0 0 34px;
  font-size: 0.7rem;
  font-weight: 850;
  height: 34px;
  justify-content: center;
}

.brand-name,
.brand-subtitle {
  display: block;
  line-height: 1.2;
}

.brand-name {
  font-size: 0.95rem;
  font-weight: 800;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.68rem;
  margin-top: 2px;
}

.topbar-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.desktop-nav {
  align-items: center;
  align-self: stretch;
  display: flex;
  gap: 4px;
  margin-left: auto;
  margin-right: 20px;
}

.desktop-nav a {
  align-items: center;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  gap: 6px;
  padding: 0 13px;
  text-decoration: none;
}

.desktop-nav a.active {
  border-bottom-color: var(--brand);
  color: var(--brand);
}

.desktop-nav .lucide {
  height: 15px;
  width: 15px;
}

.sync-status {
  color: var(--muted);
  font-size: 0.76rem;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  display: inline-flex;
  flex: 0 0 42px;
  height: 42px;
  justify-content: center;
  padding: 0;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
  width: 42px;
}

.icon-button:hover {
  background: var(--surface-subtle);
  border-color: var(--line-strong);
}

.icon-button:active {
  transform: scale(0.96);
}

.icon-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.is-spinning .lucide {
  animation: spin 0.8s linear infinite;
}

.icon-button .lucide {
  height: 18px;
  width: 18px;
}

.icons-ready .icon-fallback {
  display: none;
}

.main-content {
  background: var(--surface);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-height: calc(100vh - var(--topbar-height));
}

.workspace-section {
  animation: view-enter 180ms ease-out;
  border-bottom: 1px solid var(--line);
  min-height: calc(100vh - var(--topbar-height) - 76px);
  padding: 32px;
}

@keyframes view-enter {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-heading {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-heading h1,
.section-heading h2 {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.25;
  margin: 2px 0 0;
}

.section-heading p {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 4px 0 0;
}

.section-kicker {
  color: var(--brand);
  font-size: 0.68rem;
  font-weight: 850;
}

.section-meta {
  color: var(--muted);
  font-size: 0.76rem;
}

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

.market-score-card {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  padding: 18px;
}

.market-card-head,
.market-score-line {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.market-ticker {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.market-name {
  font-size: 1rem;
  font-weight: 800;
  margin-top: 2px;
}

.status-chip,
.signal-badge,
.condition-badge,
.date-badge,
.count-badge {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 800;
  justify-content: center;
  line-height: 1;
  min-height: 26px;
  padding: 5px 9px;
  white-space: nowrap;
}

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

.market-score-line {
  align-items: flex-end;
  margin-top: 16px;
}

.score-number {
  font-size: 2.2rem;
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  line-height: 1;
}

.score-max {
  color: var(--muted);
  font-size: 0.78rem;
  margin-left: 4px;
}

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

.score-progress span {
  background: var(--brand);
  border-radius: inherit;
  display: block;
  height: 100%;
  transition: width 300ms ease;
}

.score-market-meta {
  color: var(--muted);
  font-size: 0.73rem;
  margin-top: 8px;
}

.score-details {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 10px;
}

.score-details summary {
  align-items: center;
  color: var(--brand);
  cursor: pointer;
  display: flex;
  font-size: 0.78rem;
  font-weight: 800;
  justify-content: space-between;
  list-style: none;
  min-height: 34px;
}

.score-details summary::-webkit-details-marker,
.advanced-options summary::-webkit-details-marker,
.history-disclosure summary::-webkit-details-marker {
  display: none;
}

.score-details summary::after {
  content: "＋";
  font-size: 1rem;
}

.score-details[open] summary::after {
  content: "−";
}

.score-component-list {
  border-top: 1px solid var(--line);
}

.score-component-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px 0;
}

.score-component-row:last-child {
  border-bottom: 0;
  padding-bottom: 2px;
}

.component-label,
.component-source {
  color: var(--muted);
  font-size: 0.7rem;
}

.component-value {
  font-size: 0.84rem;
  font-weight: 800;
  margin-top: 2px;
}

.component-score {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.component-score.pass {
  color: var(--buy);
}

.skeleton {
  animation: pulse 1.5s ease-in-out infinite;
  background: var(--line);
  border-radius: 4px;
}

.skeleton-line {
  height: 12px;
  margin-top: 14px;
  width: 80%;
}

.skeleton-line.short {
  margin-top: 0;
  width: 44%;
}

.skeleton-score {
  height: 38px;
  margin-top: 22px;
  width: 34%;
}

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

.home-summary-item {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 12px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-height: 92px;
  padding: 14px;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.home-summary-item:hover {
  background: var(--surface-subtle);
  border-color: var(--line-strong);
}

.home-summary-item strong {
  display: inline-block;
  font-size: 1.1rem;
  font-weight: 850;
  line-height: 1.2;
  margin-top: 4px;
}

.home-summary-item small {
  color: var(--muted);
  font-size: 0.72rem;
  margin-left: 8px;
}

.home-summary-icon {
  align-items: center;
  background: var(--brand-soft);
  border-radius: 7px;
  color: var(--brand);
  display: inline-flex;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.home-summary-icon.portfolio {
  background: var(--buy-soft);
  color: var(--buy);
}

.home-summary-icon .lucide {
  height: 18px;
  width: 18px;
}

.summary-arrow {
  color: var(--muted);
  height: 17px;
  width: 17px;
}

@keyframes pulse {
  50% {
    opacity: 0.48;
  }
}

.search-workspace {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.search-primary {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  display: flex;
  min-height: 54px;
  overflow: hidden;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.search-primary:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent);
}

.search-leading {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex: 0 0 48px;
  justify-content: center;
}

.search-leading .lucide {
  height: 19px;
  width: 19px;
}

.ticker-input {
  background: transparent;
  border: 0;
  color: var(--text);
  flex: 1 1 auto;
  font-size: 1.05rem;
  font-weight: 750;
  height: 52px;
  min-width: 0;
  outline: 0;
  padding: 0 10px 0 0;
  text-transform: uppercase;
}

.ticker-input::placeholder {
  color: var(--muted);
  font-weight: 500;
  opacity: 0.72;
}

.primary-action,
.secondary-action {
  align-items: center;
  border-radius: 7px;
  display: inline-flex;
  font-weight: 800;
  gap: 8px;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.primary-action {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: #ffffff;
}

[data-theme="dark"] .primary-action {
  color: #111821;
}

.primary-action:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

.primary-action:active,
.secondary-action:active {
  transform: translateY(1px);
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-action .lucide,
.secondary-action .lucide {
  height: 17px;
  width: 17px;
}

.search-primary .primary-action {
  border-radius: 6px;
  margin-right: 5px;
  min-height: 44px;
}

.secondary-action {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text);
}

.secondary-action:hover {
  background: var(--surface-subtle);
  border-color: var(--brand);
  color: var(--brand);
}

.search-options {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-top: 14px;
}

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

.option-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.segmented-control {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
}

.segmented-control button {
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
  min-height: 34px;
  padding: 0 12px;
  white-space: nowrap;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.active {
  background: var(--brand-soft);
  color: var(--brand);
}

.advanced-options {
  position: relative;
}

.advanced-options summary {
  align-items: center;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  gap: 6px;
  list-style: none;
  min-height: 36px;
}

.advanced-options summary .lucide {
  height: 15px;
  width: 15px;
}

.advanced-fields {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-menu);
  min-width: 200px;
  padding: 14px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label,
.switch-field strong {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.field input,
.unit-input {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--text);
  height: 44px;
}

.field input {
  min-width: 0;
  padding: 0 12px;
  width: 100%;
}

.field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent);
  outline: 0;
}

.unit-input {
  align-items: center;
  display: flex;
  overflow: hidden;
}

.unit-input input {
  border: 0;
  flex: 1;
}

.unit-input span {
  color: var(--muted);
  font-size: 0.76rem;
  padding-right: 12px;
}

.app-alert {
  border-radius: 7px;
  font-size: 0.84rem;
  margin-top: 14px;
  padding: 12px 14px;
}

.error-alert {
  background: var(--sell-soft);
  border: 1px solid color-mix(in srgb, var(--sell) 38%, transparent);
  color: var(--sell);
}

.analysis-loading {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.82rem;
  gap: 10px;
  justify-content: center;
  min-height: 180px;
}

.loading-spinner {
  animation: spin 0.8s linear infinite;
  border: 2px solid var(--line);
  border-radius: 50%;
  border-top-color: var(--brand);
  height: 20px;
  width: 20px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.analysis-result {
  margin-top: 22px;
}

.stock-summary {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.stock-actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.route-action {
  text-decoration: none;
}

.stock-identity {
  min-width: 0;
}

.stock-code-row {
  align-items: center;
  display: flex;
  gap: 8px;
}

.stock-code {
  color: var(--brand);
  font-size: 0.8rem;
  font-weight: 850;
}

.date-badge {
  color: var(--muted);
  min-height: 22px;
  padding: 4px 8px;
}

.stock-identity h3 {
  font-size: 1.3rem;
  font-weight: 850;
  line-height: 1.35;
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.signal-strip {
  align-items: stretch;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  margin-top: 18px;
  overflow: hidden;
}

.signal-primary,
.signal-price {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 104px;
  padding: 18px;
}

.signal-price {
  border-left: 1px solid var(--line);
}

.metric-label {
  color: var(--muted);
  display: block;
  font-size: 0.72rem;
  font-weight: 750;
}

.signal-value-row {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.signal-value-row strong {
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  line-height: 1;
}

.signal-price strong {
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  margin-top: 8px;
}

.signal-badge.neutral {
  background: var(--surface);
  color: var(--muted);
}

.signal-badge.buy {
  background: var(--buy-soft);
  border-color: color-mix(in srgb, var(--buy) 35%, transparent);
  color: var(--buy);
}

.signal-badge.sell {
  background: var(--sell-soft);
  border-color: color-mix(in srgb, var(--sell) 35%, transparent);
  color: var(--sell);
}

.metric-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 10px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 86px;
  padding: 14px;
}

.metric-card strong {
  display: block;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  line-height: 1.2;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.metric-card.highlight {
  background: var(--brand-soft);
  border-color: color-mix(in srgb, var(--brand) 30%, var(--line));
}

.analysis-tabs {
  margin-top: 26px;
  scroll-margin-top: calc(var(--topbar-height) + 10px);
}

.tab-list {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 4px;
}

.tab-button {
  align-items: center;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.82rem;
  font-weight: 800;
  gap: 7px;
  min-height: 44px;
  padding: 0 14px;
}

.tab-button.active {
  border-bottom-color: var(--brand);
  color: var(--brand);
}

.tab-button .lucide {
  height: 16px;
  width: 16px;
}

.tab-panel {
  padding-top: 16px;
}

.chart-toolbar,
.data-toolbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  min-height: 28px;
}

.chart-note {
  color: var(--muted);
  font-size: 0.72rem;
}

.chart-frame {
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 440px;
  overflow: hidden;
  padding: 12px;
}

.compact-toggle {
  align-items: center;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 750;
  gap: 6px;
}

.data-table-wrap,
.trade-table-wrap,
.portfolio-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 520px;
  overflow: auto;
}

.data-table {
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text);
  font-size: 0.8rem;
  min-width: 100%;
  width: max-content;
}

.data-table th,
.data-table td {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover td {
  background: var(--surface-subtle);
}

.data-table .numeric {
  text-align: right;
}

.expectation-high,
.positive {
  color: var(--buy);
  font-weight: 800;
}

.expectation-low,
.negative {
  color: var(--sell);
  font-weight: 800;
}

.backtest-form {
  align-items: end;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(110px, 0.8fr)) minmax(150px, 1fr) minmax(190px, 1.2fr);
  padding: 16px;
}

.switch-field {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  height: 44px;
  justify-content: space-between;
  padding: 0 12px;
}

.switch-field > span:first-child {
  display: flex;
  flex-direction: column;
}

.switch-field strong {
  color: var(--text);
  line-height: 1.1;
}

.switch-field small {
  color: var(--muted);
  font-size: 0.62rem;
  margin-top: 2px;
}

.switch {
  flex: 0 0 auto;
  height: 24px;
  position: relative;
  width: 42px;
}

.switch input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.switch-track {
  background: var(--line-strong);
  border-radius: 999px;
  inset: 0;
  position: absolute;
  transition: background-color 160ms ease;
}

.switch-track::after {
  background: #ffffff;
  border-radius: 50%;
  box-shadow: var(--shadow-small);
  content: "";
  height: 18px;
  left: 3px;
  position: absolute;
  top: 3px;
  transition: transform 160ms ease;
  width: 18px;
}

.switch input:checked + .switch-track {
  background: var(--brand);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 3px solid color-mix(in srgb, var(--brand) 32%, transparent);
  outline-offset: 2px;
}

.backtest-action {
  height: 44px;
}

.backtest-results {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding-top: 24px;
}

.result-heading {
  align-items: flex-start;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.result-heading h3 {
  font-size: 1.1rem;
  font-weight: 850;
  margin: 2px 0 0;
}

.condition-badge {
  color: var(--muted);
}

.history-disclosure {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 14px;
  overflow: hidden;
}

.history-disclosure > summary {
  align-items: center;
  background: var(--surface-subtle);
  cursor: pointer;
  display: flex;
  font-size: 0.86rem;
  font-weight: 850;
  justify-content: space-between;
  list-style: none;
  min-height: 52px;
  padding: 0 14px;
}

.history-disclosure[open] > summary {
  border-bottom: 1px solid var(--line);
}

.count-badge {
  background: var(--surface);
  color: var(--muted);
  min-height: 24px;
}

.trade-table-wrap {
  border: 0;
  border-radius: 0;
}

.trade-card-list,
.portfolio-card-list {
  display: none;
}

.title-with-count {
  align-items: center;
  display: flex;
  gap: 8px;
}

.empty-state {
  align-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  min-height: 128px;
  padding: 20px;
}

.empty-state .lucide {
  height: 22px;
  width: 22px;
}

.empty-state strong {
  font-size: 0.84rem;
}

.portfolio-actions {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  justify-content: flex-end;
}

.table-action {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.table-action:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.table-action.danger:hover {
  border-color: var(--sell);
  color: var(--sell);
}

.table-action .lucide {
  height: 15px;
  width: 15px;
}

.app-footer {
  color: var(--muted);
  font-size: 0.72rem;
  padding: 24px 32px 36px;
  text-align: center;
}

.app-footer p {
  margin: 0;
}

.mobile-nav {
  display: none;
}

.app-toast {
  background: var(--text);
  border-radius: 7px;
  bottom: 22px;
  box-shadow: var(--shadow-menu);
  color: var(--surface);
  font-size: 0.82rem;
  font-weight: 750;
  left: 50%;
  max-width: min(90vw, 420px);
  opacity: 0;
  padding: 11px 15px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 1200;
}

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

@media (max-width: 900px) {
  .backtest-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .backtest-action {
    grid-column: 1 / -1;
  }
}

@media (max-width: 767px) {
  :root {
    --topbar-height: 56px;
  }

  html {
    scroll-padding-top: calc(var(--topbar-height) + 10px);
  }

  body {
    padding-bottom: calc(66px + env(safe-area-inset-bottom));
  }

  .topbar-inner {
    padding: 0 14px;
  }

  .desktop-nav {
    display: none;
  }

  .brand-mark {
    flex-basis: 30px;
    height: 30px;
  }

  .brand-name {
    font-size: 0.86rem;
  }

  .brand-subtitle {
    display: none;
  }

  .sync-status {
    display: none;
  }

  .icon-button {
    flex-basis: 40px;
    height: 40px;
    width: 40px;
  }

  .main-content {
    border: 0;
  }

  .workspace-section {
    min-height: calc(100vh - var(--topbar-height) - 62px);
    padding: 22px 14px;
  }

  .section-heading {
    margin-bottom: 16px;
  }

  .section-heading h1,
  .section-heading h2 {
    font-size: 1.08rem;
  }

  .market-section {
    overflow: hidden;
    padding-right: 0;
  }

  .market-section > .section-heading,
  .market-section > .section-meta {
    padding-right: 14px;
  }

  .market-score-grid {
    display: flex;
    gap: 10px;
    margin-right: 0;
    overflow-x: auto;
    padding-bottom: 4px;
    padding-right: 14px;
    scroll-padding-left: 0;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .market-score-grid::-webkit-scrollbar {
    display: none;
  }

  .market-score-card {
    flex: 0 0 min(84vw, 340px);
    padding: 15px;
    scroll-snap-align: start;
  }

  .home-summary-grid {
    grid-template-columns: 1fr;
    padding-right: 14px;
  }

  .home-summary-item {
    min-height: 82px;
    padding: 12px;
  }

  .score-number {
    font-size: 2rem;
  }

  .search-workspace {
    padding: 10px;
  }

  .search-primary {
    min-height: 52px;
  }

  .search-leading {
    flex-basis: 42px;
  }

  .ticker-input {
    font-size: 1rem;
    height: 50px;
  }

  .search-primary .primary-action {
    min-width: 76px;
    padding: 0 12px;
  }

  .search-primary .primary-action .lucide {
    display: none;
  }

  .search-options {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
  }

  .option-group {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

  .option-label {
    display: none;
  }

  .segmented-control {
    width: 100%;
  }

  .segmented-control button {
    min-height: 38px;
    padding: 0 6px;
  }

  .advanced-options summary {
    min-height: 32px;
  }

  .advanced-fields {
    left: 0;
    right: auto;
    width: 100%;
  }

  .analysis-loading {
    min-height: 150px;
  }

  .analysis-result {
    margin-top: 18px;
  }

  .stock-identity h3 {
    font-size: 1.08rem;
  }

  .secondary-action {
    flex: 0 0 44px;
    min-height: 40px;
    padding: 0;
    width: 44px;
  }

  .stock-summary .secondary-action span {
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
  }

  .stock-actions {
    gap: 6px;
  }

  .signal-strip {
    grid-template-columns: 1.25fr 1fr;
    margin-top: 14px;
  }

  .signal-primary,
  .signal-price {
    min-height: 90px;
    padding: 14px;
  }

  .signal-value-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .signal-value-row strong {
    font-size: 1.7rem;
  }

  .signal-price strong {
    font-size: 1.08rem;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card {
    min-height: 80px;
    padding: 12px;
  }

  .metric-card strong {
    font-size: 1.04rem;
  }

  .analysis-tabs {
    margin-top: 22px;
  }

  .tab-button {
    flex: 1;
    justify-content: center;
    padding: 0 8px;
  }

  .chart-frame {
    height: 310px;
    padding: 8px;
  }

  .chart-note {
    display: none;
  }

  .data-table-wrap {
    max-height: 430px;
  }

  .data-table {
    font-size: 0.76rem;
    width: 100%;
  }

  .data-table th,
  .data-table td {
    padding: 10px 9px;
  }

  .data-table th:first-child,
  .data-table td:first-child {
    left: 0;
    position: sticky;
    z-index: 1;
  }

  .data-table th:first-child {
    z-index: 3;
  }

  #dataPanel:not(.show-all-columns) .secondary-column {
    display: none;
  }

  .backtest-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px;
  }

  .backtest-form .field:nth-child(3) {
    grid-column: 1 / 2;
  }

  .switch-field {
    grid-column: 2 / 3;
  }

  .backtest-action {
    grid-column: 1 / -1;
    margin-top: 2px;
  }

  .result-heading {
    align-items: flex-end;
  }

  .condition-badge {
    max-width: 56%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .trade-table-wrap,
  .portfolio-table-wrap {
    display: none;
  }

  .trade-card-list,
  .portfolio-card-list {
    display: grid;
  }

  .trade-card-list {
    gap: 0;
  }

  .trade-card {
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 14px;
  }

  .trade-card:last-child {
    border-bottom: 0;
  }

  .trade-dates {
    color: var(--muted);
    font-size: 0.7rem;
  }

  .trade-prices {
    font-size: 0.82rem;
    font-weight: 750;
    margin-top: 4px;
  }

  .trade-profit {
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
    font-weight: 850;
    text-align: right;
  }

  .trade-amount {
    color: var(--muted);
    font-size: 0.7rem;
    margin-top: 4px;
    text-align: right;
  }

  .portfolio-card-list {
    gap: 8px;
  }

  .portfolio-card {
    align-items: center;
    background: var(--surface-subtle);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 13px;
  }

  .portfolio-code {
    color: var(--brand);
    font-size: 0.7rem;
    font-weight: 850;
  }

  .portfolio-name {
    font-size: 0.86rem;
    font-weight: 800;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .portfolio-values {
    align-items: flex-end;
    display: flex;
    flex-direction: column;
    gap: 3px;
  }

  .portfolio-price {
    color: var(--muted);
    font-size: 0.7rem;
  }

  .portfolio-expectation {
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
    font-weight: 850;
  }

  .portfolio-card-actions {
    display: flex;
    gap: 6px;
    grid-column: 1 / -1;
  }

  .portfolio-card-actions button {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    display: inline-flex;
    flex: 1;
    font-size: 0.74rem;
    font-weight: 800;
    gap: 6px;
    justify-content: center;
    min-height: 38px;
  }

  .portfolio-card-actions button.danger {
    color: var(--sell);
  }

  .portfolio-card-actions .lucide {
    height: 14px;
    width: 14px;
  }

  .app-footer {
    padding: 22px 14px 26px;
  }

  .mobile-nav {
    align-items: stretch;
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    border-top: 1px solid var(--line);
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: calc(62px + env(safe-area-inset-bottom));
    left: 0;
    padding-bottom: env(safe-area-inset-bottom);
    position: fixed;
    right: 0;
    z-index: 1100;
  }

  .mobile-nav a {
    align-items: center;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    font-size: 0.62rem;
    font-weight: 750;
    gap: 3px;
    justify-content: center;
    min-width: 0;
    text-decoration: none;
  }

  .mobile-nav a.active {
    color: var(--brand);
  }

  .mobile-nav .lucide {
    height: 19px;
    width: 19px;
  }

  .app-toast {
    bottom: calc(76px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 380px) {
  .search-primary .primary-action {
    min-width: 68px;
  }

  .segmented-control button {
    font-size: 0.7rem;
  }

  .signal-primary,
  .signal-price {
    padding: 11px;
  }

  .signal-value-row strong {
    font-size: 1.5rem;
  }

  .signal-badge {
    font-size: 0.65rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
