:root {
    --bg: #0f1115;
    --panel: #171a21;
    --line: #262b35;
    --text: #e6e9ef;
    --muted: #8b93a3;
    --up: #3ddc97;
    --down: #ff6b6b;
    --accent: #6ea8fe;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }

header { display: flex; align-items: baseline; justify-content: space-between; }
h1 { font-size: 20px; letter-spacing: 0.02em; margin: 0 0 20px; }

.gate { max-width: 320px; padding-top: 18vh; }
.gate form { display: flex; gap: 8px; flex-wrap: wrap; }

input, button, textarea {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
}

input:focus, button:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }

textarea {
    resize: none;
    overflow-y: auto;
    max-height: 160px;
    line-height: 1.4;
    vertical-align: bottom;
}

.error { color: var(--down); font-size: 13px; }

#add-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    padding: 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.row-pick {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.row-note {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.field { position: relative; }
.row-pick .ticker-field { flex: 1 1 220px; }
.row-pick .ticker-field input#ticker { width: 100%; }
.field.grow { flex: 1 1 auto; }
.field.grow input, .field.grow textarea { width: 100%; }
.sides { display: flex; gap: 12px; color: var(--muted); font-size: 14px; }
.sides label { display: flex; align-items: center; gap: 4px; }

.row-note textarea { min-height: 62px; }
.row-note button {
    flex: 0 0 auto;
    align-self: flex-end;
    padding: 8px 18px;
    font-weight: 600;
    border-color: var(--accent);
    color: var(--accent);
}
.row-note button:hover { background: var(--accent); color: var(--bg); }

@media (max-width: 700px) {
    .row-pick { flex-direction: column; align-items: stretch; }
    .row-pick .ticker-field { flex-basis: auto; }
    .row-note { flex-direction: column; align-items: stretch; }
    .row-note button { align-self: stretch; }
}

#suggestions {
    position: absolute;
    z-index: 10;
    top: 100%;
    left: 0;
    min-width: 260px;
    margin: 4px 0 0;
    padding: 4px;
    list-style: none;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
}

#suggestions li { padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 14px; }
#suggestions li:hover, #suggestions li[aria-selected="true"] { background: var(--line); }
#suggestions .sym { font-weight: 600; margin-right: 6px; }
#suggestions .ex { color: var(--muted); font-size: 12px; }

.summary { display: flex; gap: 24px; margin: 20px 0 12px; color: var(--muted); font-size: 13px; }
.summary b { display: block; color: var(--text); font-size: 20px; font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; cursor: pointer; }
th:hover { color: var(--text); }
.num, td.num { text-align: right; }

.name { color: var(--muted); font-size: 12px; display: block; }
.name.note { white-space: pre-wrap; word-break: break-word; max-width: 46ch; }
.name.note a { color: inherit; text-decoration: underline; text-decoration-color: var(--line); }
.name.note a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.badge { font-size: 11px; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line); text-transform: uppercase; }
.badge.buy { color: var(--up); }
.badge.sell { color: var(--down); }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--muted); }
.stale { color: var(--muted); font-size: 11px; }

.del { background: none; border: none; color: var(--muted); cursor: pointer; }
.del:hover { color: var(--down); }

@media (hover: hover) {
    .del { visibility: hidden; }
    tr:hover .del, .del:focus { visibility: visible; }
}

@media (max-width: 700px) {
    thead { display: none; }
    table, tbody, tr, td { display: block; width: 100%; }
    tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
    td { border: none; padding: 2px 0; display: flex; justify-content: space-between; }
    td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
    td.num { text-align: right; }

    /* The Ticker cell can carry a multi-line note; let it wrap onto its own
       row instead of being squeezed into a flex column. */
    td[data-label="Ticker"] { flex-wrap: wrap; }
    td[data-label="Ticker"] .name.note { flex: 1 1 100%; max-width: none; text-align: left; }

    /* No hover on touch devices, so the delete control must stay reachable. */
    .del { visibility: visible; }
}
