@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Space+Grotesk:wght@500;600;700&display=swap");

:root {
    color-scheme: dark;
    --bg-top: #0f141f;
    --bg-mid: #111928;
    --bg-bottom: #0b0f18;
    --text-main: #f4f5f7;
    --text-sub: #c7cbd4;
    --text-muted: #4e5566;
    --coral: #f96b43;
    --coral-soft: #ff8a5b;
    --coral-verysoft: #ffca9b;
    --mint: #4fe3a1;
    --mint-soft: #b9f5d0;
    --border: #2a3040;
    --glass: rgba(15, 20, 31, 0.65);
    --glass-strong: rgba(18, 24, 36, 0.82);
    --glow: 0 0 40px rgba(249, 107, 67, 0.2);
    --radius-lg: 16px;
    --radius-md: 10px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Space Grotesk", sans-serif;
    line-height: 1.5;
    color: var(--text-main);
    font-size: 16px;
    background: linear-gradient(180deg, var(--bg-top), var(--bg-mid), var(--bg-bottom));
    position: relative;
    overflow-x: hidden;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: -20%;
    z-index: 0;
    pointer-events: none;
}

body::before {
    background:
        radial-gradient(600px 600px at 20% 10%, rgba(79, 227, 161, 0.18), transparent 70%),
        radial-gradient(800px 800px at 80% 20%, rgba(255, 138, 91, 0.2), transparent 65%),
        radial-gradient(900px 900px at 50% 85%, rgba(79, 227, 161, 0.12), transparent 70%);
    filter: blur(10px);
    opacity: 0.9;
}

body::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.07'/%3E%3C/svg%3E");
    mix-blend-mode: soft-light;
    opacity: 0.3;
}

.page {
    position: relative;
    z-index: 1;
    max-width: 1180px;
    margin: 0 auto;
    padding: 70px 28px 96px;
}

.top-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.grid {
    display: grid;
    grid-template-columns: 0.3fr 0.7fr;
    gap: 20px;
}

.column-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.column-right {
    min-width: 0;
}

.card {
    background: var(--glass);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: 20px;
    backdrop-filter: blur(16px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
}

.card h3 {
    margin: 0 0 10px;
    font-size: 21px;
    letter-spacing: -0.01em;
    user-select: none;
}

.card p {
    color: var(--text-sub);
    margin: 0 0 16px;
    font-size: 15px;
    user-select: none;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    min-height: 40px;
}

.card-header h3 {
    margin: 0;
    user-select: none;
}

.theme-add {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.theme-name-input {
    flex: 1 1 240px;
    background: rgba(8, 10, 16, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 8px 14px;
    color: var(--text-main);
    font-family: "IBM Plex Mono", monospace;
    font-size: 13px;
}

.theme-name-input::placeholder {
    color: var(--text-muted);
}

.section-label {
    font-family: "IBM Plex Mono", monospace;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    user-select: none;
}

.theme-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    margin-left: 2px;
}

.theme-list-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-list-all {
    margin-bottom: 10px;
    width: 100%;
}

.theme-list-item {
    flex: 1 1 auto;
    text-align: left;
    display: flex;
    min-height: 50px;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-sub);
    padding: 10px 12px;
    border-radius: 12px;
    font-family: "IBM Plex Mono", monospace;
    font-size: 15px;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
    user-select: none;
    caret-color: transparent;
}

.theme-list-item:hover {
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
}

.theme-list-item.active {
    border-color: rgba(79, 227, 161, 0.55);
    color: var(--mint-soft);
    background: rgba(79, 227, 161, 0.08);
}

.theme-name {
    margin-right: 10px;
    font-size: 15px;
}

.theme-order {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-theme-order {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: var(--text-sub);
    font-size: 12px;
    line-height: 1;
    padding: 6px 4px 6px 6px;
    border-radius: 999px;
    cursor: pointer;
    margin-left: 2px;
}

.btn-theme-order:hover {
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.2);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.logged-in-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.logged-in-row .actions {
    margin-top: 0;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-sub);
}

button {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 10px 18px;
    font-family: "IBM Plex Mono", monospace;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    user-select: none;
}

button:hover {
    /* transform: translateY(-1px); */
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
}

.btn-edit-theme {
    min-width: 95px;
    margin-right: 3px;
}

.btn-primary {
    background: linear-gradient(120deg, var(--coral), var(--coral-soft));
    box-shadow: 0 10px 24px rgba(249, 107, 67, 0.25);
}

.btn-success {
    background: rgba(79, 227, 161, 0.2);
    border-color: rgba(79, 227, 161, 0.55);
    color: var(--mint);
}

.btn-danger {
    background: rgba(255, 138, 91, 0.16);
    border-color: rgba(255, 138, 91, 0.5);
    color: var(--coral-soft);
}

.btn-danger.btn-ghost {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    padding-left: 0;
    padding-right: 0;
}

.btn-danger.btn-ghost:hover {
    border-color: transparent;
    color: var(--coral-verysoft);
}

.btn-add-stock {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    padding-left: 0;
    padding-right: 3px;
}

.btn-add-stock:hover {
    border-color: transparent;
    background: transparent;
    color: var(--mint-soft);
}

#log,
#portfolio-log {
    margin-top: 14px;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: rgba(10, 12, 18, 0.6);
    font-family: "IBM Plex Mono", monospace;
    font-size: 13px;
    color: var(--text-sub);
    white-space: pre-wrap;
    word-break: break-all;
}

#portfolio-log {
    min-height: 140px;
    box-shadow: none;
    border: none;
    padding: 0;
    background: transparent;
}

#action-log {
    margin-top: 12px;
    padding: 0;
    display: grid;
    gap: 8px;
}

.action-item {
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-sub);
}

.hidden {
    display: none !important;
}

.theme-item {
    background: rgba(12, 16, 24, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin: 14px 0;
    padding: 16px 10px 16px 16px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.theme-item::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 12px;
    border: 1px solid rgba(255, 138, 91, 0.2);
    pointer-events: none;
    opacity: 0.5;
}

.theme-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    padding-right: 10px;
    min-height: 40px;
    user-select: none;
}

.theme-header span {
    font-size: 20px;
}

.theme-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

body:not(.is-edit-mode) .btn-add-stock,
body:not(.is-edit-mode) .btn-toggle-theme-input,
body:not(.is-edit-mode) .btn-danger.btn-ghost,
body:not(.is-edit-mode) .btn-stock-del,
body:not(.is-edit-mode) .btn-stock-order,
body:not(.is-edit-mode) .btn-theme-order {
    display: none;
}

.stock-input {
    padding-right: 10px;
    margin: 8px 0 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.stock-input input {
    width: 15ch;
    min-width: 56px;
    background: rgba(8, 10, 16, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 6px 12px;
    color: var(--text-main);
    font-family: "IBM Plex Mono", monospace;
    font-size: 13px;
}

.stock-input input::placeholder {
    color: var(--text-muted);
}

.stock-ticker-field {
    min-width: 56px;
}

.stock-name-field {
    flex: 1;
    min-width: 160px;
}

.stock-list {
    margin-top: 5px;
    display: flex;
    flex-wrap: wrap;
    padding-right: 0;
    gap: 12px;
}

.stock-tag {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 13px;
    width: calc(100% - 5px);
    min-height: 38px;
    background: rgba(79, 227, 161, 0.12);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    margin-right: 0;
    margin-top: 0px;
    border: 1px solid rgba(79, 227, 161, 0.4);
    font-family: "IBM Plex Mono", monospace;
    color: var(--mint-soft);
    user-select: none;
}

.stock-tag:hover {
    border: 1px solid rgba(79, 227, 161, 0.8);
}

.stock-label {
    text-align: left;
    margin-right: auto;
    cursor: pointer;
    font-size: 15px;
}

.stock-order {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-stock-order {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: var(--text-sub);
    font-size: 12px;
    line-height: 1;
    padding: 6px 4px 6px 6px;
    border-radius: 999px;
    cursor: pointer;
    margin-left: 2px;
}

.btn-stock-order:hover {
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-stock-del {
    margin-left: 8px;
    margin-top:-4px;
    cursor: pointer;
    color: var(--coral-soft);
    font-weight: bold;
    border: none;
    background: none;
    padding: 0;
    font-size: 20px;
}
.btn-stock-del:hover {
    background: none;
    color: var(--coral-verysoft);
}

.reveal {
    opacity: 0;
    transform: translateY(16px);
    animation: reveal 0.8s ease forwards;
}

.delay-1 {
    animation-delay: 0.15s;
}

.delay-2 {
    animation-delay: 0.3s;
}

.delay-3 {
    animation-delay: 0.45s;
}

@keyframes reveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 900px) {
    .grid {
        grid-template-columns: 1fr;
    }

    .page {
        padding: 50px 20px 80px;
    }
}
