:root{
    --primary: #5B3DF6;
    --primary-dark: #4429D6;
    --primary-light: #8A73FF;
    --ink: #14121F;
    --ink-soft: #1D1A33;
    --ink-softer: #262244;
    --paper: #F6F5FB;
    --paper-card: #FFFFFF;
    --border: #E4E1F5;
    --text-muted: #7A7691;
    --accent: #FFB020;

    --get: #12B76A;
    --post: #F79009;
    --put: #2E90FA;
    --patch: #7A5AF8;
    --delete: #F04438;
    --active: #2E90FA;
    --active-bg: #EAF3FF;

    --radius: 12px;
    --font-display: 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

*{ box-sizing: border-box; }

body{
    font-family: var(--font-display);
    background: var(--paper);
    color: var(--ink);
    margin: 0;
    height: 100vh;
    overflow: hidden;
}

.fw-600{ font-weight: 600; }
.fw-700{ font-weight: 700; }
.fw-800{ font-weight: 800; }

/* ===== Auth pages ===== */
.auth-page{ height: 100vh; background: radial-gradient(circle at 20% 20%, var(--primary-light) 0%, transparent 45%), radial-gradient(circle at 80% 80%, var(--accent) 0%, transparent 40%), var(--ink); }
.auth-card{ width: 100%; max-width: 380px; background: var(--paper-card); border-radius: 20px; padding: 2.25rem; box-shadow: 0 30px 60px rgba(20,18,31,.35); }
.brand-mark{ width: 52px; height: 52px; border-radius: 16px; background: linear-gradient(135deg, var(--primary), var(--primary-light)); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.4rem; box-shadow: 0 10px 24px rgba(91,61,246,.4); }
.brand-mark-sm{ width: 32px; height: 32px; border-radius: 9px; font-size: .95rem; }
.auth-card .btn-primary{ background: var(--primary); border-color: var(--primary); }
.auth-card .btn-primary:hover{ background: var(--primary-dark); border-color: var(--primary-dark); }
.auth-card a{ color: var(--primary); text-decoration: none; font-weight: 600; }

/* ===== App shell ===== */
.app-shell{ height: 100vh; display: flex; flex-direction: column; }
.topbar{ height: 56px; min-height: 56px; background: var(--ink); color: #fff; }
.topbar .brand{ color: #fff; }
.btn-user{ background: var(--ink-soft); color: #fff; border: 1px solid #34304f; }
.btn-user:hover{ background: var(--ink-softer); color: #fff; }

.app-body{ flex: 1; display: flex; min-height: 0; }

/* ===== Sidebar ===== */
.sidebar{ width: 300px; min-width: 300px; background: #FFFFFF; color: var(--ink); display: flex; flex-direction: column; border-right: 1px solid var(--border); }
.sidebar-head{ padding: 14px 14px 8px; }
.sidebar-section-title{ color: var(--text-muted); }
.sidebar-scroll{ flex: 1; overflow-y: auto; padding-bottom: 20px; }
.sidebar-scroll::-webkit-scrollbar{ width: 8px; }
.sidebar-scroll::-webkit-scrollbar-thumb{ background: var(--border); border-radius: 8px; }

.tree-list{ list-style: none; margin: 0; padding-left: 0; }
.tree-list .tree-list{ padding-left: 18px; }
.tree-node{ position: relative; }
.tree-row{ display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 8px; cursor: pointer; color: var(--ink-soft); font-size: .875rem; }
.tree-row:hover{ background: var(--paper); color: var(--ink); }
.tree-row .chevron{ font-size: .65rem; transition: transform .15s ease; color: var(--text-muted); }
.tree-row[aria-expanded="true"] .chevron{ transform: rotate(90deg); }
.tree-icon{ font-size: .9rem; }
.folder-icon{ color: var(--accent); }
.collection-icon{ color: var(--primary); }
.tree-label{ flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-actions{ display: none; gap: 2px; }
.tree-row:hover .tree-actions{ display: flex; }
.btn-icon{ border: none; background: transparent; color: var(--text-muted); width: 24px; height: 24px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; }
.btn-icon:hover{ background: var(--paper); color: var(--ink); }
.tree-empty{ padding: 8px 12px; }
.badge-shared{ font-size: .65rem; color: var(--accent); }

.request-row{ padding-left: 26px; }
.request-row.active{ background: var(--active-bg); }
.request-row.active:hover{ background: var(--active-bg); }
.request-row.active .tree-label{ color: var(--active); font-weight: 700; }
.request-row.active .chevron{ color: var(--active); }
.method-badge{ font-family: var(--font-mono); font-size: .65rem; font-weight: 700; padding: 1px 6px; border-radius: 5px; color: #fff; min-width: 40px; text-align: center; }
.method-get{ background: var(--get); }
.method-post{ background: var(--post); }
.method-put{ background: var(--put); }
.method-patch{ background: var(--patch); }
.method-delete{ background: var(--delete); }

/* ===== Workspace / Tabs ===== */
.workspace{ flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--paper); }
.tabs-bar{ display: flex; align-items: center; background: #fff; border-bottom: 1px solid var(--border); overflow-x: auto; min-height: 44px; }
.tabs-bar::-webkit-scrollbar{ height: 4px; }
.tab-item{ display: flex; align-items: center; gap: 8px; padding: 0 10px; height: 44px; border-right: 1px solid var(--border); cursor: pointer; font-size: .82rem; white-space: nowrap; color: var(--text-muted); position: relative; max-width: 200px; }
.tab-item.active{ color: var(--ink); background: var(--paper); font-weight: 600; }
.tab-item.active::after{ content:""; position:absolute; left:0; right:0; bottom:-1px; height:2px; background: var(--primary); }
.tab-item .tab-name{ overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.tab-item .tab-close{ border: none; background: transparent; color: var(--text-muted); border-radius: 5px; width: 18px; height: 18px; display:flex; align-items:center; justify-content:center; font-size:.7rem; }
.tab-item .tab-close:hover{ background: var(--border); color: var(--ink); }
.tab-item .dot-unsaved{ width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display:inline-block; }
.tab-add-btn{ border: none; background: transparent; color: var(--text-muted); width: 40px; height: 44px; }
.tab-add-btn:hover{ color: var(--primary); }

.tabs-content{ flex: 1; overflow-y: auto; padding: 18px 22px 40px; }
.tabs-content::-webkit-scrollbar{ width: 10px; }
.tabs-content::-webkit-scrollbar-thumb{ background: #d9d5f0; border-radius: 8px; }

.pane{ display: none; }
.pane.active{ display: block; }

.req-breadcrumb{ display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: .78rem; color: var(--text-muted); margin-bottom: 10px; }
.req-breadcrumb .crumb-sep{ font-size: .6rem; color: var(--text-muted); opacity: .7; }
.req-breadcrumb .crumb.current{ color: var(--ink); font-weight: 700; }

.request-bar{ display: flex; align-items: stretch; gap: 10px; margin-bottom: 16px; }

.request-input-group{
    display: flex;
    align-items: stretch;
    flex: 1;
    min-width: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.request-input-group:focus-within{
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(91,61,246,.12);
}

.method-select{
    appearance: none;
    -webkit-appearance: none;
    flex: 0 0 100px;
    width: 100px;
    height: 40px;
    border: none;
    background-color: transparent;
    font-weight: 700;
    font-family: var(--font-mono);
    font-size: .76rem;
    letter-spacing: .02em;
    color: var(--ink-soft);
    padding: 0 26px 0 14px;
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%237A7691' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
.method-select:focus{ outline: none; box-shadow: none; }
.method-select.m-get{ color: var(--get); }
.method-select.m-post{ color: var(--post); }
.method-select.m-put{ color: var(--put); }
.method-select.m-patch{ color: var(--patch); }
.method-select.m-delete{ color: var(--delete); }

.method-divider{ flex: 0 0 1px; width: 1px; background: var(--border); margin: 8px 0; }

.url-input{
    flex: 1;
    min-width: 0;
    height: 40px;
    border: none;
    background: transparent;
    font-family: var(--font-mono);
    font-size: .84rem;
    color: var(--ink);
    padding: 0 14px;
}
.url-input:focus{ outline: none; box-shadow: none; }
.url-input::placeholder{ color: var(--text-muted); }
.btn-send{
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 40px; padding: 0 18px; flex: 0 0 auto; white-space: nowrap;
    background: var(--primary); border: 1px solid var(--primary); color: #fff;
    font-weight: 700; font-size: .85rem; border-radius: 10px;
    transition: background-color .15s ease, transform .05s ease;
}
.btn-send:hover{ background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-send:focus{ color: #fff; }
.btn-send:active{ transform: translateY(1px); }
.btn-save{
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 40px; padding: 0 16px; flex: 0 0 auto; white-space: nowrap;
    background: #fff; border: 1px solid var(--border); color: var(--ink-soft);
    font-weight: 600; font-size: .85rem; border-radius: 10px !important;
    transition: border-color .15s ease, color .15s ease;
}
.btn-save:hover{ border-color: var(--primary-light); color: var(--primary); background: #fff; }

.card-panel{ background: var(--paper-card); border: 1px solid var(--border); border-radius: var(--radius); }

.kv-row{ display: grid; grid-template-columns: 1fr 1fr 90px 36px; gap: 8px; margin-bottom: 8px; align-items: center; }
.kv-row input, .kv-row select{ font-size: .85rem; }
.kv-remove{ color: var(--delete); }

.nav-pills-custom .nav-link{ font-size: .82rem; font-weight: 600; color: var(--text-muted); border-radius: 8px; padding: 6px 12px; }
.nav-pills-custom .nav-link.active{ background: var(--primary); color: #fff; }

.raw-body-editor{ font-family: var(--font-mono); font-size: .85rem; min-height: 180px; }

.response-meta{ display: flex; gap: 18px; align-items: center; font-size: .82rem; }
.response-meta .status-ok{ color: var(--get); font-weight: 700; }
.response-meta .status-err{ color: var(--delete); font-weight: 700; }
.response-body-view{ font-family: var(--font-mono); font-size: .82rem; background: var(--ink); color: #E9E7F5; border-radius: var(--radius); padding: 14px; max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.response-empty{ padding: 60px 20px; text-align: center; color: var(--text-muted); }

.section-title{ font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; color: var(--text-muted); margin-bottom: 10px; }

.file-drop-hint{ font-size: .72rem; color: var(--text-muted); }
.b64-preview{ max-width: 60px; max-height: 40px; border-radius: 4px; border: 1px solid var(--border); }

.toast-stack{ position: fixed; bottom: 18px; right: 18px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.app-toast{ background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .85rem; box-shadow: 0 10px 24px rgba(0,0,0,.25); min-width: 220px; }
.app-toast.error{ background: var(--delete); }
.app-toast.success{ background: var(--get); }

.modal-content{ border-radius: 16px; border: none; }
.modal-header, .modal-footer{ border-color: var(--border); }
.btn-primary{ background: var(--primary); border-color: var(--primary); }
.btn-primary:hover{ background: var(--primary-dark); border-color: var(--primary-dark); }