/* Psix Mini App — design system.
   A fixed, premium dark theme: deep green-black surfaces with a refined jade
   accent. Kept independent of the Telegram light/dark setting so the brand
   identity stays consistent and intentional for every user. */
:root {
    /* Dark surfaces, layered for depth */
    --bg: #0c1311;
    --text: #eef3f1;
    --hint: #8a9a93;
    --card: #151e1a;
    --elevated: #1d2823;

    /* Jade accent that glows on dark */
    --accent: #46c08a;
    --accent-strong: #5fd1a0;
    --accent-grad: linear-gradient(135deg, #3fb583 0%, #268f63 100%);
    --on-accent: #ffffff;

    /* Hairlines & tints tuned for dark */
    --line: rgba(255, 255, 255, 0.09);
    --shade: rgba(255, 255, 255, 0.07);
    --tint: rgba(70, 192, 138, 0.14);

    --radius: 18px;
    --radius-sm: 12px;
    --gap: 14px;
    --shadow-1: 0 1px 1px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.34);
    --shadow-2: 0 14px 36px rgba(0, 0, 0, 0.5);
    --shadow-accent: 0 8px 24px rgba(47, 157, 110, 0.42);
}

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    background-color: var(--bg);
    /* Subtle jade aura at the top for depth. */
    background-image: radial-gradient(130% 55% at 50% -12%, rgba(70, 192, 138, 0.14) 0%, transparent 60%);
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.app {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
    min-height: 100vh;
}
/* Make room for the floating tab bar when it is on screen. */
body.nav-open .app { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

/* ---------------------------------------------------------------- Typography */
h1 { font-size: 24px; line-height: 1.2; margin: 0; letter-spacing: -0.02em; font-weight: 700; }
h2 { font-size: 19px; line-height: 1.25; margin: 0 0 12px; letter-spacing: -0.01em; font-weight: 700; }
p { margin: 0 0 12px; line-height: 1.5; }
p:last-child { margin-bottom: 0; }
.hint { color: var(--hint); font-size: 14px; line-height: 1.45; }
.center { text-align: center; }
.section-title { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--hint); margin: 4px 2px -2px; }
.stack > * + * { margin-top: var(--gap); }

/* -------------------------------------------------------------------- Icons */
.icon {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    display: inline-block;
    vertical-align: -0.18em;
    stroke: currentColor;
}
.ic-sm { width: 16px; height: 16px; }
.ic-btn { width: 20px; height: 20px; }
.ic-star { width: 16px; height: 16px; color: #f5b942; }
.ic-star polygon,
.rating-given .icon polygon,
.star.on .icon polygon {
    fill: currentColor;
}
.with-icon { display: flex; align-items: center; gap: 8px; }

/* -------------------------------------------------------------------- Cards */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-1);
}

/* --------------------------------------------------------------- Home: hero */
.home-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.home-greeting { min-width: 0; }
.home-greeting .hint { margin-top: 2px; }

.hero {
    position: relative;
    overflow: hidden;
    border: none;
    color: var(--on-accent);
    /* Deeper, muted emerald — calmer than the bright button gradient. */
    background: linear-gradient(150deg, #2e9468 0%, #1a5e41 100%);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(30, 110, 75, 0.26);
    text-align: left;
    cursor: pointer;
    display: block;
    width: 100%;
    font: inherit;
    padding: 20px;
}
.hero::after {
    content: "";
    position: absolute;
    right: -40px; top: -50px;
    width: 180px; height: 180px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.12), transparent 70%);
    pointer-events: none;
}
.hero-kicker { font-size: 13px; font-weight: 600; opacity: 0.9; display: inline-flex; align-items: center; gap: 6px; }
.hero-title { font-size: 21px; font-weight: 700; margin: 8px 0 4px; letter-spacing: -0.01em; }
.hero-sub { font-size: 14px; opacity: 0.92; line-height: 1.4; max-width: 88%; }
.hero-cta {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 16px; padding: 9px 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px; font-size: 14px; font-weight: 600;
    backdrop-filter: blur(4px);
}

/* --------------------------------------------------------------- Home: tiles */
.tile {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    text-align: left;
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    color: inherit;
    font: inherit;
    box-shadow: var(--shadow-1);
    transition: transform 0.12s ease;
}
.tile:active { transform: scale(0.985); }
.tile .tile-icon {
    flex: 0 0 auto;
    width: 46px; height: 46px;
    border-radius: 14px;
    display: grid; place-items: center;
    background: var(--tint);
    color: var(--accent);
}
.tile.t-specialists .tile-icon { background: rgba(70, 192, 138, 0.18); color: #5fd1a0; }
.tile.t-articles .tile-icon { background: rgba(90, 150, 235, 0.20); color: #7fb0f5; }
.tile.t-consultations .tile-icon { background: rgba(225, 170, 80, 0.20); color: #e6b964; }
.tile .tile-title { font-weight: 600; font-size: 16px; }
.tile .tile-sub { color: var(--hint); font-size: 13px; margin-top: 3px; line-height: 1.35; }
.tile .chev { margin-left: auto; color: var(--hint); width: 22px; height: 22px; opacity: 0.55; }

/* ------------------------------------------------------------------ Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 15px 18px;
    border: none;
    border-radius: 14px;
    background: var(--accent-grad);
    color: var(--on-accent);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-accent);
    transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn:active { transform: scale(0.98); }
.btn.secondary {
    background: var(--card);
    color: var(--accent);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-1);
}
.btn.ghost { background: transparent; color: var(--accent); box-shadow: none; }
.btn[disabled] { opacity: 0.5; cursor: default; transform: none; }

/* ----------------------------------------------------------- Screening flow */
.option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--line);
    background: var(--card);
    color: inherit;
    font: inherit;
    font-size: 15px;
    cursor: pointer;
    box-shadow: var(--shadow-1);
    transition: transform 0.12s ease, border-color 0.12s ease;
}
.option::before {
    content: "";
    flex: 0 0 auto;
    width: 20px; height: 20px;
    border-radius: 50%;
    border: 2px solid var(--line);
}
.option:active { transform: scale(0.98); border-color: var(--accent); }
.option.selected { border-color: var(--accent); }
.option.selected::before { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px var(--card); }

.topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.topline h2 { margin: 0; }
.progress { height: 6px; border-radius: 999px; background: var(--shade); overflow: hidden; margin-bottom: 20px; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--accent-grad); transition: width 0.3s cubic-bezier(0.22, 1, 0.36, 1); }

/* ----------------------------------------------------- Specialist / consult */
.spec-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.spec-head:last-child { margin-bottom: 0; }
.spec-head .spec-name { margin: 0; }
.name-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.avatar {
    flex: 0 0 auto;
    display: grid; place-items: center;
    width: 48px; height: 48px;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, hsl(var(--a, 150), 52%, 56%), hsl(var(--a, 150), 48%, 42%));
}
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.spec-name { font-weight: 700; font-size: 16px; }
.spec-meta { color: var(--hint); font-size: 13px; margin: 4px 0; }
.spec-bio { font-size: 14px; line-height: 1.5; margin: 4px 0 14px; }
.spec-reason { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; line-height: 1.5; margin: 4px 0 14px; padding: 10px 12px; background: var(--tint); border-radius: var(--radius-sm); color: var(--text); }
.spec-reason .icon { color: var(--accent-strong); margin-top: 2px; }
.price-row { display: flex; align-items: baseline; gap: 6px; margin: 0 0 14px; }
.price { font-weight: 700; font-size: 17px; }
.price-unit { color: var(--hint); font-size: 13px; }

/* -------------------------------------------------------------------- Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--shade);
    color: var(--hint);
    white-space: nowrap;
}
.badge.low, .badge.active, .badge.accepted, .badge.completed { background: rgba(70, 192, 138, 0.16); color: #5fd1a0; }
.badge.medium, .badge.requested { background: rgba(225, 170, 80, 0.16); color: #e6b964; }
.badge.high { background: rgba(232, 140, 80, 0.16); color: #f0975a; }
.badge.crisis, .badge.cancelled { background: rgba(232, 100, 95, 0.16); color: #ef8480; }

.field-label { font-size: 13px; color: var(--hint); margin-bottom: 4px; }

/* ------------------------------------------------------------- Filter chips */
.tabs { display: flex; gap: 8px; overflow-x: auto; margin-bottom: var(--gap); padding: 2px 2px 6px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
    flex: 0 0 auto;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--hint);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.12s ease;
}
.tab:active { transform: scale(0.95); }
.tab.active { background: var(--accent-grad); color: var(--on-accent); border-color: transparent; box-shadow: var(--shadow-accent); }

/* -------------------------------------------------------------------- Alert */
.alert {
    border-radius: var(--radius);
    padding: 18px;
    background: rgba(232, 100, 95, 0.12);
    border: 1px solid rgba(232, 100, 95, 0.34);
}
.alert h2 { color: #ef8480; }

/* ----------------------------------------------------------- Empty / states */
.empty { text-align: center; color: var(--hint); padding: 48px 24px; }
.empty .empty-icon { display: inline-block; margin-bottom: 14px; opacity: 0.7; }
.empty .empty-icon .icon { width: 44px; height: 44px; }
.hero-icon { display: flex; justify-content: center; }
.hero-icon-svg { width: 56px; height: 56px; color: var(--accent); }
.hero-icon-svg.ok { color: var(--accent-strong); }
.hero-icon-svg.muted { color: var(--hint); }

/* Contact gate (shown until the user shares their phone) */
.gate { padding-top: 12vh; }
.gate h2 { margin: 4px 0 0; }
.gate p { max-width: 30em; }

/* --------------------------------------------------------------- Skeletons */
.skeleton {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-1);
}
.sk-line, .sk-circle { background: var(--shade); position: relative; overflow: hidden; border-radius: 8px; }
.sk-circle { width: 48px; height: 48px; border-radius: 50%; flex: 0 0 auto; }
.sk-line { height: 12px; }
.sk-line.sm { height: 10px; }
.sk-row { display: flex; align-items: center; gap: 12px; }
.sk-grow { flex: 1; }
.sk-line + .sk-line { margin-top: 10px; }
.skeleton .sk-block { margin-top: 14px; }
.skeleton .sk-block .sk-line { height: 38px; border-radius: 12px; }
.shimmer::after {
    content: "";
    position: absolute; inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
    animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

.spinner { display: grid; place-items: center; gap: 14px; color: var(--hint); padding: 56px 16px; }
.spinner .ring {
    width: 34px; height: 34px; border-radius: 50%;
    border: 3px solid var(--shade); border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ Ratings */
.spec-rating { font-size: 13px; color: var(--hint); display: inline-flex; align-items: center; gap: 4px; }
.rating-given { display: inline-flex; gap: 2px; margin-top: 8px; }
.rate-link {
    background: var(--tint); border: none; color: var(--accent); font: inherit; font-weight: 600;
    padding: 9px 14px; margin-top: 12px; border-radius: 999px; cursor: pointer; align-self: flex-start;
}
.stars { display: flex; gap: 10px; justify-content: center; margin: 12px 0 18px; }
.star {
    background: none; border: none; cursor: pointer; padding: 4px;
    line-height: 0; color: rgba(255, 255, 255, 0.16);
    transition: transform 0.12s ease, color 0.12s ease;
}
.star .icon { width: 40px; height: 40px; }
.star:active { transform: scale(1.2); }
.star.on { color: #f5b942; }
.rate-comment {
    width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--line);
    background: var(--elevated); color: var(--text); font: inherit; padding: 14px; resize: vertical;
}
.rate-comment::placeholder { color: var(--hint); }

/* ------------------------------------------------------------------ Articles */
.article-item { display: block; width: 100%; text-align: left; border: 1px solid var(--line); cursor: pointer; color: inherit; font: inherit; }
.article-item:active { transform: scale(0.99); }
.article-title { font-weight: 700; font-size: 16px; line-height: 1.3; }
.article-summary { color: var(--hint); font-size: 14px; margin-top: 6px; line-height: 1.45; }
.article-by { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); font-size: 13px; font-weight: 600; margin-top: 10px; }
.article-head { margin-bottom: 4px; }
.article-body { white-space: pre-wrap; line-height: 1.65; font-size: 16px; }

/* ------------------------------------------------------------- Bottom tab bar */
.tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    display: flex;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: var(--card);
    background: color-mix(in srgb, var(--card) 88%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid var(--line);
}
.tabbar.hidden { display: none; }
.tabbar-btn {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 0;
    border: none; background: none; cursor: pointer;
    color: var(--hint); font: inherit;
    transition: color 0.12s ease;
}
.tabbar-btn .tabbar-icon { width: 24px; height: 24px; opacity: 0.85; transition: opacity 0.12s ease, transform 0.12s ease; }
.tabbar-btn .tabbar-label { font-size: 11px; font-weight: 600; }
.tabbar-btn:active { transform: scale(0.92); }
.tabbar-btn.active { color: var(--accent); }
.tabbar-btn.active .tabbar-icon { opacity: 1; transform: translateY(-1px); }

/* ----------------------------------------------------------------- Animations */
#app > * { animation: viewIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Gentle stagger for the home feature list. */
.home-list > * { animation: cardIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both; }
.home-list > *:nth-child(1) { animation-delay: 0.03s; }
.home-list > *:nth-child(2) { animation-delay: 0.07s; }
.home-list > *:nth-child(3) { animation-delay: 0.11s; }
.home-list > *:nth-child(4) { animation-delay: 0.15s; }
.home-list > *:nth-child(5) { animation-delay: 0.19s; }
@keyframes cardIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    *, #app > *, .home-list > * { animation: none !important; transition: none !important; }
}

/* Language switcher (home top bar) */
.home-topbar { display: flex; justify-content: flex-end; margin-bottom: -4px; }
.lang-switch {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 999px;
}
.lang-btn {
    border: 0;
    background: transparent;
    color: var(--text);
    opacity: 0.55;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 5px 11px;
    border-radius: 999px;
    cursor: pointer;
    transition: opacity 0.15s ease, background 0.15s ease;
}
.lang-btn.active { opacity: 1; background: var(--accent-grad); color: #07120d; }

/* AI supportive note on the screening result */
.ai-note { border-color: rgba(70, 192, 138, 0.35); background: rgba(70, 192, 138, 0.07); }
.ai-note-head {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--accent-strong);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.02em;
}
.ai-note-body { margin: 8px 0 0; line-height: 1.5; color: var(--text); }

/* Article authoring form (verified specialists) */
.write-article { display: inline-flex; align-items: center; gap: 6px; width: auto; margin-top: 6px; }
.form-field { margin-bottom: 4px; }
.form-input {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--elevated);
    color: var(--text);
    font: inherit;
    padding: 12px 14px;
}
textarea.form-input { resize: vertical; line-height: 1.5; }
.form-input::placeholder { color: var(--hint); }
.form-input:focus { outline: none; border-color: var(--accent); }
