:root {
    --bg: #0d1117;
    --card: #161b22;
    --card-border: rgba(255, 255, 255, 0.12);
    --text: #d7e2f0;
    --muted: #8a97ab;
    --cyan: #00f0ff;
    --green: #00ff66;
    --danger: #ff3366;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

@font-face {
    font-family: "Barlow Condensed";
    src: url("fonts/BarlowCondensed-500.ttf") format("truetype");
    font-style: normal;
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: "Barlow Condensed";
    src: url("fonts/BarlowCondensed-700.ttf") format("truetype");
    font-style: normal;
    font-weight: 700;
    font-display: swap;
}

@font-face {
    font-family: "Rajdhani";
    src: url("fonts/Rajdhani-500.ttf") format("truetype");
    font-style: normal;
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: "Rajdhani";
    src: url("fonts/Rajdhani-700.ttf") format("truetype");
    font-style: normal;
    font-weight: 700;
    font-display: swap;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: radial-gradient(circle at 20% 10%, #182536 0%, var(--bg) 38%),
        radial-gradient(circle at 80% 95%, #11251b 0%, var(--bg) 42%);
    color: var(--text);
    font-family: "Rajdhani", sans-serif;
}

body {
    position: relative;
    overflow-x: hidden;
}

body.modal-open {
    overflow: hidden;
}

body::before,
body::after {
    content: "";
    position: fixed;
    width: 34vw;
    height: 34vw;
    border-radius: 50%;
    filter: blur(60px);
    z-index: 0;
    pointer-events: none;
}

body::before {
    background: rgba(0, 240, 255, 0.14);
    top: -10vw;
    right: -8vw;
}

body::after {
    background: rgba(0, 255, 102, 0.11);
    bottom: -12vw;
    left: -8vw;
}

.app-shell {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: 16px 14px 28px;
    display: grid;
    gap: 14px;
}

.card {
    background: linear-gradient(180deg, rgba(31, 40, 53, 0.65), rgba(22, 27, 34, 0.9));
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 16px;
    transform: translateY(0);
    opacity: 1;
    transition: opacity 0.22s ease, transform 0.22s ease, border-color 0.2s ease;
}

.card:hover {
    border-color: rgba(0, 240, 255, 0.38);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 12px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 9, 14, 0.7);
    backdrop-filter: blur(3px);
}

.modal-window {
    position: relative;
    width: min(900px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    border-color: rgba(0, 240, 255, 0.42);
    animation: revealUp 0.24s ease-out both;
}

.modal-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.modal-toolbar p {
    margin: 0;
    letter-spacing: 0.06em;
    font-size: 0.82rem;
    color: var(--cyan);
    text-transform: uppercase;
}

.modal-close {
    width: auto;
    min-width: 100px;
    border: 1px solid rgba(0, 240, 255, 0.4);
    background: rgba(0, 240, 255, 0.08);
    color: var(--text);
    font-weight: 700;
    font-size: 0.96rem;
    border-radius: 10px;
    padding: 0 14px;
}

.is-hidden {
    display: none;
}

.app-header {
    animation: revealUp 0.45s ease-out both;
}

.eyebrow {
    margin: 0;
    color: var(--cyan);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.82rem;
}

h1,
h2 {
    margin: 6px 0;
    font-family: "Barlow Condensed", sans-serif;
    letter-spacing: 0.02em;
    color: var(--cyan);
}

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

.search-panel label,
.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.92rem;
    color: #c7d6e7;
}

.custom-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.custom-panel .subtitle {
    margin-bottom: 12px;
}

.mix-builder {
    margin-top: 12px;
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 12px;
    padding: 11px;
    background: rgba(0, 240, 255, 0.04);
}

.mix-builder > p {
    margin: 0 0 10px;
    color: #c7d6e7;
    font-size: 0.92rem;
}

.mix-result {
    margin: 10px 0 0;
    color: var(--green);
    font-weight: 700;
}

.mode-picker {
    margin-top: 12px;
}

.mode-picker p {
    margin: 0 0 8px;
    color: #c7d6e7;
    font-size: 0.92rem;
}

.touch-input,
.result-item,
.toggle-btn,
.btn-primary,
.btn-secondary {
    min-height: 48px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.touch-input {
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(0, 240, 255, 0.25);
    background: rgba(10, 14, 20, 0.85);
    color: var(--text);
    padding: 11px 12px;
    font-family: inherit;
    font-size: 1.08rem;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.touch-input:focus-visible {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.17);
    outline: none;
}

.search-results {
    margin-top: 10px;
    display: grid;
    gap: 8px;
}

.result-item {
    width: 100%;
    border: 1px solid rgba(138, 151, 171, 0.35);
    background: rgba(17, 22, 29, 0.93);
    color: var(--text);
    text-align: left;
    border-radius: 12px;
    padding: 9px 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.2s ease;
}

.result-item strong {
    font-size: 1.05rem;
}

.result-item span {
    color: var(--muted);
    font-size: 0.88rem;
}

.result-item:active,
.result-item:hover {
    transform: translateY(-1px);
    border-color: var(--cyan);
    background: rgba(0, 240, 255, 0.08);
}

.empty {
    margin: 6px 4px;
    color: var(--muted);
}

.medication-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chip {
    border: 1px solid rgba(0, 240, 255, 0.38);
    color: var(--cyan);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.note {
    margin-bottom: 0;
    color: #c5d4e4;
}

.form-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.drip-toggle {
    margin-top: 12px;
}

.drip-toggle p {
    margin: 0 0 8px;
    color: #c7d6e7;
}

.toggle-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.toggle-btn {
    border: 1px solid rgba(138, 151, 171, 0.35);
    border-radius: 10px;
    background: rgba(12, 16, 22, 0.92);
    color: var(--text);
    padding: 0 14px;
    font-family: inherit;
    font-weight: 700;
}

.toggle-btn.active {
    border-color: var(--cyan);
    color: var(--cyan);
    box-shadow: 0 0 0 2px rgba(0, 240, 255, 0.18);
}

.btn-primary {
    width: 100%;
    border: none;
    border-radius: 12px;
    background: linear-gradient(90deg, #0ad8e7, #00ff66);
    color: #081018;
    font-weight: 700;
    font-size: 1rem;
    margin-top: 14px;
}

.btn-secondary {
    width: 100%;
    border: 1px solid rgba(0, 240, 255, 0.4);
    border-radius: 12px;
    background: rgba(0, 240, 255, 0.08);
    color: var(--cyan);
    font-weight: 700;
    font-size: 1rem;
    margin-top: 10px;
}

.alert {
    margin-top: 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    padding: 11px 12px;
    font-size: 0.94rem;
}

.alert.warning {
    background: rgba(255, 165, 0, 0.09);
    border-color: rgba(255, 165, 0, 0.35);
    color: #ffd27d;
}

.alert.danger {
    background: rgba(255, 51, 102, 0.13);
    border-color: rgba(255, 51, 102, 0.45);
    color: #ff6f93;
}

.results-grid {
    margin-top: 12px;
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.result-card {
    border: 1px solid rgba(138, 151, 171, 0.24);
    border-radius: 12px;
    padding: 12px;
    background: rgba(10, 14, 20, 0.8);
}

.result-label {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.result-value {
    margin: 6px 0 0;
    color: var(--green);
    font-size: 1.72rem;
    font-weight: 700;
    line-height: 1.12;
}

@keyframes revealUp {
    from {
        opacity: 0;
        transform: translate3d(0, 12px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@media (max-width: 540px) {
    .app-shell {
        padding: 12px 10px 18px;
    }

    .card {
        border-radius: 14px;
        padding: 13px;
    }

    .result-value {
        font-size: 1.45rem;
    }
}
