:root {
  --bg: #dde3d9;
  --card: #f9f8f0;
  --card-short: #ede4e4;
  --bg-box: #ffffff;
  --bg-box-border: rgba(0, 0, 0, 0.06);
  --bg-tag: rgba(255, 255, 255, 0.7);
  --border: rgba(0, 0, 0, 0.08);
  --text: #1a1a1a;
  --muted: #6b7280;
  --accent: #68d6bd;
  --accent-strong: #137f68;
  --long: #1d9e75;
  --short: #d85a30;
  --warn: #d8a83e;
  --cream: #ffffff;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 14px;
  --status-ok-text: #1A6E4B;
  --status-ok-bg: #DCEFE6;
  --status-run-text: #1F5FA6;
  --status-run-bg: #E2EDF8;
  --status-warn-text: #9A6800;
  --status-warn-bg: #F8EFD6;
  --status-err-text: #B23A3A;
  --status-err-bg: #F8E3E3;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(104, 214, 189, 0.20), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.topbar,
.filter-bar,
.candidate-card,
.empty-state,
.skeleton-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  margin-bottom: 16px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 18px;
  background: #1a1a1a;
  color: var(--accent);
  font-size: 18px;
  font-weight: 800;
}

.title-block {
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
  font-weight: 700;
}

.status-strip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.muted,
.connection-note {
  color: var(--muted);
}

.status-label {
  font-size: 11px;
  font-weight: 700;
}

.pill,
.chip,
.badge,
.zone-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}

.pill {
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  background: var(--cream);
  color: var(--text);
  font-size: 11px;
}

.pill.live {
  border-color: rgba(104, 214, 189, 0.42);
  background: #e4fff7;
  color: var(--accent-strong);
}

.filter-bar {
  display: block;
  padding: 12px;
  margin-bottom: 16px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.filter-divider {
  width: 1px;
  height: 24px;
  margin: 0 3px;
  background: rgba(0, 0, 0, 0.12);
}

.chip {
  min-height: 32px;
  padding: 7px 13px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.58);
  color: #4b5563;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.chip:hover,
.chip:focus-visible {
  border-color: rgba(19, 127, 104, 0.28);
  outline: none;
}

.chip.active {
  background: #1a1a1a;
  color: #ffffff;
  border-color: #1a1a1a;
}

.timeframe-filter-chip.active,
.direction-filter-chip.active {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.content-grid {
  display: block;
}

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

.candidate-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 18px;
  min-height: 214px;
  padding: 16px;
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.candidate-card.dir-short {
  background: var(--card-short);
}

.candidate-card:hover,
.candidate-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(19, 127, 104, 0.34);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  outline: none;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.symbol {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-line {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.zone-chip {
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  background: var(--bg-tag);
  color: #4b5563;
  font-size: 11px;
}

.zone-chip.long {
  color: #0f6d51;
  background: rgba(29, 158, 117, 0.12);
  border-color: rgba(29, 158, 117, 0.18);
}

.zone-chip.short {
  color: #9b341c;
  background: rgba(216, 90, 48, 0.12);
  border-color: rgba(216, 90, 48, 0.18);
}

.card-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.status-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.status-main.live {
  color: var(--status-ok-text);
}

.status-main.approach {
  color: var(--status-run-text);
}

.status-main.waiting {
  color: #667085;
}

.status-icon {
  font-size: 18px;
  line-height: 1;
}

.zone-range {
  align-self: center;
  color: #111827;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.lifecycle-badge {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--status-warn-bg);
  color: var(--status-warn-text);
  font-size: 12px;
  font-weight: 800;
}

.lifecycle-badge.live {
  color: var(--status-ok-text);
  background: var(--status-ok-bg);
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.state-flags {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.flag {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  color: #475467;
}

.flag.approach {
  color: var(--status-warn-text);
  background: var(--status-warn-bg);
}

.flag.touched {
  color: var(--status-err-text);
  background: var(--status-err-bg);
}

.ob-stars {
  color: #111827;
  font-size: 17px;
  line-height: 1;
}

.empty-state {
  display: none;
  padding: 40px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
}

.empty-state.show {
  display: block;
}

.skeleton-card {
  min-height: 214px;
  padding: 16px;
}

.skeleton-line,
.skeleton-block {
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.35));
  background-size: 220% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.skeleton-line {
  height: 16px;
  margin-bottom: 12px;
}

.skeleton-line--lg {
  width: 48%;
}

.skeleton-line--md {
  width: 72%;
}

.skeleton-line--sm {
  width: 38%;
}

.skeleton-block {
  height: 128px;
  border-radius: var(--radius-md);
}

body.pattern-detail-open {
  overflow: hidden;
}

.pattern-detail-modal[hidden] {
  display: none;
}

.pattern-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
}

.pattern-detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.34);
  backdrop-filter: blur(7px);
  animation: pattern-detail-fade 180ms ease both;
}

.pattern-detail-sheet {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  width: min(940px, 100%);
  max-height: min(88vh, 840px);
  overflow: auto;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 24px;
  background: #fbfaf3;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
  color: var(--text);
  outline: none;
  animation: pattern-detail-sheet-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.pattern-detail-head {
  position: sticky;
  top: -18px;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin: -18px -18px 0;
  padding: 18px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(251, 250, 243, 0.82);
  backdrop-filter: blur(18px);
}

.pattern-detail-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pattern-detail-head h2 {
  margin: 0;
  color: #111827;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

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

.pattern-detail-close {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.70);
  color: #111827;
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.pattern-detail-section {
  padding: 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.66);
}

.pattern-detail-section h3 {
  margin: 0 0 10px;
  color: #111827;
  font-size: 13px;
  font-weight: 700;
}

.pattern-chart-section {
  overflow: hidden;
}

.pattern-chart-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 10px;
  background: #111827;
}

.pattern-chart {
  display: block;
  width: 100%;
  min-width: 720px;
  min-height: 560px;
  height: auto;
}

.pattern-chart-bg {
  fill: #111827;
}

.pattern-chart-grid line {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.pattern-chart-grid text,
.zone-chart-label,
.zone-price-label {
  fill: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pattern-candle line {
  stroke-width: 1.2;
}

.pattern-candle.up line,
.pattern-candle.up rect {
  stroke: #34d399;
  fill: #34d399;
}

.pattern-candle.down line,
.pattern-candle.down rect {
  stroke: #fb7185;
  fill: #fb7185;
}

.zone-box {
  stroke-width: 1;
}

.zone-box.long {
  fill: rgba(34, 197, 94, 0.20);
  stroke: rgba(56, 189, 248, 0.9);
}

.zone-box.short {
  fill: rgba(239, 68, 68, 0.22);
  stroke: rgba(248, 113, 113, 0.9);
}

.zone-edge {
  stroke-width: 1;
}

.zone-edge.long {
  stroke: rgba(187, 247, 208, 0.95);
}

.zone-edge.short {
  stroke: rgba(254, 202, 202, 0.95);
}

.zone-price-line {
  stroke-width: 1.2;
  stroke-dasharray: 5 7;
}

.zone-price-line.invalid {
  stroke: #f97316;
}

.zone-price-line.val {
  stroke: #22c55e;
  opacity: 0.68;
}

.zone-price-line.current {
  stroke: rgba(229, 231, 235, 0.68);
}

.zone-leg-line {
  fill: none;
  stroke: #facc15;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.zone-chart-label-box {
  fill: rgba(17, 24, 39, 0.86);
  stroke: rgba(255, 255, 255, 0.16);
  stroke-width: 1;
}

.pattern-chart-state {
  display: grid;
  min-height: 280px;
  place-items: center;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-weight: 700;
}

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

.detail-metric {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.58);
}

.detail-metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.detail-metric strong {
  color: #111827;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

@keyframes shimmer {
  to {
    background-position: -220% 0;
  }
}

@keyframes pattern-detail-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pattern-detail-sheet-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 1240px);
    padding-top: 10px;
  }

  .topbar {
    border-radius: var(--radius-lg);
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 15px;
  }

  .candidate-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    overflow-x: auto;
  }

  .filter-row {
    flex-wrap: nowrap;
  }

  .chip {
    flex: 0 0 auto;
  }

  .pattern-detail-modal {
    padding: 0;
  }

  .pattern-detail-sheet {
    width: 100%;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

  .pattern-detail-head {
    display: grid;
  }
}
