/* 시드봇 모니터링. 한국 시세 관례: 빨강 = 익절·수익, 파랑 = 매수·하락. */
:root {
  --paper: #edf0f3;
  --ink: #121b2e;
  --muted: #5a6577;
  --rule: #cbd2db;
  --up: #c5302a;
  --down: #1c54c4;
  --hold: #9a5b00;
  --panel: #101a30;
  --panel-ink: #e9edf4;
  --panel-muted: #94a1b8;
  --panel-rule: #2a3754;
  --panel-up: #ff7a70;
  --panel-down: #7fa9ff;
  --now: #ffd24a;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0a101d;
    --ink: #e6eaf2;
    --muted: #93a0b5;
    --rule: #232e45;
    --up: #ff7a70;
    --down: #7fa9ff;
    --hold: #e0a84a;
    --panel: #141f39;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
  word-break: keep-all;
}

h1,
h2,
p,
dl,
dd,
ol,
ul {
  margin: 0;
  padding: 0;
}

ol,
ul {
  list-style: none;
}

:focus-visible {
  outline: 3px solid var(--down);
  outline-offset: 2px;
}

.up {
  color: var(--up);
}

.down {
  color: var(--down);
}

/* 상단 */
.top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--rule);
}

.brand {
  font-weight: 800;
  letter-spacing: -0.02em;
}

.mode {
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 700;
  white-space: nowrap;
}

.mode-paper {
  color: var(--hold);
  box-shadow: inset 0 0 0 1.5px currentColor;
}

.mode-live {
  background: var(--up);
  color: #fff;
}

.asof {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: right;
}

@media (max-width: 30rem) {
  .top {
    flex-wrap: wrap;
    row-gap: 0.35rem;
  }

  .top .quiet {
    margin-left: auto;
  }

  .asof {
    order: 1;
    flex-basis: 100%;
    margin-left: 0;
    text-align: left;
  }
}

button {
  font: inherit;
  cursor: pointer;
}

.quiet {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font-size: 0.875rem;
}

.message {
  padding: 3rem clamp(1rem, 4vw, 2.5rem);
  color: var(--muted);
}

main#app {
  max-width: 76rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem) 4rem;
}

/* 상태 문장과 숫자 */
.status h1 {
  max-width: 22em;
  font-size: clamp(1.7rem, 1.1rem + 2.6vw, 2.75rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.subline {
  max-width: 40em;
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 1.0625rem;
}

.warning {
  max-width: 44em;
  margin-top: 1rem;
  padding: 0.7rem 0.9rem;
  border-left: 4px solid var(--up);
  background: color-mix(in srgb, var(--up) 9%, transparent);
  font-weight: 600;
}

.figures {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 2.5rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 2px solid var(--ink);
}

.figure dt {
  color: var(--muted);
  font-size: 0.875rem;
}

.figure dd {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.figure-main dd {
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.1rem);
  font-weight: 800;
  line-height: 1.2;
}

.scope {
  margin-top: 0.9rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

/* 본문 2단 */
.columns {
  display: grid;
  gap: 2.5rem;
  margin-top: 2.5rem;
}

@media (min-width: 62rem) {
  .columns {
    grid-template-columns: minmax(22rem, 5fr) 7fr;
    align-items: start;
    gap: 3.5rem;
  }

  .ladder {
    position: sticky;
    top: 1.5rem;
  }
}

h2 {
  font-size: 1.0625rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.side {
  display: grid;
  gap: 2.5rem;
  min-width: 0;
}

.side h2 {
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

.note {
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.875rem;
  max-width: 44em;
}

/* 매수 사다리: 이 화면의 중심 */
.ladder {
  padding: 1.5rem clamp(1.1rem, 3vw, 1.75rem) 1.6rem;
  border-radius: 14px;
  background: var(--panel);
  color: var(--panel-ink);
}

.seeds {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.1rem;
}

.seed-group {
  display: inline-flex;
  gap: 3px;
}

.seed {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1.5px var(--panel-muted);
}

.seed-on {
  background: var(--panel-down);
  box-shadow: none;
}

.seeds-text {
  margin-top: 0.5rem;
  color: var(--panel-muted);
  font-size: 0.875rem;
}

.rungs {
  position: relative;
  margin-top: 1.4rem;
}

/* 세로 레일 */
.rungs::before {
  content: '';
  position: absolute;
  top: 1.1rem;
  bottom: 1.1rem;
  left: 0.4375rem;
  width: 2px;
  background: var(--panel-rule);
}

.rung {
  position: relative;
  display: grid;
  grid-template-columns: 1rem 1fr auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0;
}

.rung-mark {
  position: relative;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: inset 0 0 0 2px var(--panel-muted);
}

.rung-body {
  display: grid;
  min-width: 0;
}

.rung-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
}

.rung-label .seed {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
}

.rung-detail {
  color: var(--panel-muted);
  font-size: 0.8125rem;
}

.rung-price {
  font-weight: 700;
  white-space: nowrap;
}

.rung-tp .rung-mark {
  background: var(--panel-up);
  box-shadow: none;
}

.rung-tp .rung-label,
.rung-tp .rung-price {
  color: var(--panel-up);
}

.rung-buy-done .rung-mark {
  background: var(--panel-down);
  box-shadow: none;
}

.rung-buy-next .rung-label,
.rung-buy-next .rung-price {
  color: var(--panel-down);
}

.rung-avg .rung-mark,
.rung-ma .rung-mark {
  border-radius: 2px;
  transform: rotate(45deg) scale(0.8);
}

/* 현재가: 사다리 위에서 지금 어디인지 */
.rung-now {
  margin: 0.25rem -0.6rem;
  padding: 0.6rem 0.6rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--now) 14%, transparent);
}

.rung-now .rung-mark {
  background: var(--now);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--now) 30%, transparent);
}

.rung-now .rung-label,
.rung-now .rung-price {
  color: var(--now);
  font-size: 1.125rem;
}

.ladder-note {
  margin-top: 0.75rem;
  color: var(--panel-muted);
  font-size: 0.875rem;
}

.ladder-note:empty,
.subline:empty {
  display: none;
}

/* 자산 추이 */
.chart {
  margin-top: 0.75rem;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-shadow {
  fill: none;
  stroke: var(--down);
  stroke-width: 7;
  stroke-linejoin: round;
  stroke-linecap: round;
  opacity: 0.28;
}

.chart-base {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 2 5;
}

.chart-text {
  fill: var(--muted);
  font-size: 12px;
}

/* 표 */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

th {
  padding: 0.6rem 0.75rem 0.4rem 0;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: left;
}

td {
  padding: 0.55rem 0.75rem 0.55rem 0;
  border-top: 1px solid var(--rule);
  vertical-align: top;
}

td:first-child {
  white-space: nowrap;
}

th:last-child,
td:last-child {
  padding-right: 0;
  text-align: right;
}

@media (max-width: 30rem) {
  table {
    font-size: 0.8125rem;
  }

  th,
  td {
    padding-right: 0.5rem;
  }
}

/* 알림 기록 */
.events li {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--rule);
  font-size: 0.9375rem;
}

@media (max-width: 30rem) {
  .events li {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}

.events li:first-child {
  border-top: 0;
}

.events time {
  color: var(--muted);
  font-size: 0.8125rem;
  padding-top: 0.1rem;
}

.events p {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* 로그인 */
.login-page {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: 1.5rem;
}

.login {
  width: min(100%, 22rem);
}

.login h1 {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.login-lead {
  margin-top: 0.4rem;
  color: var(--muted);
}

.login form {
  display: grid;
  margin-top: 1.75rem;
}

.login label {
  margin-top: 0.9rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.login input {
  margin-top: 0.3rem;
  padding: 0.7rem 0.8rem;
  border: 1.5px solid var(--rule);
  border-radius: 8px;
  background: color-mix(in srgb, var(--paper) 60%, #fff);
  color: var(--ink);
  font: inherit;
}

@media (prefers-color-scheme: dark) {
  .login input {
    background: #111a2e;
  }
}

.login button {
  margin-top: 1.4rem;
  padding: 0.8rem;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
}

.login button:disabled {
  opacity: 0.6;
  cursor: default;
}

.form-error {
  margin-top: 0.9rem;
  color: var(--up);
  font-weight: 600;
}

.login-note {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

@media (prefers-reduced-motion: no-preference) {
  .rung-now .rung-mark {
    animation: pulse 2.4s ease-out infinite;
  }

  @keyframes pulse {
    0% {
      box-shadow: 0 0 0 0 color-mix(in srgb, var(--now) 55%, transparent);
    }
    100% {
      box-shadow: 0 0 0 10px transparent;
    }
  }
}
