/* ============================================================
   토스(Toss) 스타일 디자인 시스템
   ============================================================ */

:root {
    /* ── Brand ── */
    --blue:        #3182F6;
    --blue-dark:   #1B64DA;
    --blue-light:  #EBF3FF;

    /* ── Market Colors ── */
    --crypto:      #FF9500;
    --crypto-light:#FFF5E6;
    --stock:       #00B493;
    --stock-light: #E8FAF6;

    /* ── Semantic ── */
    --success:     #00B493;
    --success-bg:  #E8FAF6;
    --danger:      #F04452;
    --danger-bg:   #FFF3F4;
    --warning:     #FF9F00;
    --warning-bg:  #FFF8E6;

    /* ── Surface ── */
    --bg:          #F2F4F6;
    --surface:     #FFFFFF;
    --surface-2:   #F9FAFB;

    /* ── Text ── */
    --text-1:      #191F28;
    --text-2:      #4E5968;
    --text-3:      #8B95A1;
    --text-4:      #B0B8C1;

    /* ── Border ── */
    --border:      #F2F4F6;
    --divider:     #E5E8EB;

    /* ── Shadow ── */
    --shadow-sm:   0 1px 4px rgba(0,0,0,0.06);
    --shadow:      0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg:   0 8px 32px rgba(0,0,0,0.10);

    /* ── Radius ── */
    --r-xs: 8px;
    --r-sm: 12px;
    --r:    16px;
    --r-lg: 20px;
    --r-xl: 24px;

    /* ── Type ── */
    --sans: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }

html, body {
    background: var(--bg);
    color: var(--text-1);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

body {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    padding-bottom: 80px;
    background: var(--bg);
    position: relative;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; }

/* ── Top Bar ────────────────────────────────────────────────── */
.topbar {
    height: 56px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    position: sticky; top: 0; z-index: 50;
}
.topbar-left  { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 4px; }
.topbar-title { font-size: 18px; font-weight: 700; color: var(--text-1); }

.back-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; color: var(--text-1); margin-left: -6px;
    transition: background 0.15s;
}
.back-btn:active { background: var(--bg); }

.icon-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; color: var(--text-2);
    transition: background 0.15s;
}
.icon-btn:active { background: var(--bg); }
.icon-btn.primary { background: var(--blue-light); color: var(--blue); }

/* ── Bottom Tab Bar ─────────────────────────────────────────── */
.tabbar {
    position: fixed; bottom: 0; left: 50%;
    transform: translateX(-50%);
    width: 100%; max-width: 430px;
    height: 60px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex; z-index: 50;
}
.tab {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 3px;
    color: var(--text-3); font-size: 10px; font-weight: 600;
    letter-spacing: -0.02em; padding: 6px 4px;
    transition: color 0.15s;
}
.tab.active { color: var(--blue); }
.tab svg { width: 22px; height: 22px; }

/* ── Page ───────────────────────────────────────────────────── */
.page { padding: 0 0 32px; }

.page-section {
    background: var(--surface);
    margin-bottom: 8px;
    padding: 20px;
}
.page-section:last-child { margin-bottom: 0; }

.section-label {
    font-size: 12px; font-weight: 700; color: var(--text-3);
    letter-spacing: 0.04em; text-transform: uppercase;
    margin-bottom: 14px;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--r);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

/* ── List Items (Toss style - dividers not cards) ───────────── */
.list-item {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 20px; background: var(--surface);
}
.list-item + .list-item { border-top: 1px solid var(--border); }

.list-icon {
    width: 44px; height: 44px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px; flex-shrink: 0;
    color: white;
}

.list-body { flex: 1; min-width: 0; }
.list-title { font-size: 15px; font-weight: 600; color: var(--text-1); }
.list-sub   { font-size: 13px; color: var(--text-3); margin-top: 2px; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 0 20px; height: 52px;
    font-size: 16px; font-weight: 700;
    border-radius: var(--r-sm); width: 100%;
    transition: all 0.12s;
}
.btn-primary  { background: var(--blue);  color: #fff; }
.btn-primary:active  { background: var(--blue-dark); transform: scale(0.99); }
.btn-primary:disabled  { opacity: 0.45; cursor: not-allowed; }
.btn-secondary { background: var(--blue-light); color: var(--blue); }
.btn-danger   { background: var(--danger-bg); color: var(--danger); }
.btn-outline  { background: var(--surface); border: 1.5px solid var(--divider); color: var(--text-1); }
.btn-gray     { background: var(--bg); color: var(--text-2); }
.btn-sm { height: 38px; font-size: 14px; font-weight: 600; border-radius: var(--r-xs); width: auto; padding: 0 14px; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block; font-size: 13px; font-weight: 600;
    color: var(--text-2); margin-bottom: 8px;
}

.form-input, .form-textarea, .form-select {
    width: 100%; padding: 15px 16px;
    background: var(--bg); border: 1.5px solid transparent;
    color: var(--text-1); font-size: 15px;
    border-radius: var(--r-sm); transition: all 0.15s;
    -webkit-appearance: none; appearance: none;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
    outline: none; border-color: var(--blue);
    background: var(--surface); box-shadow: 0 0 0 3px rgba(49,130,246,0.10);
}
.form-textarea { resize: none; min-height: 120px; line-height: 1.65; }
.form-select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238B95A1' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 16px center;
    padding-right: 44px;
}
.form-hint { font-size: 12px; color: var(--text-3); margin-top: 6px; }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
    padding: 14px 16px; border-radius: var(--r-sm); margin-bottom: 16px;
    font-size: 14px; display: flex; align-items: flex-start; gap: 10px; line-height: 1.5;
}
.alert-error   { background: var(--danger-bg);  color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-info    { background: var(--blue-light); color: var(--blue); }
.alert-warn    { background: var(--warning-bg); color: var(--warning); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; font-size: 12px; font-weight: 700;
    border-radius: 100px;
}
.badge-idle    { background: var(--bg); color: var(--text-3); }
.badge-running { background: var(--success-bg); color: var(--success); }
.badge-error   { background: var(--danger-bg); color: var(--danger); }
.badge-stopped { background: var(--warning-bg); color: var(--warning); }
.badge-crypto  { background: var(--crypto-light); color: var(--crypto); }
.badge-stock   { background: var(--stock-light); color: var(--stock); }
.badge .dot {
    width: 5px; height: 5px; border-radius: 50%; background: currentColor;
}
.badge-running .dot { animation: pulse-dot 1.4s infinite; }
@keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ── Segmented Control ──────────────────────────────────────── */
.seg-ctrl {
    display: flex; background: var(--bg);
    border-radius: var(--r-sm); padding: 3px; gap: 2px;
}
.seg-btn {
    flex: 1; padding: 9px 8px; border-radius: var(--r-xs);
    font-size: 14px; font-weight: 600; color: var(--text-3);
    transition: all 0.18s; text-align: center;
}
.seg-btn.active {
    background: var(--surface); color: var(--text-1);
    box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}
.seg-btn.active.crypto { color: var(--crypto); }
.seg-btn.active.stock  { color: var(--stock); }

/* ── Stats Grid ─────────────────────────────────────────────── */
.stats-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.stat-card {
    background: var(--surface); border-radius: var(--r);
    padding: 16px 12px; text-align: center;
    box-shadow: var(--shadow-sm);
}
.stat-num {
    font-size: 28px; font-weight: 800; letter-spacing: -0.04em;
    line-height: 1.1; color: var(--text-1);
}
.stat-num.blue   { color: var(--blue); }
.stat-num.crypto { color: var(--crypto); }
.stat-num.stock  { color: var(--stock); }
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 4px; font-weight: 500; }

/* ── Hero ───────────────────────────────────────────────────── */
.hero {
    background: linear-gradient(135deg, #3182F6 0%, #5ba4ff 100%);
    border-radius: var(--r-xl); color: white; padding: 24px;
    margin: 20px; position: relative; overflow: hidden;
    box-shadow: 0 8px 24px rgba(49,130,246,0.30);
}
.hero::before {
    content: ''; position: absolute;
    right: -40px; top: -40px;
    width: 180px; height: 180px; border-radius: 50%;
    background: rgba(255,255,255,0.10);
}
.hero::after {
    content: ''; position: absolute;
    right: 20px; bottom: -50px;
    width: 120px; height: 120px; border-radius: 50%;
    background: rgba(255,255,255,0.06);
}
.hero-eyebrow { font-size: 12px; font-weight: 700; opacity: 0.75; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 8px; }
.hero-title   { font-size: 22px; font-weight: 800; line-height: 1.3; margin-bottom: 6px; position: relative; z-index: 1; }
.hero-sub     { font-size: 13px; opacity: 0.82; margin-bottom: 18px; position: relative; z-index: 1; }
.hero-cta {
    display: inline-flex; align-items: center; gap: 6px;
    background: white; color: var(--blue);
    padding: 10px 18px; border-radius: 100px;
    font-weight: 700; font-size: 14px; position: relative; z-index: 1;
}

/* ── Market Tag ─────────────────────────────────────────────── */
.market-tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 100px;
    font-size: 11px; font-weight: 700;
}
.market-tag.crypto { background: var(--crypto-light); color: var(--crypto); }
.market-tag.stock  { background: var(--stock-light);  color: var(--stock); }

/* ── Exchange Icon ──────────────────────────────────────────── */
.ex-icon {
    width: 46px; height: 46px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 17px; flex-shrink: 0; color: white;
}

/* ── Bot Card ───────────────────────────────────────────────── */
.bot-card {
    background: var(--surface);
    display: flex; align-items: center; gap: 14px;
    padding: 16px 20px;
}
.bot-card + .bot-card { border-top: 1px solid var(--border); }

.bot-icon {
    width: 44px; height: 44px; border-radius: 13px;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; color: var(--text-3);
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15,18,25,0.5); backdrop-filter: blur(4px);
    z-index: 100; display: flex; align-items: flex-end; justify-content: center;
    animation: fade-in 0.2s ease;
}
.modal-sheet {
    background: var(--surface); width: 100%; max-width: 430px;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: 8px 20px calc(28px + env(safe-area-inset-bottom, 0));
    animation: slide-up 0.28s cubic-bezier(0.34, 1.12, 0.64, 1);
    max-height: 88vh; overflow-y: auto;
}
.modal-handle {
    width: 36px; height: 4px; background: var(--divider);
    border-radius: 100px; margin: 10px auto 18px;
}
.modal-title    { font-size: 20px; font-weight: 800; margin-bottom: 6px; color: var(--text-1); }
.modal-subtitle { font-size: 14px; color: var(--text-3); margin-bottom: 20px; }

@keyframes fade-in  { from { opacity:0 }            to { opacity:1 } }
@keyframes slide-up { from { transform:translateY(60px); opacity:0 } to { transform:translateY(0); opacity:1 } }

/* ── Page Tabs (bot_view) ───────────────────────────────────── */
.page-tabs {
    display: flex; background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 56px; z-index: 40;
    padding: 0 20px;
}
.page-tab {
    flex: 1; padding: 14px 4px; font-size: 14px;
    font-weight: 600; color: var(--text-3); text-align: center;
    border-bottom: 2px solid transparent; transition: all 0.15s;
}
.page-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ── Code Block ─────────────────────────────────────────────── */
.code-block {
    background: #191F28; color: #CDD5E0;
    border-radius: var(--r-sm); padding: 16px;
    font-family: var(--mono); font-size: 12px; line-height: 1.7;
    white-space: pre-wrap; word-break: break-word;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
}

/* ── Example Chip ───────────────────────────────────────────── */
.chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 8px 14px; background: var(--surface);
    border: 1.5px solid var(--divider); border-radius: 100px;
    font-size: 13px; color: var(--text-1); cursor: pointer;
    transition: all 0.15s; margin: 0 6px 6px 0;
    box-shadow: var(--shadow-sm);
}
.chip:active { background: var(--blue-light); border-color: var(--blue); color: var(--blue); }

/* ── Floating Action Bar ────────────────────────────────────── */
.action-bar {
    position: fixed; bottom: 60px; left: 50%;
    transform: translateX(-50%);
    width: 100%; max-width: 430px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom,0));
    z-index: 30;
}

/* ── Greetings section ──────────────────────────────────────── */
.greeting-section {
    padding: 20px 20px 16px;
    background: var(--surface);
}
.greeting-sub  { font-size: 14px; color: var(--text-3); margin-bottom: 2px; }
.greeting-name { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; color: var(--text-1); }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
    padding: 56px 20px; text-align: center;
    background: var(--surface);
}
.empty-icon {
    width: 72px; height: 72px; border-radius: 50%; background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 18px; color: var(--text-4);
}
.empty-title { font-size: 17px; font-weight: 700; color: var(--text-1); margin-bottom: 8px; }
.empty-desc  { font-size: 14px; color: var(--text-3); line-height: 1.6; margin-bottom: 24px; }

/* ── Misc ───────────────────────────────────────────────────── */
.mono { font-family: var(--mono); }
.text-blue  { color: var(--blue); }
.text-muted { color: var(--text-3); }
hr.div { border: 0; border-top: 1px solid var(--border); margin: 0; }

/* ── Register/Login pages ───────────────────────────────────── */
.auth-page { padding: 28px 20px; background: var(--surface); min-height: calc(100vh - 56px); }
.auth-title { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 6px; }
.auth-sub   { font-size: 15px; color: var(--text-3); margin-bottom: 32px; }

/* ── Desktop ────────────────────────────────────────────────── */
@media (min-width: 600px) {
    body { box-shadow: 0 0 48px rgba(0,0,0,0.07); }
}
