/* === VORSTADT — Minimal Dark Protocol UI === */

:root {
    --bg: #0a0a0a;
    --bg2: #141414;
    --bg3: #1e1e1e;
    --text: #d4d4d4;
    --dim: #666;
    --accent: #e03030;
    --green: #3a9a5c;
    --orange: #c87820;
    --blue: #3080c0;
    --card: #181818;
    --border: rgba(255,255,255,0.06);
    --radius: 14px;
    --nav-h: 60px;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

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

/* Щадящий скроллинг */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    height: 100%; width: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    user-select: none;
    -webkit-user-select: none;
}

#app {
    height: 100vh; height: 100dvh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* --- Boot Screen --- */
#boot-screen {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    height: 100%;
    gap: 24px;
    padding: 20px;
}
.boot-logo {
    font-size: 2rem;
    letter-spacing: 0.3rem;
    color: var(--accent);
    font-weight: 800;
    margin: 0;
}
.boot-progress {
    width: 160px;
    height: 4px;
    background: var(--bg2);
    border-radius: 2px;
    overflow: hidden;
}
.boot-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    width: 0%;
    transition: width 0.4s ease;
}
.boot-status {
    font-size: 0.8rem;
    color: var(--dim);
    min-height: 1.2em;
}
.boot-status.error { color: #ff4444; }

/* --- View Container --- */
.view-container {
    display: flex; flex-direction: column;
    height: 100%;
    overflow: hidden;
    padding-bottom: calc(var(--nav-h) + var(--safe-b));
}

.view-header {
    padding: 16px 20px 0;
    flex-shrink: 0;
}
.view-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
    margin: 0 0 2px;
    letter-spacing: 0.02em;
}
.header-sub {
    font-size: 0.75rem;
    color: var(--dim);
    margin-bottom: 4px;
}

.scroll-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px 80px;
    scroll-behavior: smooth;
    overscroll-behavior-y: contain;
}

.empty-state {
    text-align: center;
    color: var(--dim);
    padding: 60px 20px;
    font-size: 0.85rem;
}

/* --- Tab Bar --- */
.tab-bar {
    display: flex;
    gap: 2px;
    background: var(--bg2);
    border-radius: 10px;
    padding: 3px;
    margin-top: 10px;
}
.tab {
    flex: 1;
    text-align: center;
    padding: 8px 0;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--dim);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.tab.active {
    background: var(--bg3);
    color: var(--text);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Planner type filter (MVP: товар | деньги | хранение | производство) */
.planner-type-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}
.planner-type-tab {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    font-size: 1.1rem;
    color: var(--dim);
    background: var(--bg2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.planner-type-tab.active {
    background: var(--accent);
    color: #fff;
}

/* --- Plan Cards --- */
.plan-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    transition: transform 0.15s;
}
.plan-card:active { transform: scale(0.985); }
.plan-card.faded { opacity: 0.7; }

.plan-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.plan-icon {
    font-size: 1rem;
    color: var(--accent);
    flex-shrink: 0;
}
.plan-title {
    font-weight: 700;
    font-size: 0.9rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.plan-status {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.plan-desc {
    font-size: 0.78rem;
    color: var(--dim);
    margin-bottom: 6px;
    line-height: 1.3;
}
.plan-meta {
    display: flex;
    gap: 12px;
    font-size: 0.72rem;
    color: var(--dim);
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.plan-meta .result-tag {
    color: var(--green);
    font-weight: 600;
}
.plan-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* --- Progress Bar --- */
.progress-bar {
    height: 4px;
    background: var(--bg2);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}
.progress-fill {
    height: 100%;
    background: var(--green);
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* --- Contracts --- */
.contract-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s;
}
.contract-card:active { transform: scale(0.985); }

.contract-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px;
}
.contract-status {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.contract-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-top: 2px;
}
.contract-vol {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
    flex-shrink: 0;
}

.contract-details {
    padding: 0 14px 14px;
}
.contract-card:not(.expanded) .contract-details { display: none; }

.contract-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}
.contract-terms {
    font-size: 0.78rem;
    color: var(--dim);
    padding: 8px 0;
    line-height: 1.4;
    border-bottom: 1px solid var(--border);
}

/* Signing block */
.sign-block {
    margin: 10px 0;
    padding: 10px;
    background: var(--bg2);
    border-radius: 10px;
}
.sign-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    padding: 4px 0;
    color: var(--dim);
}
.sign-row.signed { color: var(--green); }

/* Files */
.files-block { margin: 8px 0; }
.file-row {
    font-size: 0.75rem;
    padding: 6px 8px;
    background: var(--bg2);
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
}
.file-row:active { background: var(--bg3); }

.contract-hash {
    font-family: monospace;
    font-size: 0.6rem;
    margin-top: 8px;
}
.contract-link-block { margin-top: 8px; }
.contract-link-block a { text-decoration: none; }

.contract-paste-block { padding: 20px 0; }
.contract-url-block { margin: 20px 0; }
.contract-url-row { display: flex; gap: 8px; align-items: center; }
.contract-url-row .input { flex: 1; }
.contract-page-card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.contract-page-row { display: flex; justify-content: space-between; padding: 6px 0; }
.contract-page-row .strong { font-weight: 700; }
.contract-status-badge { font-size: 0.65rem; padding: 2px 8px; border-radius: 6px; background: var(--bg3); }
.contract-status-badge.signed { color: var(--green); }
.contract-page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.contract-qr-block { margin-top: 16px; text-align: center; }
.contract-qr-img { width: 160px; height: 160px; border-radius: 8px; background: #fff; padding: 8px; }

.contract-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* --- Contacts --- */
.contact-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s;
}
.contact-card:active { transform: scale(0.985); }

.contact-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
}
.contact-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--bg3);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    color: var(--accent);
    flex-shrink: 0;
}
.contact-info { flex: 1; min-width: 0; }
.contact-name {
    font-weight: 700;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.contact-username {
    font-size: 0.72rem;
    color: var(--dim);
}
.contact-stats {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.stat-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(255,255,255,0.05);
}
.stat-badge.green { color: var(--green); }
.stat-badge.orange { color: var(--orange); }

.contact-details {
    padding: 0 14px 14px;
}
.contact-card:not(.expanded) .contact-details { display: none; }

.mini-contract-ref {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    padding: 4px 8px;
    background: var(--bg2);
    border-radius: 6px;
    margin-bottom: 3px;
}
.contact-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

/* --- Profile --- */
.profile-section {
    text-align: center;
    padding: 30px 0 20px;
}
.profile-avatar {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: var(--bg3);
    border: 3px solid var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--accent);
    margin-bottom: 12px;
}
.profile-name {
    font-weight: 800;
    font-size: 1.2rem;
}
.profile-username {
    font-size: 0.8rem;
    color: var(--dim);
    margin-top: 2px;
}
.profile-id {
    font-family: monospace;
    font-size: 0.7rem;
    color: var(--dim);
    margin-top: 6px;
}

.info-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
}
.info-label {
    font-size: 0.7rem;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.info-value {
    font-size: 0.85rem;
    color: var(--text);
}
.info-value.mono {
    font-family: monospace;
    font-size: 0.75rem;
    word-break: break-all;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}
.stat-cell {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 8px;
    text-align: center;
}
.stat-num {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
}
.stat-label {
    font-size: 0.65rem;
    color: var(--dim);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-actions {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.profile-footer {
    text-align: center;
    font-size: 0.7rem;
    color: var(--dim);
    margin-top: 30px;
    padding: 20px;
    line-height: 1.6;
}

/* --- Navigation Bar --- */
.nav-bar {
    position: fixed;
    bottom: 0; left: 0;
    width: 100%;
    height: calc(var(--nav-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    background: rgba(10,10,10,0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
}
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--dim);
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    cursor: pointer;
    transition: color 0.2s;
    padding: 2px 0;
    min-width: 0; /* prevent overflow with 5 tabs */
    -webkit-touch-callout: none;
}
.nav-item.active { color: var(--accent); }
.nav-icon {
    font-size: 1.1rem;
    margin-bottom: 2px;
    display: block;
}
/* Ensure 44px minimum touch target */
@media (max-width: 380px) {
    .nav-item { font-size: 0.5rem; letter-spacing: 0; }
    .nav-icon { font-size: 1rem; }
}

/* --- FAB --- */
.fab {
    position: fixed;
    bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
    right: 18px;
    width: 48px; height: 48px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 300;
    box-shadow: 0 4px 16px rgba(224,48,48,0.3);
    cursor: pointer;
    z-index: 50;
    transition: transform 0.15s, box-shadow 0.15s;
    border: none;
    -webkit-appearance: none;
}
.fab:active {
    transform: scale(0.9);
    box-shadow: 0 2px 8px rgba(224,48,48,0.4);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    padding: 16px;
}
.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 20px 20px 16px 16px;
    padding: 24px 20px;
    width: 100%;
    max-width: 420px;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-title {
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 16px;
}
.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* --- Inputs --- */
.input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
    margin-bottom: 8px;
    font-family: inherit;
    -webkit-appearance: none;
    transition: border-color 0.2s;
}
.input:focus { border-color: var(--accent); }
select.input { cursor: pointer; }
textarea.input { resize: vertical; min-height: 60px; }

/* --- Buttons --- */
.btn {
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    -webkit-appearance: none;
}
.btn:active { transform: scale(0.96); }
.btn-accent {
    background: var(--accent);
    color: #fff;
}
.btn-green {
    background: var(--green);
    color: #fff;
}
.btn-ghost {
    background: transparent;
    color: var(--dim);
    border: 1px solid var(--border);
}
.btn-danger {
    background: transparent;
    color: var(--accent);
    border: 1px solid rgba(224,48,48,0.2);
}
.btn.wide { width: 100%; }

.btn-sm {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    -webkit-appearance: none;
}
.btn-sm:active { transform: scale(0.95); }
.btn-sm.btn-green { background: var(--green); color: #fff; }
.btn-sm.btn-accent { background: var(--accent); color: #fff; }
.btn-sm.btn-ghost { background: transparent; color: var(--dim); border: 1px solid var(--border); }

/* --- Board (Marketplace) --- */
.wallet-strip {
    flex-shrink: 0;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
}
.wallet-strip:active { background: var(--bg3); }
.wallet-row {
    display: flex;
    align-items: center;
}
.wallet-cell {
    flex: 1;
    text-align: center;
}
.wallet-num {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
}
.wallet-label {
    font-size: 0.55rem;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 1px;
}
.wallet-divider {
    width: 1px;
    height: 28px;
    background: var(--border);
}

.board-streams {
    flex: 1;
    display: flex;
    overflow: hidden;
}
.board-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.board-column:first-child { border-right: 1px solid var(--border); }
.board-col-header {
    padding: 8px 12px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.demand-header { color: var(--accent); background: rgba(224,48,48,0.04); }
.supply-header { color: var(--green); background: rgba(58,154,92,0.04); }
.board-count {
    opacity: 0.5;
    font-weight: 400;
}
.board-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px;
    padding-bottom: 80px;
}
.board-empty {
    text-align: center;
    color: var(--dim);
    font-size: 0.78rem;
    padding: 40px 12px;
}

.market-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
    transition: transform 0.12s;
}
.market-card:active { transform: scale(0.98); }
.market-demand { border-left: 3px solid var(--accent); }
.market-supply { border-left: 3px solid var(--green); }
.market-card.mine { opacity: 0.65; }

.market-card-top {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.market-icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 1px;
}
.market-demand .market-icon { color: var(--accent); }
.market-supply .market-icon { color: var(--green); }
.market-card-info { flex: 1; min-width: 0; }
.market-title {
    font-weight: 700;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.market-origin {
    font-size: 0.65rem;
    color: var(--dim);
    margin-top: 1px;
}
.market-vol {
    font-size: 1rem;
    font-weight: 800;
    flex-shrink: 0;
    color: var(--text);
}
.market-desc {
    font-size: 0.72rem;
    color: var(--dim);
    margin-top: 4px;
    line-height: 1.3;
}
.market-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    gap: 8px;
}
.market-date {
    font-size: 0.65rem;
    color: var(--dim);
}
.market-mine-tag {
    font-size: 0.6rem;
    color: var(--dim);
    background: rgba(255,255,255,0.04);
    padding: 2px 8px;
    border-radius: 6px;
}

/* Published badge in planner */
.published-badge {
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--green);
    background: rgba(58,154,92,0.1);
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}
.plan-card.published { border-left: 3px solid var(--green); }

.btn-sm.btn-board {
    background: rgba(58,154,92,0.15);
    color: var(--green);
    border: 1px solid rgba(58,154,92,0.2);
}

/* --- Documents (Zones + Docs) --- */
.zone-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}
.zone-square {
    aspect-ratio: 1;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}
.zone-square:active { transform: scale(0.98); }
.zone-square.selected {
    border-color: var(--accent);
    background: rgba(224, 48, 48, 0.08);
}
.zone-square-icon {
    font-size: 1.5rem;
    color: var(--accent);
    margin-bottom: 4px;
}
.zone-square-name {
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.zone-square-op {
    font-size: 0.6rem;
    color: var(--dim);
}
.zone-detail {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 20px;
}
.zone-detail-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.zone-detail-name { font-weight: 700; }
.zone-detail-type, .zone-detail-operator {
    font-size: 0.75rem;
    color: var(--dim);
}
.zone-loss {
    font-size: 0.7rem;
    color: var(--accent);
}
.docs-list { margin-bottom: 12px; }
.doc-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--bg2);
    border-radius: 10px;
    margin-bottom: 6px;
}
.doc-card-row { flex: 1; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.doc-in { color: var(--dim); }
.doc-arrow { color: var(--accent); font-size: 0.8rem; }
.doc-out { font-weight: 600; }
.doc-meta { font-size: 0.65rem; color: var(--dim); }
.doc-loss { color: var(--accent); margin-right: 8px; }
.doc-form-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.empty-state.small { padding: 20px; font-size: 0.8rem; }

/* --- Catalog --- */
.catalog-search {
    margin-bottom: 16px;
}
.catalog-section-title {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--dim);
    margin: 16px 0 8px;
}
.catalog-entry {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 6px;
}
.cat-entry-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.cat-entry-name {
    font-weight: 700;
    font-size: 0.9rem;
}
.cat-entry-conf {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--green);
    background: rgba(58,154,92,0.1);
    padding: 2px 8px;
    border-radius: 6px;
}
.cat-entry-bar {
    height: 3px;
    background: var(--bg2);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 6px;
}
.cat-entry-fill {
    height: 100%;
    background: var(--green);
    border-radius: 2px;
    transition: width 0.3s;
}
.cat-entry-meta {
    display: flex;
    gap: 12px;
    font-size: 0.65rem;
    color: var(--dim);
}
.cat-add-plan { margin-top: 8px; }
.catalog-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.cat-pill {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.72rem;
    cursor: pointer;
    display: flex;
    gap: 6px;
    align-items: center;
    transition: all 0.15s;
}
.cat-pill:active { transform: scale(0.96); background: var(--bg3); }
.cat-name { font-weight: 600; }
.cat-count { color: var(--dim); font-size: 0.6rem; }
.cat-conf { color: var(--green); font-size: 0.55rem; font-weight: 700; }
.catalog-footer {
    text-align: center;
    font-size: 0.65rem;
    padding: 30px 0;
    line-height: 1.6;
}

/* --- Voice --- */
.fab-mic {
    background: var(--accent);
    animation: mic-pulse 2s ease infinite;
}
.fab-secondary {
    bottom: calc(var(--nav-h) + var(--safe-b) + 76px);
    width: 36px; height: 36px;
    font-size: 1.1rem;
    background: var(--bg3);
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(224,48,48,0.3); }
    50% { box-shadow: 0 4px 24px rgba(224,48,48,0.6); }
}
.voice-modal {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}
.voice-pulse {
    width: 80px; height: 80px;
    border-radius: 50%;
    background: var(--accent);
    animation: voice-anim 1s ease infinite;
    margin-bottom: 20px;
}
@keyframes voice-anim {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.15); opacity: 1; }
}
.voice-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}
.voice-raw {
    font-style: italic;
    font-size: 0.85rem;
    color: var(--text);
    padding: 10px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 8px;
    line-height: 1.4;
}
.voice-confidence {
    font-size: 0.7rem;
    margin-bottom: 12px;
}
.voice-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--dim);
    padding: 8px 0;
    cursor: pointer;
}
.voice-toggle input { accent-color: var(--green); }

/* --- Mobile-First Fixes --- */

/* Щадящий скролл: плавность, без резинки */
.scroll-content, .board-scroll {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    scroll-padding-bottom: 20px;
}

/* Fix input zoom on iOS (font-size >= 16px) */
@media screen and (max-width: 768px) {
    .input { font-size: 16px; }
    select.input { font-size: 16px; }
}

/* Board columns: stack on very narrow screens */
@media (max-width: 340px) {
    .board-streams { flex-direction: column; }
    .board-column:first-child { border-right: none; border-bottom: 1px solid var(--border); }
}

/* Modal: full-width on mobile, account for keyboard */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .modal { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}

/* Tighter spacing on small screens */
@media (max-width: 380px) {
    .view-header { padding: 12px 14px 0; }
    .scroll-content { padding: 10px 12px 80px; }
    .plan-card, .contract-card, .contact-card { padding: 12px; }
    .wallet-strip { padding: 10px 12px; }
    .wallet-num { font-size: 0.95rem; }
    .market-card { padding: 10px; }
}

/* FAB safe position on all devices */
@supports (bottom: env(safe-area-inset-bottom)) {
    .fab { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); }
    .fab-secondary { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 76px); }
}

/* Stats grid: 2 cols on narrow */
@media (max-width: 340px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ═══ Board Type Bar ═══ */

.board-type-bar {
    display: flex;
    gap: 4px;
    padding: 0 16px 8px;
    overflow-x: auto;
}

.board-type-tab {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--dim);
    cursor: pointer;
    white-space: nowrap;
}
.board-type-tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.board-feed {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.board-tag {
    font-size: 0.65rem;
    background: var(--bg);
    color: var(--dim);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
}

/* ═══ Message Card ═══ */

.message-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
}
.message-card.mine { border-left: 3px solid var(--blue); }

.message-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 0.75rem;
}
.message-author { color: var(--blue); font-weight: 600; }
.message-time { color: var(--dim); margin-left: auto; }

.message-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}
.message-body {
    font-size: 0.85rem;
    color: var(--text);
    line-height: 1.5;
    opacity: 0.85;
}

/* ═══ Poll Card ═══ */

.poll-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
}
.poll-question {
    font-weight: 700;
    margin-bottom: 8px;
}
.poll-options { display: flex; flex-direction: column; gap: 4px; }
.poll-option {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    cursor: pointer;
}
.poll-option:active { border-color: var(--accent); }
.poll-votes { color: var(--dim); font-size: 0.75rem; }

/* ═══ Share / Drop ═══ */

.btn-share {
    color: var(--blue);
    background: rgba(48, 128, 192, 0.12);
    border: 1px solid rgba(48, 128, 192, 0.25);
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
}
.btn-share:active { opacity: 0.7; }

.share-modal .modal-title { margin-bottom: 8px; }

.share-modes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.share-mode-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    cursor: pointer;
    text-align: left;
    color: var(--text);
    transition: border-color 0.15s;
}
.share-mode-btn:active { border-color: var(--accent); }

.share-mode-icon { font-size: 1.4rem; flex-shrink: 0; }
.share-mode-label { font-weight: 600; font-size: 0.9rem; }
.share-mode-desc { font-size: 0.75rem; color: var(--dim); margin-left: auto; }

.share-result { margin-top: 4px; }

.share-success {
    font-size: 0.85rem;
    color: var(--green);
    margin-bottom: 8px;
}

.share-error {
    font-size: 0.85rem;
    color: var(--accent);
}

.share-url-input {
    font-size: 0.75rem;
    font-family: monospace;
    user-select: all;
    -webkit-user-select: all;
    word-break: break-all;
}

.share-actions-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.share-phrase-display {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-size: 1.1rem;
    text-align: center;
    margin-top: 8px;
    user-select: all;
    -webkit-user-select: all;
}

/* Receive / Drop */

.receive-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 20px;
    margin: 40px auto;
    max-width: 400px;
}

.receive-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.offer-preview {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-top: 12px;
}

.offer-from {
    font-size: 0.8rem;
    color: var(--dim);
    margin-bottom: 6px;
}

.offer-plan-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.offer-meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--dim);
    margin-top: 8px;
    flex-wrap: wrap;
}

.offer-meta span {
    background: var(--bg);
    padding: 3px 8px;
    border-radius: 6px;
}

/* ═══ Board Management (Profile) ═══ */

.profile-section-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 16px 0 8px;
}

.boards-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.board-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}

.board-item-name { font-weight: 600; font-size: 0.9rem; }
.board-item-url { font-size: 0.7rem; }
.board-remove:disabled { opacity: 0.2; pointer-events: none; }

/* --- Utility --- */
.dim { color: var(--dim); }
.mono { font-family: monospace; }
