/* hoga-bot UI — 밝은 배경, 검은 글자, 큰 글씨 */

:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --card-2: #f6f8fa;
  --line: #d7dce3;
  --line-2: #e8ecf1;
  --text: #000000;          /* 본문은 전부 검정 */
  --dim: #000000;
  --faint: #3d4552;         /* 꼭 낮춰야 할 때만 진한 회색 */
  --up: #067647;
  --up-bg: #e3f5ec;
  --down: #c01c12;
  --down-bg: #fdeceb;
  --accent: #1a4fd6;
  --accent-bg: #e6edff;
  --warn: #8a5300;
  --warn-bg: #fdf0d5;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --radius: 12px;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --card: #171d26;
  --card-2: #1e242e;
  --line: #303845;
  --line-2: #252c37;
  --text: #ffffff;
  --dim: #ffffff;
  --faint: #c3ccd8;
  --up: #4ade80;
  --up-bg: rgba(74,222,128,.14);
  --down: #ff7b72;
  --down-bg: rgba(255,123,114,.14);
  --accent: #79b0ff;
  --accent-bg: rgba(121,176,255,.16);
  --warn: #f0b429;
  --warn-bg: rgba(240,180,41,.14);
  --shadow: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* 어떤 요소가 삐져나와도 화면이 옆으로 밀리지 않게 한다 */
html, body { max-width: 100%; overflow-x: hidden; }

body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}

/* ── 레이아웃 ─────────────────────────────── */
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 18px 110px; }

header {
  position: sticky; top: 0; z-index: 40;
  background: var(--card); border-bottom: 2px solid var(--line); padding: 12px 0;
  margin-bottom: 20px;
}
.header-in { max-width: 1280px; margin: 0 auto; padding: 0 18px;
             display: flex; align-items: center; gap: 14px; }
.brand { font-weight: 800; font-size: 19px; color: var(--text); }
.brand span { color: var(--faint); font-weight: 600; margin-left: 8px; font-size: 14px; }
.spacer { flex: 1; }

.tabs { display: flex; gap: 3px; background: var(--card-2); padding: 4px; border-radius: 10px; }
.tab { border: none; background: none; color: var(--text);
       padding: 9px 18px; border-radius: 8px; font-size: 16px; font-weight: 700;
       cursor: pointer; font-family: inherit; white-space: nowrap; opacity: .62; }
.tab.on { background: var(--card); opacity: 1; box-shadow: var(--shadow); }

.icon-btn { border: 2px solid var(--line); background: var(--card); color: var(--text);
            width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
            display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }

.grid { display: grid; gap: 16px; }
/* 격자 칸의 기본 min-width 는 auto 라, 안쪽 입력칸이 넓으면 칸을 밀어내
   옆 칸을 덮어버린다. 0으로 눌러야 칸 밖으로 새지 않는다. */
.grid > * { min-width: 0; }
.grid.two { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
.grid.side { grid-template-columns: minmax(0,430px) minmax(0,1fr); align-items: start; }

.card { background: var(--card); border: 1px solid var(--line);
        border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
        min-width: 0; overflow-wrap: anywhere; }
.card h3 { margin: 0 0 14px; font-size: 15px; font-weight: 800; color: var(--text); }
.card h3 small { font-weight: 600; color: var(--faint); margin-left: 8px; font-size: 13px; }

/* ── 배지 ─────────────────────────────────── */
.pill { font-size: 14px; font-weight: 800; padding: 5px 12px; border-radius: 999px;
        background: var(--card-2); color: var(--text);
        display: inline-flex; align-items: center; gap: 7px; }
.pill.on   { background: var(--up-bg);     color: var(--up); }
.pill.hold { background: var(--warn-bg);   color: var(--warn); }
.pill.info { background: var(--accent-bg); color: var(--accent); }
.pill.off  { background: var(--card-2);    color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.dot.live { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.25} }

.status-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }

/* 거래소 전환 — 두 거래소는 완전히 분리된 화면이다 */
.exbar { display: flex; gap: 8px; margin-bottom: 16px; }
.ex-btn { display: flex; align-items: center; gap: 8px; padding: 12px 20px;
          border: 2px solid var(--line); background: var(--card); color: var(--text);
          border-radius: 11px; cursor: pointer; font-family: inherit;
          font-size: 16px; font-weight: 700; }
.ex-btn:hover { background: var(--card-2); }
.ex-btn.on { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
.ex-name { font-weight: 800; }
.ex-quote { font-size: 13px; font-weight: 700; color: var(--faint); }
.ex-btn.on .ex-quote { color: var(--accent); }
.ex-run { width: 9px; height: 9px; border-radius: 50%; background: var(--up);
          animation: pulse 1.6s ease-in-out infinite; }

/* ── 포지션 목록 ──────────────────────────── */
.pos { display: flex; flex-direction: column; gap: 10px; }
.pos-item { background: var(--card); border: 2px solid var(--line);
            border-radius: 11px; padding: 14px 16px; cursor: pointer; }
.pos-item.held { border-color: var(--up); background: var(--up-bg); }
.pos-item.sel  { border-color: var(--accent); }
.pos-head { display: flex; align-items: baseline; gap: 10px; }
.pos-sym { font-size: 18px; font-weight: 800; color: var(--text); }
.pos-sym small { font-size: 13px; font-weight: 700; color: var(--faint); }
.pos-price { margin-left: auto; font-size: 18px; font-weight: 800;
             font-variant-numeric: tabular-nums; color: var(--text); }
.pos-line { display: flex; gap: 18px; margin-top: 8px; font-size: 15px; font-weight: 600;
            flex-wrap: wrap; }
.pos-line b { font-weight: 800; font-variant-numeric: tabular-nums; }
.pos-tag { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 6px;
           background: var(--accent-bg); color: var(--accent); }
.pos-detail { margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--line); }

.metrics { display: grid; grid-template-columns: repeat(auto-fit,minmax(130px,1fr)); gap: 2px;
           background: var(--line-2); border-radius: 10px; overflow: hidden; }
.metric { background: var(--card); padding: 12px 14px; }
.metric .k { font-size: 13px; color: var(--faint); font-weight: 700; margin-bottom: 3px; }
.metric .v { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums;
             color: var(--text); }

/* ── 알림 ─────────────────────────────────── */
.alert-row { display: flex; gap: 12px; align-items: center; padding: 11px 0;
             border-bottom: 1px solid var(--line-2); font-size: 15px; font-weight: 600; }
.alert-row:last-child { border-bottom: none; }
.alert-kind { font-size: 13px; font-weight: 800; padding: 3px 9px; border-radius: 6px;
              background: var(--up-bg); color: var(--up); }

/* ── 폼 ───────────────────────────────────── */
.field { display: flex; align-items: center; gap: 10px; padding: 11px 12px;
         border-radius: 10px; cursor: pointer; border: 2px solid transparent;
         min-width: 0; }
.field:hover { background: var(--card-2); }
.field.sel { background: var(--accent-bg); border-color: var(--accent); }
.field label { flex: 1 1 auto; min-width: 0; font-size: 16px; color: var(--text);
               font-weight: 700; cursor: pointer; }
.field .ov { font-size: 12px; font-weight: 800; padding: 2px 7px; border-radius: 5px;
             background: var(--warn-bg); color: var(--warn); }

input[type="text"], input[type="number"], select {
  background: var(--card); border: 2px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 9px 11px; font-size: 17px; font-weight: 700;
  width: 118px; min-width: 0; max-width: 100%; flex: 0 0 auto;
  text-align: right; font-variant-numeric: tabular-nums; font-family: inherit;
}
select { text-align: left; width: 140px; }
input:focus, select:focus { outline: 3px solid var(--accent); outline-offset: -1px; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); transform: scale(1.4); }
input::placeholder { color: var(--faint); }

.group-title { font-size: 14px; font-weight: 800; color: var(--text);
               margin: 20px 0 6px; padding: 0 12px; }
.group-title:first-child { margin-top: 0; }

button.act { border: none; border-radius: 10px; padding: 14px 18px; font-size: 17px;
             font-weight: 800; cursor: pointer; font-family: inherit; flex: 1; }
button.act:disabled { opacity: .4; cursor: not-allowed; }
.b-start { background: var(--up); color: #fff; }
.b-stop  { background: var(--card-2); color: var(--text); border: 2px solid var(--line); }
.b-panic { background: var(--down); color: #fff; }
.b-save  { background: var(--accent); color: #fff; }
.b-ghost { background: var(--card); color: var(--text); border: 2px solid var(--line); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── 종목 고르기 ──────────────────────────── */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 80;
            display: grid; place-items: center; padding: 16px; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 560px;
         max-height: 82vh; display: flex; flex-direction: column; overflow: hidden;
         border: 2px solid var(--line); }
.modal-head { padding: 16px 18px; border-bottom: 2px solid var(--line); display: flex; gap: 10px; }
.modal-head input { flex: 1; width: auto; text-align: left; font-size: 17px; }
.modal-body { overflow-y: auto; padding: 8px; }
.mk-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; width: 100%;
          border: none; background: none; cursor: pointer; border-radius: 9px;
          font-family: inherit; font-size: 16px; color: var(--text); text-align: left; }
.mk-row:hover { background: var(--card-2); }
.mk-row.added { opacity: .45; }
.mk-sym { font-weight: 800; flex: 1; }
.mk-vol { font-size: 13px; font-weight: 700; color: var(--faint); }
.mk-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.mk-chg { font-weight: 800; min-width: 74px; text-align: right;
          font-variant-numeric: tabular-nums; }

.pos-item.on { border-color: var(--up); }
.pos-item.held { border-color: var(--warn); background: var(--warn-bg); }
.dot.off { background: var(--faint) !important; }

button.act.mini { flex: 0 0 auto; padding: 7px 15px; font-size: 15px; }

.hold-item { background: var(--card); border: 2px solid var(--warn);
             border-radius: 11px; padding: 15px 16px; margin-bottom: 12px; }
.hold-item:last-child { margin-bottom: 0; }

/* 종목별 개별 설정 목록 */
.ov-row { display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0;
          padding: 12px 14px; border: 2px solid var(--line); background: var(--card);
          border-radius: 10px; margin-bottom: 8px; cursor: pointer;
          font-family: inherit; color: var(--text); text-align: left; }
.ov-row:hover { background: var(--card-2); }
.ov-row.sel { border-color: var(--accent); background: var(--accent-bg); }
.ov-sym { font-size: 16px; font-weight: 800; }
.ov-keys { font-size: 14px; font-weight: 600; color: var(--faint);
           min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 매수금액 환산 표시 */
.conv { font-size: 14px; font-weight: 700; color: var(--faint);
        white-space: nowrap; margin-left: 4px; }

/* 이력 한 줄 흐름 */
.flow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
        padding: 12px 0; border-bottom: 1px solid var(--line-2); font-size: 15px; }
.flow:last-child { border-bottom: none; }
.flow-when { font-size: 13px; font-weight: 700; color: var(--faint);
             font-variant-numeric: tabular-nums; min-width: 92px; }
.flow-sym { font-size: 16px; font-weight: 800; min-width: 96px; }
.flow-step { font-weight: 700; font-variant-numeric: tabular-nums;
             background: var(--card-2); padding: 3px 10px; border-radius: 7px; }
.flow-step.buy { background: var(--accent-bg); color: var(--accent); }
.flow-arrow { color: var(--faint); font-weight: 800; }
.flow-pnl { margin-left: auto; font-weight: 800; font-size: 16px;
            font-variant-numeric: tabular-nums; }

/* 매수금액 — 설정 목록과 분리해 아래에 크게 */
.amount-card { margin-top: 18px; padding: 16px; border: 2px solid var(--accent);
               border-radius: 11px; background: var(--accent-bg); }
.amount-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.amount-title { font-size: 16px; font-weight: 800; flex: 1; }
.cur-toggle { display: flex; gap: 2px; background: var(--card); padding: 3px;
              border-radius: 9px; border: 1px solid var(--line); }
.cur-btn { border: none; background: none; color: var(--text); padding: 6px 14px;
           border-radius: 7px; font-size: 14px; font-weight: 700; cursor: pointer;
           font-family: inherit; opacity: .55; }
.cur-btn.on { background: var(--accent); color: #fff; opacity: 1; }
.amount-input { display: flex; align-items: center; gap: 10px; }
.amount-input input { flex: 1 1 auto; width: auto; min-width: 0; font-size: 24px;
                      padding: 11px 13px; text-align: right; }
.amount-unit { font-size: 18px; font-weight: 800; min-width: 54px; }
.amount-conv { margin-top: 9px; font-size: 15px; font-weight: 700; color: var(--text);
               display: flex; align-items: baseline; gap: 10px; }
.amount-fx { font-size: 13px; font-weight: 600; color: var(--faint); margin-left: auto; }

/* 좁은 화면용 서브탭 — 넓은 화면에서는 감춘다 */
.subtabs { display: none; gap: 3px; background: var(--card-2); padding: 4px;
           border-radius: 10px; margin-bottom: 14px; }
.subtab { flex: 1; border: none; background: none; color: var(--text);
          padding: 10px 14px; border-radius: 8px; font-size: 16px; font-weight: 700;
          cursor: pointer; font-family: inherit; opacity: .6; }
.subtab.on { background: var(--card); opacity: 1; box-shadow: var(--shadow); }

/* 고른 항목 설명 — 그래프 바로 위 */
.field-desc { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
              font-size: 15px; font-weight: 600; color: var(--text);
              background: var(--card-2); border-left: 4px solid var(--accent);
              padding: 11px 14px; border-radius: 0 9px 9px 0; margin-bottom: 14px; }
.field-desc:empty { display: none; }
.field-desc b { font-size: 15px; font-weight: 800; white-space: nowrap; }
.field-desc b::after { content: " :"; color: var(--faint); }

.ip-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.ip-value { flex: 1; font-size: 24px; font-weight: 800; letter-spacing: .02em;
            font-variant-numeric: tabular-nums; padding: 12px 16px;
            background: var(--card-2); border-radius: 10px; text-align: center; }

/* ── 다이어그램 ───────────────────────────── */
.sticky-side { position: sticky; top: 84px; min-width: 0; z-index: 1; }
.diagram { width: 100%; height: auto; display: block; max-width: 100%; }
.diagram text { font-family: inherit; font-size: 14px; font-weight: 700; fill: var(--text); }
.diagram .axis { stroke: var(--line); stroke-width: 1.5; }
.diagram .price-path { fill: none; stroke: var(--faint); stroke-width: 2.4; }
.diagram .dim { opacity: .25; }
.diagram * { transition: opacity .3s, y .45s cubic-bezier(.4,0,.2,1), y1 .45s, y2 .45s,
             cy .45s, height .45s, x .45s, width .45s; }
.diagram-title { font-size: 17px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.diagram-sub { font-size: 14px; font-weight: 600; color: var(--faint); margin-bottom: 12px; }

/* ── 이력 ─────────────────────────────────── */
.hist-row { display: flex; align-items: center; gap: 12px; padding: 12px 0;
            border-bottom: 1px solid var(--line-2); font-size: 15px; font-weight: 600; }
.hist-row:last-child { border-bottom: none; }
.hist-tag { font-size: 13px; font-weight: 800; padding: 3px 9px; border-radius: 6px;
            background: var(--card-2); color: var(--text); }
.hist-pnl { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }

.up { color: var(--up); } .down { color: var(--down); }
.muted { color: var(--faint); }
.note { font-size: 14px; font-weight: 600; color: var(--faint); margin-top: 10px; }

.banner { background: var(--down-bg); border: 2px solid var(--down); color: var(--down);
          padding: 13px 16px; border-radius: 11px; font-size: 16px; font-weight: 700;
          margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.banner.info { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.banner b { display: block; margin-bottom: 3px; font-size: 16px; }
.banner-x { margin-left: auto; flex: 0 0 auto; align-self: flex-start;
            border: none; background: none; color: inherit; cursor: pointer;
            font-size: 18px; font-weight: 800; line-height: 1;
            padding: 2px 6px; border-radius: 6px; opacity: .7; font-family: inherit; }
.banner-x:hover { opacity: 1; background: rgba(0,0,0,.08); }

.toast { position: fixed; left: 50%; transform: translateX(-50%) translateY(12px);
         bottom: 26px; background: #111; color: #fff; padding: 13px 22px; border-radius: 11px;
         font-size: 16px; font-weight: 700; opacity: 0; transition: all .22s;
         pointer-events: none; z-index: 90; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--down); }

code { background: var(--card-2); padding: 2px 7px; border-radius: 5px;
       font-size: 15px; font-weight: 700;
       font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ── 모바일 ───────────────────────────────── */
@media (max-width: 900px) {
  body { font-size: 17px; }
  .subtabs { display: flex; }
  .exbar { gap: 6px; }
  .ex-btn { flex: 1; justify-content: center; padding: 11px 8px; font-size: 15px; }
  .grid.two, .grid.side { grid-template-columns: 1fr; }
  .sticky-side { position: static; }
  .wrap { padding: 0 12px 40px; }
  .card { padding: 15px 14px; }

  /* 헤더 — 이름과 테마 버튼이 윗줄, 탭은 아랫줄 전체 폭 */
  header { padding: 10px 0 8px; margin-bottom: 14px; }
  .header-in { flex-wrap: wrap; row-gap: 9px; padding: 0 12px; gap: 8px; }
  .brand { font-size: 17px; white-space: nowrap; }
  .tabs { order: 3; width: 100%; }
  .tab { flex: 1; padding: 10px 6px; font-size: 15px; text-align: center; }
  .subtab { padding: 10px 8px; font-size: 15px; }
}

/* 좁은 화면에서는 이름과 입력칸을 두 줄로 나눈다.
   한 줄에 넣으면 긴 라벨이 입력칸을 화면 밖으로 밀어낸다. */
@media (max-width: 620px) {
  .field { flex-wrap: wrap; row-gap: 9px; padding: 12px; }
  .field label { flex: 1 1 100%; }
  .field .ov { order: 2; }
  .field input[type="text"], .field input[type="number"], .field select {
    flex: 1 1 auto; width: auto; min-width: 120px;
  }
  .field input[type="checkbox"] { flex: 0 0 auto; margin-left: auto; }

  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos-head { flex-wrap: wrap; row-gap: 4px; }
  .pos-price { font-size: 17px; }
  .amount-input input { font-size: 21px; }
  .flow { row-gap: 6px; }
  .flow-when { min-width: 78px; font-size: 12px; }
  .flow-sym { min-width: auto; }
  .flow-pnl { margin-left: auto; }
  .modal-head { flex-wrap: wrap; }
  .modal-head input { min-width: 0; }
}

@media (min-width: 901px) { .subtabs { display: none; } }
