    
:root {
  --bg: #f4f7fb;
  --bg-accent: #eef4ff;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --text: #0f172a;
  --text-strong: #0b1220;
  --muted: #5f6f89;
  --muted-soft: #94a3b8;
  --line: #dbe4f0;
  --line-strong: #c7d4e5;
  --primary: #2f6fed;
  --primary-strong: #1d4ed8;
  --primary-soft: #e8f0ff;
  --primary-soft-strong: #d7e7ff;
  --buy: #d92d20;
  --buy-soft: #fef0ef;
  --sell: #2563eb;
  --sell-soft: #edf4ff;
  --profit: #d92d20;
  --profit-soft: #fef0ef;
  --danger: #9a3412;
  --danger-soft: #fff7ed;
  --loss: #2563eb;
  --loss-soft: #edf4ff;
  --warn: #d97706;
  --warn-soft: #fff7ed;
  --ok: #0f766e;
  --ok-soft: #ecfdf3;
  --slate-soft: #f2f5f9;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  --shadow-strong: 0 18px 42px rgba(15, 23, 42, 0.12);
  --radius: 18px;
  --tabbar-h: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

    * { box-sizing: border-box; }
    html, body {
      margin: 0;
      padding: 0;
      background: linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%);
      color: var(--text);
      font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Segoe UI", sans-serif;
    }
    body { -webkit-font-smoothing: antialiased; }
    button, input, textarea, select { font: inherit; }
    button { border: 0; background: none; color: inherit; cursor: pointer; }
    input, textarea, select {
      width: 100%;
      border: 1px solid var(--line-strong);
      border-radius: 14px;
      padding: 14px 16px;
      background: var(--panel);
      color: var(--text);
      outline: none;
    }
    input:focus, textarea:focus, select:focus {
      border-color: var(--primary);
      box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.14);
    }
    textarea { min-height: 108px; resize: vertical; }
    input, textarea, select, .btn, .chip, .icon-btn, .schedule-chip, .tab { transition: 0.18s ease; }
    input::placeholder, textarea::placeholder { color: var(--muted-soft); opacity: 1; }

    .app {
      max-width: 520px;
      margin: 0 auto;
      min-height: 100dvh;
      background: linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%);
      position: relative;
    }

    .screen {
      display: none;
      min-height: 100dvh;
      padding: calc(var(--safe-top) + 16px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 18px);
    }
    .screen.active { display: block; }

    .header-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 16px;
    }
    .title {
      margin: 0;
      font-size: 28px;
      font-weight: 800;
      letter-spacing: -0.02em;
    }
    .subtitle {
      margin: 6px 0 0;
      color: var(--muted);
      font-size: 14px;
    }

    .row {
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .wrap { flex-wrap: wrap; }
    .space {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
    }
    .stack-8 > * + * { margin-top: 8px; }
    .stack-10 > * + * { margin-top: 10px; }
    .stack-12 > * + * { margin-top: 12px; }

    .card {
      background: var(--panel);
      border: 1px solid rgba(208, 213, 221, 0.72);
      border-radius: var(--radius);
      padding: 16px;
      box-shadow: var(--shadow);
      margin-bottom: 12px;
    }
    .clickable { cursor: pointer; }
    .divider {
      height: 1px;
      background: var(--line);
      margin: 14px 0;
    }

    .section-title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin: 18px 0 12px;
    }
    .section-title h2 {
      margin: 0;
      font-size: 17px;
      font-weight: 800;
    }
    .section-title span,
    .small, .tiny, .muted {
      color: var(--muted);
    }
    .small { font-size: 13px; }
    .tiny { font-size: 12px; }
    .mono { font-variant-numeric: tabular-nums; }

    .icon-btn {
      width: 40px;
      height: 40px;
      border-radius: 12px;
      background: var(--panel);
      border: 1px solid var(--line-strong);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      flex: 0 0 auto;
    }
    .icon-glyph { font-size: 20px; line-height: 1; }
    .ui-icon {
      width: 18px;
      height: 18px;
      display: block;
    }
    .icon-btn.is-active {
      background: var(--primary-soft);
      border-color: var(--primary);
      color: var(--primary);
    }

    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-height: 46px;
      border-radius: 14px;
      padding: 0 16px;
      border: 1px solid transparent;
      font-weight: 700;
      width: 100%;
    }
    .btn.primary {
      background: linear-gradient(180deg, var(--primary) 0%, var(--primary-strong) 100%);
      color: #fff;
      box-shadow: 0 10px 20px rgba(47, 111, 237, 0.18);
    }
    .btn.secondary {
      background: linear-gradient(180deg, var(--primary-soft) 0%, #dce9ff 100%);
      color: var(--primary-strong);
      border-color: rgba(47, 111, 237, 0.12);
      box-shadow: inset 0 0 0 1px rgba(47, 111, 237, 0.04);
    }
    .btn.ghost {
      background: var(--panel);
      border-color: var(--line);
      color: var(--text);
    }
    .btn.danger {
      background: var(--danger);
      color: #fff;
    }
    .btn.text {
      width: auto;
      min-height: auto;
      padding: 0;
      border: 0;
      color: var(--primary);
      background: transparent;
      font-weight: 700;
    }
    .btn:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }

    .chip-group {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-bottom: 12px;
    }
    .chip {
      padding: 10px 14px;
      border-radius: 999px;
      background: var(--panel);
      border: 1px solid var(--line-strong);
      color: var(--text);
      font-weight: 700;
      white-space: nowrap;
    }
    .chip.active {
      background: var(--primary);
      border-color: var(--primary);
      color: #fff;
      box-shadow: 0 6px 14px rgba(47, 111, 237, 0.18);
    }

    .badge {
      display: inline-flex;
      align-items: center;
      height: 30px;
      border-radius: 999px;
      padding: 0 12px;
      font-size: 12px;
      font-weight: 800;
      white-space: nowrap;
    }
    .badge.tag { background: var(--slate-soft); color: #475467; }
    .badge.keep { background: #ecfdf3; color: #027a48; }
    .badge.shaky { background: #fff7ed; color: #c2410c; }
    .badge.invalid { background: var(--slate-soft); color: #475467; }
    .badge.hold { background: #f5f5f5; color: #344054; }
    .badge.watch { background: #eef2ff; color: #4338ca; }
    .badge.closed { background: var(--slate-soft); color: #475467; }
    .badge.buy { background: var(--buy-soft); color: var(--buy); }
    .badge.sell { background: var(--sell-soft); color: var(--sell); }
    .badge.holdings { background: #eef2ff; color: #3730a3; }
    .badge.totalcost { background: #f5f3ff; color: #6d28d9; }
    .badge.avgprice { background: var(--slate-soft); color: #475467; }
    .badge.earned { background: var(--profit-soft); color: var(--profit); }
    .badge.due-pre { background: var(--sell-soft); color: var(--sell); }
    .badge.due-today { background: #fff7ed; color: #c2410c; }
    .badge.due-soon { background: var(--warn-soft); color: var(--warn); }
    .badge.due-late { background: #f5f3ff; color: #7c3aed; }
    .badge.favorite-badge { background: #fff7ed; color: #b45309; }

    .metric-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }
    .metric {
      border: 1px solid var(--line-strong);
      border-radius: 14px;
      padding: 12px;
      background: var(--panel);
    }
    .metric .v {
      margin-top: 6px;
      font-size: 18px;
      font-weight: 800;
    }

    .search-box {
      position: relative;
      margin-bottom: 10px;
    }
    .search-icon {
      position: absolute;
      left: 14px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--muted);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      pointer-events: none;
    }
    .search-box input {
      padding-left: 40px;
    }

    .list-item {
      padding: 12px 0;
      border-bottom: 1px solid var(--line);
    }
    .list-item:last-child { border-bottom: 0; }

    .note-line {
      line-height: 1.55;
      white-space: pre-wrap;
      word-break: break-word;
    }

    .pnl-row {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 10px;
    }
    .pnl-profit, .pnl-rate {
      display: inline-flex;
      align-items: center;
      min-height: 30px;
      border-radius: 999px;
      padding: 0 12px;
      font-size: 12px;
      font-weight: 800;
    }
    .pnl-positive {
      background: var(--profit-soft);
      color: var(--profit);
    }
    .pnl-negative {
      background: var(--loss-soft);
      color: var(--loss);
    }
    .pnl-neutral {
      background: var(--slate-soft);
      color: #475467;
    }

    .fields > * + * { margin-top: 12px; }
    .field label {
      display: block;
      margin-bottom: 8px;
      font-size: 13px;
      color: var(--muted);
      font-weight: 700;
    }
    .field.two {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }
    .inline-field {
      display: grid;
      grid-template-columns: 1fr 108px;
      gap: 8px;
    }

    .warning-box, .danger-box, .ok-box {
      border-radius: 14px;
      padding: 14px;
      font-size: 14px;
      line-height: 1.5;
    }
    .warning-box { background: var(--warn-soft); color: #9a3412; }
    .danger-box { background: #fff7ed; color: #9a3412; }
    .ok-box { background: var(--ok-soft); color: var(--ok); }

    .empty {
      text-align: center;
      padding: 28px 18px;
      border: 1px dashed var(--line-strong);
      border-radius: 18px;
      background: rgba(255,255,255,0.76);
    }
    .empty h3 {
      margin: 0 0 8px;
      font-size: 18px;
    }
    .empty p {
      margin: 0 0 14px;
      color: var(--muted);
      line-height: 1.5;
    }

    .modal-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(16,24,40,0.46);
      z-index: 90;
      display: flex;
      align-items: flex-end;
      justify-content: center;
      padding: 12px;
    }
    .modal {
      width: min(520px, 100%);
      max-height: 92dvh;
      overflow: auto;
      background: var(--panel);
      border-radius: 24px;
      padding: 16px;
      box-shadow: 0 24px 60px rgba(16, 24, 40, 0.22);
    }
    .modal.center {
      align-self: center;
    }
    .modal-handle {
      width: 46px;
      height: 5px;
      border-radius: 999px;
      background: #d0d5dd;
      margin: 0 auto 12px;
    }
    .modal-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 14px;
    }
    .modal-title {
      margin: 0;
      font-size: 20px;
      font-weight: 800;
      letter-spacing: -0.02em;
    }

    .tabbar {
      position: fixed;
      left: 50%;
      bottom: 0;
      transform: translateX(-50%);
      width: min(520px, 100%);
      height: calc(var(--tabbar-h) + var(--safe-bottom));
      padding-bottom: var(--safe-bottom);
      background: rgba(255,255,255,0.96);
      backdrop-filter: blur(10px);
      border-top: 1px solid var(--line);
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      z-index: 40;
    }
    .tab {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 2px;
      color: var(--muted);
      font-size: 11px;
      font-weight: 800;
      min-height: 46px;
    }
    .tab .tab-ico {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-height: 22px;
      line-height: 1;
    }
    .tab-svg {
      width: 22px;
      height: 22px;
      display: block;
    }
    .tab.active { color: var(--primary); }

    .fab {
      position: fixed;
      right: max(20px, calc((100vw - min(520px, 100vw)) / 2 + 20px));
      bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 18px);
      width: 58px;
      height: 58px;
      border-radius: 50%;
      background: var(--primary);
      color: #fff;
      box-shadow: 0 18px 34px rgba(47, 111, 237, 0.24);
      z-index: 45;
      font-size: 28px;
      line-height: 1;
    }

    .toast {
      position: fixed;
      left: 50%;
      transform: translateX(-50%) translateY(16px);
      bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 90px);
      background: rgba(16,24,40,0.92);
      color: #fff;
      border-radius: 999px;
      padding: 12px 16px;
      font-size: 13px;
      font-weight: 700;
      opacity: 0;
      pointer-events: none;
      transition: 0.22s ease;
      z-index: 99;
      white-space: nowrap;
      max-width: calc(100vw - 24px);
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .toast.show {
      opacity: 1;
      transform: translateX(-50%) translateY(0);
    }

    .inline-actions-2 {
      display: grid;
      gap: 10px;
      grid-template-columns: 1fr 1fr;
    }

    .trash-icon {
      width: 18px;
      height: 18px;
      display: block;
    }

    @media (max-width: 420px) {
      .field.two,
      .inline-actions-2,
      .metric-grid {
        grid-template-columns: 1fr;
      }
      .inline-field {
        grid-template-columns: 1fr;
      }
    }
  


    .fold-card {
      border: 1px solid var(--line-strong);
      border-radius: 18px;
      background: var(--panel);
      overflow: hidden;
      box-shadow: var(--shadow);
    }
    .fold-card summary {
      list-style: none;
      cursor: pointer;
      padding: 16px;
      font-weight: 800;
    }
    .fold-card summary::-webkit-details-marker { display: none; }
    .fold-card[open] summary {
      border-bottom: 1px solid var(--line);
      background: #fafbff;
    }
    .fold-body {
      padding: 16px;
    }
    .check-grid {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }
    .check-chip {
      position: relative;
      display: inline-flex;
    }
    .check-chip input {
      position: absolute;
      inset: 0;
      opacity: 0;
      pointer-events: none;
    }
    .check-chip span {
      display: inline-flex;
      align-items: center;
      min-height: 38px;
      border-radius: 999px;
      padding: 0 14px;
      border: 1px solid var(--line-strong);
      background: var(--panel);
      font-size: 13px;
      font-weight: 700;
      color: var(--text);
    }
    .check-chip input:checked + span {
      border-color: var(--primary);
      background: var(--primary-soft);
      color: var(--primary);
      box-shadow: inset 0 0 0 1px rgba(47, 111, 237, 0.08);
    }


    .segment-row {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
      margin-bottom: 14px;
      padding: 4px;
      border-radius: 18px;
      background: #eef2f7;
    }
    .segment {
      min-height: 42px;
      border-radius: 14px;
      font-weight: 800;
      color: var(--muted);
      background: transparent;
    }
    .segment.active {
      background: var(--panel);
      color: var(--primary);
      box-shadow: 0 6px 14px rgba(16, 24, 40, 0.08);
    }
    .sort-row { margin-top: -2px; }
    .compact-card { padding: 16px; }
    .compact-head strong {
      font-size: 17px;
      font-weight: 800;
      letter-spacing: -0.01em;
    }
    .card-title-row { gap: 8px; }
    .compact-reason {
      margin-top: 8px;
      color: #344054;
      line-height: 1.5;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }
    .compact-meta {
      margin-top: 12px;
      font-size: 12px;
      color: var(--muted);
      line-height: 1.4;
    }
    .schedule-chip-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }
    .schedule-chip {
      min-height: 44px;
      border-radius: 14px;
      border: 1px solid var(--line-strong);
      background: var(--panel);
      font-weight: 800;
      padding: 0 12px;
    }
    .preset-row { margin-top: 4px; }
    .preset-chip {
      width: auto;
      min-height: 38px;
      padding: 0 14px;
      background: var(--panel);
    }
    .hl {
      background: var(--primary-soft);
      color: inherit;
      padding: 0 2px;
      border-radius: 4px;
    }
    .draft-notice {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 12px 14px;
      border: 1px solid #fed7aa;
      background: #fff7ed;
      color: #9a3412;
      border-radius: 14px;
      margin-bottom: 12px;
    }
    .list-jump {
      width: 100%;
      border: 0;
      background: transparent;
      text-align: left;
      padding: 0;
    }


.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
}
.search-meta {
  margin: -2px 0 12px;
  font-size: 12px;
  color: var(--muted);
}
.btn.emphasis {
  background: linear-gradient(180deg, var(--primary-soft-strong) 0%, var(--primary-soft) 100%);
  color: var(--primary-strong);
  border-color: rgba(47, 111, 237, 0.14);
  box-shadow: inset 0 0 0 1px rgba(47, 111, 237, 0.08);
}
.btn.secondary:hover, .btn.emphasis:hover, .schedule-chip:hover, .chip:hover, .icon-btn:hover {
  transform: translateY(-1px);
}
.record-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.mini-link, .summary-link {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel-soft);
  color: var(--primary-strong);
  font-weight: 700;
}
.link-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.archive-banner {
  margin-bottom: 12px;
  border-radius: 16px;
  padding: 14px 16px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  line-height: 1.5;
  font-size: 14px;
}
.home-focus-card {
  background: linear-gradient(180deg, #f7faff 0%, #edf4ff 100%);
  border: 1px solid rgba(47, 111, 237, 0.12);
  border-radius: 22px;
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}
.home-focus-value {
  margin-top: 4px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-strong);
}
.home-focus-actions .btn { width: auto; }
.compact-list-item { padding-top: 10px; padding-bottom: 10px; }
.section-card { margin-bottom: 0; }
.section-title-tight { margin: 0; }
.schedule-custom-row { display: flex; justify-content: flex-start; }
.schedule-custom-toggle { width: auto; min-height: 42px; padding: 0 16px; }
.schedule-custom-toggle.is-active { background: var(--primary-soft); color: var(--primary-strong); border-color: rgba(47, 111, 237, 0.18); }
.schedule-inline-input { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.draft-notice { border-color: #bfdbfe; background: #eff6ff; color: #1d4ed8; }
@media (max-width: 420px) { .link-summary-grid { grid-template-columns: 1fr; } }

.form-status{display:none;margin:-4px 0 10px;padding:10px 12px;border-radius:12px;font-size:12px;font-weight:700;background:var(--panel-soft);color:var(--muted);border:1px solid var(--line);}
.form-status.is-visible{display:block;}
.form-status[data-tone="saved"]{background:#eff6ff;border-color:#bfdbfe;color:#1d4ed8;}
.form-status[data-tone="error"]{background:#fef2f2;border-color:#fecaca;color:#b42318;}
.form-status[data-tone="drafting"]{background:#f8fafc;border-color:#dbe4f0;color:#475467;}
.context-banner{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 16px;border-radius:16px;background:#eff6ff;border:1px solid #bfdbfe;margin-bottom:12px;}
.connection-card{margin-top:4px;padding:14px 16px;border-radius:16px;background:var(--panel-soft);border:1px solid var(--line);}
.connection-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:8px;}
.connection-main{margin-top:4px;font-weight:800;color:var(--text-strong);}
.trade-history-item.focus-trade>.card{border-color:rgba(47,111,237,.32);box-shadow:0 0 0 3px rgba(47,111,237,.12), var(--shadow);}
@media (max-width:420px){.connection-grid{grid-template-columns:1fr;}.context-banner{align-items:flex-start;flex-direction:column;}}


.save-trust-row{display:inline-flex;align-items:center;gap:8px;margin-top:8px;padding:7px 10px;border-radius:999px;background:var(--panel-soft);border:1px solid var(--line);font-size:12px;color:var(--muted);}
.save-dot{width:8px;height:8px;border-radius:999px;background:var(--primary);box-shadow:0 0 0 4px rgba(47,111,237,.12);}
.connection-card .badge{white-space:nowrap;}
.connection-card .note-line{line-height:1.55;}
.section-card .list-jump.compact-list-item{padding:10px 0;}
.connection-main{font-weight:600;line-height:1.55;}


.compact-snippet{
  margin-top:6px;
  font-size:12px;
  line-height:1.45;
  color:var(--muted);
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}
.compact-keywords{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin-top:8px;
}
.mini-keyword{
  display:inline-flex;
  align-items:center;
  padding:4px 8px;
  border-radius:999px;
  background:var(--panel-soft);
  border:1px solid var(--line);
  color:var(--muted);
  font-size:11px;
  line-height:1;
}
.form-footer-actions{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-top:8px;
}
.form-footer-actions .btn.primary{
  min-width:128px;
}
.archive-btn{
  width:auto;
  padding-inline:14px;
}


.modal-head-actions{
  display:flex;
  align-items:center;
  gap:8px;
}
.header-archive-btn{
  width:auto;
  min-height:36px;
  padding:0 12px;
  border-radius:12px;
  font-size:13px;
  white-space:nowrap;
}
.form-footer-actions{
  display:flex;
  justify-content:flex-end;
  align-items:center;
}
