@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
    --bg: #0e1116;
    --bg-soft: #171c23;
    --panel: #202733;
    --panel-2: #262f3d;
    --line: #313c4d;
    --text: #f2f5f9;
    --text-soft: #aeb8c8;
    --brand: #3b82f6;
    --brand-hover: #2f73e0;
    --ok: #22c55e;
    --in-bubble: #2a3342;
    --out-bubble: #2b6ee8;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
}

html,
body {
    overflow-x: hidden;
    background: var(--bg) !important;
    color: var(--text) !important;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: #8bb8ff;
}

b,
strong,
h1,
h2,
h3,
h4 {
    font-weight: 600;
}

.ui-page {
    background: linear-gradient(180deg, #0f1319 0%, #0d1015 100%) !important;
}

/* jQM-less page visibility fallback */
.app-page {
    display: none;
}

.app-page.ui-page-active {
    display: block;
}

[role="main"] {
    display: block;
}

[data-role="navbar"] ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

[data-role="navbar"] li {
    margin: 10px 0;
}

.ui-grid-b {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}

.ui-block-a,
.ui-block-b,
.ui-block-c {
    min-width: 0;
}

.ui-field-contain-left {
    display: flex;
    align-items: center;
    gap: 8px;
    width: calc(100% - 68px);
}

.ui-btn-inline {
    display: inline-flex !important;
}

.ui-icon-user,
.ui-icon-home,
.ui-icon-gear,
.ui-icon-navigation,
.ui-icon-delete,
.ui-icon-clock,
.ui-icon-action,
.ui-icon-arrow-l,
.ui-icon-lock {
    text-decoration: none;
}

.ui-corner-all {
    border-radius: 10px !important;
}

.ui-shadow {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18) !important;
}

.ui-header,
.ui-footer {
    background: rgba(32, 39, 51, 0.92) !important;
    border-top: 1px solid var(--line) !important;
    border-bottom: 1px solid var(--line) !important;
    backdrop-filter: blur(8px);
}

.ui-header h1,
.ui-footer,
.ui-footer p,
.ui-footer span {
    color: var(--text) !important;
    text-shadow: none !important;
}

.ui-content,
.app-content {
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 14px;
    margin: 12px;
    padding: 16px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.app-content--home,
.app-content--feed {
    margin-left: auto;
    margin-right: auto;
}

.app-content--feed {
    border: 0;
    box-shadow: none;
    background: transparent;
    margin-top: 0;
}

.app-header--banner {
    background: rgba(32, 39, 51, 0.88);
    backdrop-filter: blur(8px);
}

.app-header--chat {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(23, 28, 35, 0.92) !important;
    backdrop-filter: blur(10px);
}

.app-footer--compose {
    position: sticky;
    bottom: 0;
    z-index: 1030;
}

.ui-btn {
    border-radius: 10px !important;
    border: 1px solid var(--line) !important;
    background: var(--panel) !important;
    color: var(--text) !important;
    text-shadow: none !important;
    box-shadow: none !important;
    font-weight: 600;
    transition: transform 0.08s ease, background 0.15s ease;
}

.btn {
    border-radius: 10px;
    font-weight: 600;
}

.btn-outline-light {
    border-color: #576273 !important;
}

.ui-btn:active {
    transform: scale(0.99);
}

.ui-btn:hover {
    background: var(--panel-2) !important;
}

.ui-btn-b,
.buildbox,
.pushmsg,
.copylink,
.copylinkbox,
.cpenter {
    background: var(--brand) !important;
    border-color: var(--brand) !important;
    color: #fff !important;
}

.ui-btn-b:hover,
.buildbox:hover,
.pushmsg:hover,
.copylink:hover,
.copylinkbox:hover,
.cpenter:hover {
    background: var(--brand-hover) !important;
    border-color: var(--brand-hover) !important;
}

input[type="text"],
input[type="number"],
select,
textarea {
    background: #1b2431 !important;
    color: var(--text) !important;
    border: 1px solid #354257 !important;
    border-radius: 10px !important;
    box-shadow: none !important;
}

.form-control,
.form-select {
    background: #1b2431 !important;
    color: var(--text) !important;
    border: 1px solid #354257 !important;
    border-radius: 10px !important;
    box-shadow: none !important;
}

.form-control:focus,
.form-select:focus {
    border-color: #4f6a8f !important;
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.15) !important;
    background: #1b2431 !important;
    color: var(--text) !important;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-soft);
}

#home .app-content > center img {
    width: min(78vw, 420px) !important;
    filter: drop-shadow(0 12px 26px rgba(0, 0, 0, 0.45));
    margin: 6px 0 12px;
}

#home p,
#home center {
    color: var(--text-soft);
    line-height: 1.45;
}

#boxlist .row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin: 10px 0;
}

#boxlist .row > div {
    float: none !important;
}

#boxfeedstream {
    min-height: 56vh;
    max-height: 64vh;
    overflow-y: auto;
    padding: 12px;
    border-radius: 12px;
    background:
        linear-gradient(rgba(14, 17, 22, 0.93), rgba(14, 17, 22, 0.93)),
        radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.05) 1px, transparent 0);
    background-size: auto, 20px 20px;
}

#boxfeedstream .chat-bubble,
#boxfeedstream .ui-body.ui-body-a {
    border: 0 !important;
    border-radius: 12px !important;
    margin: 0 0 10px 0 !important;
    padding: 10px 12px !important;
    width: 88% !important;
    color: var(--text) !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

#boxfeedstream .chat-bubble:not(.chat-bubble--out),
#boxfeedstream .ui-body.ui-body-a:not([style*="float:right"]) {
    background: var(--in-bubble) !important;
}

#boxfeedstream .chat-bubble--out,
#boxfeedstream .ui-body.ui-body-a[style*="float:right"] {
    background: var(--out-bubble) !important;
    color: #fff !important;
}

#boxfeedstream .chat-bubble span,
#boxfeedstream .ui-body.ui-body-a span {
    color: #dbe7ff !important;
    opacity: 0.92;
}

#boxfeedstream .chat-bubble--out span {
    color: rgba(255, 255, 255, 0.92) !important;
}

.people .participant-pill,
.people .ui-btn {
    min-width: 54px;
    padding: 6px 8px !important;
    border-radius: 999px !important;
    font-size: 11px;
}

.app-footer--compose #msg {
    min-height: 44px !important;
    max-height: 110px;
    resize: none;
}

#cp .app-content--cp {
    max-width: 540px;
    margin: 16px auto;
}

#cp .cpbt {
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    padding: 0.65rem 0 !important;
}

#cpwarn {
    color: #fda4af;
}

#cphelp {
    color: var(--text-soft) !important;
}

.ui-popup-container .ui-content,
#tinypopup {
    background: #1f2937 !important;
    border: 1px solid #334155 !important;
    color: var(--text) !important;
}

::-webkit-scrollbar {
    width: 7px;
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 6px;
}