@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;700&family=Space+Mono:wght@400;700&display=swap');

:root {
    --bg: #0a0c0f;
    --surface: #111318;
    --surface2: #181c24;
    --border: #1e2330;
    --border2: #2a3042;
    --text: #c8d0e0;
    --text-dim: #5a6480;
    --text-muted: #3a4060;
    --accent: #3b82f6;
    --accent2: #06b6d4;
    --green: #22c55e;
    --yellow: #eab308;
    --red: #ef4444;
    --orange: #f97316;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 24px;
    font-size: 13px;
}

/* ── Header ── */
.header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
}

.logo {
    font-family: 'Space Mono', monospace;
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -1px;
}

.logo span {
    color: var(--accent2);
}

.subtitle {
    color: var(--text-dim);
    font-size: 11px;
}

/* ── Layout ── */
.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 900px) {
    .grid {
        grid-template-columns: 1fr;
    }
}

/* ── Panels ── */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.panel-header {
    padding: 8px 14px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-header .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

.panel-body {
    padding: 14px;
}

/* ── Form elements ── */
label {
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-dim);
    display: block;
    margin-bottom: 5px;
}

input[type=text],
input[type=url],
textarea,
select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border2);
    color: var(--text);
    padding: 7px 10px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 12px;
    outline: none;
    transition: border-color 0.15s;
}

input:focus,
textarea:focus {
    border-color: var(--accent);
}

input[type=file] {
    display: none;
}

.file-drop {
    border: 2px dashed var(--border2);
    border-radius: 6px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-dim);
}

.file-drop:hover,
.file-drop.dragover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(59, 130, 246, 0.04);
}

.file-drop .icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.file-drop .hint {
    font-size: 11px;
    margin-top: 4px;
    color: var(--text-muted);
}

.form-row {
    margin-bottom: 12px;
}

.form-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    border-radius: 4px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-primary:disabled {
    background: var(--border2);
    color: var(--text-muted);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border2);
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-danger {
    background: transparent;
    color: var(--red);
    border: 1px solid var(--red);
}

.btn-danger:hover {
    background: var(--red);
    color: #fff;
}

.btn-sm {
    padding: 4px 9px;
    font-size: 11px;
}

.btn-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* ── Torrent Info ── */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.info-item label {
    margin-bottom: 2px;
}

.info-value {
    font-size: 12px;
    color: var(--text);
    word-break: break-all;
}

.info-value.hash {
    color: var(--accent2);
    font-size: 10px;
}

.info-value.size {
    color: var(--green);
}

/* ── Progress ── */
.progress-wrap {
    margin: 14px 0 8px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 11px;
}

.progress-bar {
    height: 6px;
    background: var(--surface2);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    transition: width 0.4s ease;
}

/* ── Piece map ── */
.piece-map-container {
    margin-top: 12px;
}

#pieceMap {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}

.piece-cell {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: var(--border2);
    transition: background 0.2s;
}

.piece-cell.have {
    background: var(--green);
}

.piece-cell.active {
    background: var(--accent);
}

.piece-cell.failed {
    background: var(--red);
}

/* ── Peers table ── */
#peerBox {
    height:220px;
    overflow-y:auto;
}
.peers-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 4px;
}

.peers-table th {
    text-align: left;
    padding: 5px 8px;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.peers-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
}

.peers-table tr:last-child td {
    border-bottom: none;
}

.peer-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10px;
}

.peer-status.connecting {
    background: rgba(234, 179, 8, 0.15);
    color: var(--yellow);
}

.peer-status.handshake {
    background: rgba(249, 115, 22, 0.15);
    color: var(--orange);
}

.peer-status.ready {
    background: rgba(34, 197, 94, 0.15);
    color: var(--green);
}

.peer-status.downloading {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent);
}

.peer-status.closed {
    background: rgba(239, 68, 68, 0.12);
    color: var(--red);
}

.peer-status::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

/* ── Log ── */
#logBox {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px 12px;
    height: 220px;
    overflow-y: auto;
    font-size: 11px;
    line-height: 1.7;
}

.log-line {
    display: flex;
    gap: 8px;
}

.log-time {
    color: var(--text-muted);
    flex-shrink: 0;
}

.log-info {
    color: var(--text-dim);
}

.log-ok {
    color: var(--green);
}

.log-warn {
    color: var(--yellow);
}

.log-error {
    color: var(--red);
}

.log-data {
    color: var(--accent2);
}

/* ── Downloads ── */
.download-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-top: 6px;
}

.download-name {
    color: var(--text);
}

.download-size {
    color: var(--text-dim);
    font-size: 11px;
}

/* ── Stats bar ── */
.stats-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.stat-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.stat-value.green {
    color: var(--green);
}

.stat-value.blue {
    color: var(--accent);
}

.stat-value.cyan {
    color: var(--accent2);
}

/* ── Proxy URL display ── */
.proxy-url {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 6px;
    word-break: break-all;
}

.proxy-url span {
    color: var(--accent2);
}