* {
    box-sizing: border-box;
}

:root {
    --accent: #22d3ee;
    --accent-rgb: 34, 211, 238;
    --accent-bright: #67e8f9;
    --accent-soft: #cffafe;
    --accent-panel: #0b1116;
    --bg-deep: #000000;
    --bg: #040912;
    --panel: rgba(11, 17, 22, 0.93);
    --panel-strong: rgba(7, 12, 18, 0.98);
    --panel-border: rgba(34, 211, 238, 0.24);
    --text: #f4fbfd;
    --muted: rgba(244, 251, 253, 0.76);
    --danger: #ff6b6b;
    --danger-soft: rgba(255, 107, 107, 0.16);
    --success-soft: rgba(34, 197, 94, 0.14);
    --shadow: 0 18px 42px rgba(0, 0, 0, 0.58);
    --radius: 18px;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.18), transparent 28%),
        radial-gradient(circle at left center, rgba(var(--accent-rgb), 0.10), transparent 26%),
        linear-gradient(180deg, var(--bg-deep) 0%, var(--bg) 100%);
}

body.login-page {
    min-height: 100vh;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    color: var(--muted);
    font-size: 0.95rem;
}

input,
textarea {
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(var(--accent-rgb), 0.24);
    background: rgba(0, 0, 0, 0.36);
    color: var(--text);
    padding: 0.95rem 1rem;
    font: inherit;
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

input:focus,
textarea:focus {
    border-color: rgba(var(--accent-rgb), 0.72);
    box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.16), 0 0 14px rgba(var(--accent-rgb), 0.14);
}

textarea {
    resize: vertical;
    min-height: 140px;
    line-height: 1.6;
}

button,
.btn {
    appearance: none;
    border: none;
    border-radius: 12px;
    padding: 0.78rem 1rem;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

button:hover,
.btn:hover {
    transform: translateY(-1px);
}

.btn-compact {
    padding: 0.62rem 0.9rem;
    font-size: 0.92rem;
    border-radius: 11px;
}

.btn-primary {
    background: linear-gradient(180deg, rgba(16, 52, 60, 0.98), rgba(8, 28, 34, 0.98));
    color: #f4feff;
    border: 1px solid #6ffaff;
    box-shadow: 0 0 24px rgba(57, 231, 240, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.btn-secondary {
    color: var(--text);
    border: 1px solid rgba(var(--accent-rgb), 0.22);
    background: linear-gradient(180deg, rgba(18, 26, 30, 0.98), rgba(9, 14, 17, 0.99));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 0 12px rgba(var(--accent-rgb), 0.08);
}

.btn-danger {
    color: #ffd3d3;
    border: 1px solid rgba(255, 107, 107, 0.28);
    background: linear-gradient(180deg, rgba(72, 24, 28, 0.98), rgba(44, 14, 18, 0.98));
}

.btn-full {
    width: 100%;
}

.small {
    font-size: 0.86rem;
}

.muted {
    color: var(--muted);
}

.eyebrow {
    margin-bottom: 0.5rem;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: rgba(var(--accent-rgb), 0.78);
}

.workflow-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
    border: 1px solid rgba(var(--accent-rgb), 0.5);
    background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.22), rgba(var(--accent-rgb), 0.11));
    color: #f4feff;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.stack-lg,
.stack-xl {
    display: flex;
    flex-direction: column;
}

.stack-lg {
    gap: 1rem;
}

.stack-xl {
    gap: 1.5rem;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.login-card {
    width: min(100%, 460px);
    padding: 2rem;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.helper-card,
.sidebar-box,
.panel,
.stat-card,
.alert,
.login-card {
    box-shadow: var(--shadow);
}

.helper-card,
.sidebar-box,
.panel,
.stat-card,
.alert {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
}

.helper-card,
.sidebar-box {
    padding: 1rem;
}

.helper-card code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: rgba(var(--accent-rgb), 0.08);
    padding: 0.12rem 0.4rem;
    border-radius: 6px;
}

.app-shell {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.5rem;
    background: linear-gradient(180deg, rgba(5, 10, 14, 0.94), rgba(4, 8, 12, 0.96));
    border-right: 1px solid rgba(var(--accent-rgb), 0.16);
    box-shadow: inset -1px 0 0 rgba(var(--accent-rgb), 0.04), 0 0 26px rgba(var(--accent-rgb), 0.04);
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sidebar-title {
    margin: 0;
    font-size: 2.15rem;
    line-height: 1.05;
}

.sidebar-subtitle {
    color: var(--muted);
    margin-bottom: 0;
}

.sidebar-nav {
    display: grid;
    gap: 0.65rem;
}

.sidebar-nav a {
    color: var(--text);
    text-decoration: none;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    border: 1px solid transparent;
    background: linear-gradient(180deg, rgba(14, 18, 22, 0.96), rgba(10, 13, 16, 0.98));
}

.sidebar-nav a:hover {
    border-color: rgba(var(--accent-rgb), 0.28);
}

.sidebar-box p {
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.55;
}

.content {
    padding: 1.5rem;
}

.page-header {
    margin-bottom: 1.25rem;
}

.page-header h2 {
    margin-bottom: 0.55rem;
    font-size: clamp(2rem, 4vw, 3.2rem);
}

.page-copy {
    color: var(--muted);
    font-size: 1.05rem;
    max-width: 900px;
    line-height: 1.6;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    padding: 1.2rem;
    background: linear-gradient(180deg, rgba(7, 12, 18, 0.96), rgba(7, 11, 16, 0.98));
    box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.05), 0 0 26px rgba(var(--accent-rgb), 0.05);
}

.stat-label {
    color: rgba(var(--accent-rgb), 0.76);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.74rem;
}

.stat-card strong {
    display: block;
    margin: 0.25rem 0 0.45rem;
    font-size: 2.3rem;
    line-height: 1;
}

.stat-card p {
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.5;
}

.panel {
    padding: 1.3rem;
    background: linear-gradient(180deg, rgba(11, 17, 22, 0.96), rgba(8, 13, 18, 0.98));
    box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.04), 0 0 24px rgba(var(--accent-rgb), 0.04);
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel-head h3 {
    margin-bottom: 0.35rem;
    font-size: 1.5rem;
}

.panel-head p {
    margin-bottom: 0;
    color: var(--muted);
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.links-stack {
    display: grid;
    gap: 1rem;
}

.link-card {
    display: grid;
    grid-template-columns: minmax(180px, 0.9fr) minmax(280px, 1.4fr) minmax(160px, auto);
    gap: 0.9rem;
    padding: 0.95rem;
    border-radius: 16px;
    border: 1px solid rgba(var(--accent-rgb), 0.12);
    background: rgba(0, 0, 0, 0.18);
}

.link-actions {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    justify-self: end;
    text-align: right;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.notes-area {
    min-height: 420px;
}

.panel-action {
    align-self: flex-start;
    margin-left: auto;
}

.notes-panel label span,
.panel label span {
    color: rgba(var(--accent-rgb), 0.86);
    font-size: 0.84rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.action-bar {
    position: sticky;
    bottom: 1rem;
    display: flex;
    justify-content: flex-end;
    padding-bottom: 0.25rem;
}

.alert {
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
}

.alert-success {
    border-color: rgba(34, 197, 94, 0.32);
    background: var(--success-soft);
}

.alert-error {
    border-color: rgba(255, 107, 107, 0.32);
    background: rgba(255, 107, 107, 0.12);
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
        border-right: none;
        border-bottom: 1px solid rgba(var(--accent-rgb), 0.12);
    }

    .stats-grid,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .link-card {
        grid-template-columns: 1fr;
    }

    .link-actions {
        align-items: center;
        justify-content: flex-end;
        justify-self: stretch;
    }
}

@media (max-width: 720px) {
    .content,
    .sidebar,
    .login-card {
        padding: 1rem;
    }

    .sidebar-title {
        font-size: 1.8rem;
    }

    .page-header h2 {
        font-size: 2.2rem;
    }

    .panel-head,
    .panel-head-stack-mobile {
        flex-direction: column;
    }

    .notes-area {
        min-height: 320px;
    }

    .action-bar {
        justify-content: stretch;
    }

    .action-bar .btn {
        width: 100%;
    }

    .panel-action {
        margin-left: 0;
    }
}


.app-shell-compact {
    grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar-compact {
    gap: 0.9rem;
}

.sidebar-box-tight {
    padding: 0.85rem 0.95rem;
}

.content-compact {
    padding: 1.25rem;
}

.compact-form {
    gap: 1.15rem;
}

.panel-head-inline {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
}

.panel-head-inline h2,
.panel-head-inline h3 {
    margin-bottom: 0.35rem;
}

.panel-head-inline p {
    margin-bottom: 0;
}

.compact-link-card {
    padding: 0.9rem;
}

.link-row-top {
    display: flex;
    gap: 0.9rem;
    align-items: end;
}

.inline-grow {
    flex: 1 1 auto;
    min-width: 0;
}

.inline-actions-right {
    flex: 0 0 auto;
    justify-content: flex-end;
    align-items: center;
    gap: 0.45rem;
    display: flex;
    flex-wrap: wrap;
}

.link-label-wrap input,
.compact-link-card input[type="url"] {
    min-height: 44px;
}

.links-stack {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.link-card {
    padding: 1rem;
    background: linear-gradient(180deg, rgba(7, 12, 18, 0.96), rgba(7, 11, 16, 0.98));
    border: 1px solid rgba(var(--accent-rgb), 0.18);
    border-radius: 16px;
    box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.04), 0 0 20px rgba(var(--accent-rgb), 0.05);
}

.link-card label + label {
    margin-top: 0.7rem;
}

.notes-panel .panel-head-inline {
    align-items: center;
}

.notes-area {
    min-height: 420px;
}

@media (max-width: 980px) {
    .app-shell-compact {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid rgba(var(--accent-rgb), 0.16);
    }
}

@media (max-width: 760px) {
    .panel-head-inline,
    .link-row-top,
    .notes-panel .panel-head-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .inline-actions-right {
        justify-content: flex-start;
    }

    .notes-area {
        min-height: 300px;
    }
}
