:root {
    --root: #17181a;
    --surface: #202124;
    --card: #2a2b2f;
    --hair: #34363a;
    --btn: #3c4043;
    --off: #4a4c51;
    --pri: #e8eaed;
    --sec: #9aa0a6;
    --meta: #80868b;
    --accent: #ff5a5a;
    --green: #5fd98a;
    --amber: #f5c542;
    --amberBd: #5a4a14;
    --okBg: #11261a;
    --warnBg: #2b2410;
    --pastBg: #2d1515;
    --launchBg: #ff5a5a;
    --launchTxt: #1a0d0d;
    --inputBg: #17181a;
    --purple: #b794f6;
}

:root[data-theme="light"] {
    --root: #eef0f3;
    --surface: #ffffff;
    --card: #e4e7ec;
    --hair: #d8dbe0;
    --btn: #e2e5ea;
    --off: #c9ccd2;
    --pri: #202124;
    --sec: #5f6368;
    --meta: #80868b;
    --accent: #d93025;
    --green: #1e8e3e;
    --amber: #a86200;
    --amberBd: #ecd08a;
    --okBg: #e6f4ea;
    --warnBg: #fff4d6;
    --pastBg: #fce8e6;
    --launchBg: #d93025;
    --launchTxt: #ffffff;
    --inputBg: #eef0f3;
    --purple: #7b3fe4;
}

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

button,
a,
input,
textarea {
    touch-action: manipulation
}

html,
body {
    margin: 0;
    background: var(--root);
    color: var(--pri);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px
}

body {
    padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + 150px);
    max-width: 560px;
    margin: 0 auto
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace
}

header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px
}

.logo {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex: none
}

.logo img {
    width: 40px;
    height: 40px
}

.ttl {
    flex: 1;
    min-width: 0
}

.ttl b {
    font-size: 19px;
    display: block
}

.ttl span {
    color: var(--sec);
    font-size: 12px
}

.pill {
    border: 0;
    border-radius: 999px;
    background: var(--btn);
    color: var(--pri);
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer
}

.pill.accent {
    background: var(--launchBg);
    color: var(--launchTxt)
}

.pill.small {
    padding: 6px 12px;
    font-size: 12px
}

.card {
    background: var(--surface);
    border: 1px solid var(--hair);
    border-radius: 18px;
    padding: 16px;
    margin-bottom: 14px
}

.card h2 {
    margin: 0 0 4px;
    font-size: 15px
}

.card p.sub {
    margin: 0 0 12px;
    color: var(--sec);
    font-size: 12.5px;
    line-height: 1.4
}

input[type=text] {
    width: 100%;
    background: var(--inputBg);
    border: 1px solid var(--hair);
    border-radius: 12px;
    color: var(--pri);
    padding: 12px 14px;
    font-size: 14px;
    outline: none
}

input[type=text]:focus {
    border-color: var(--accent)
}

.row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px
}

.kv {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 12px;
    font-size: 12.5px
}

.kv span:nth-child(odd) {
    color: var(--sec)
}

.kv span:nth-child(even) {
    text-align: right;
    word-break: break-all
}

.tag {
    display: inline-block;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 11.5px;
    font-weight: 600
}

.ok {
    background: var(--okBg);
    color: var(--green)
}

.warn {
    background: var(--warnBg);
    color: var(--amber)
}

.bad {
    background: var(--pastBg);
    color: var(--accent)
}

#log {
    background: var(--inputBg);
    border: 1px solid var(--hair);
    border-radius: 12px;
    padding: 10px;
    height: 190px;
    overflow: auto;
    font-size: 11.5px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all
}

.hide {
    display: none !important
}

#buyWrap {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 70px;
    z-index: 60;
    display: none
}

#buyWrap.on {
    display: block
}

#buy {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 20px 20px 0 0;
    background: var(--launchBg);
    color: var(--launchTxt);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, .4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    padding: 8px 56px 6px;
    cursor: pointer
}

#buy .big {
    font-size: clamp(28px, 9vw, 40px);
    font-weight: 900;
    line-height: 1.05;
    letter-spacing: 1px
}

#buy .itm {
    font-size: 12.5px;
    font-weight: 700;
    max-width: 100%;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

#buyX {
    position: absolute;
    right: 12px;
    top: 8px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 0;
    background: rgba(0, 0, 0, .28);
    color: #fff;
    font-size: 19px;
    font-weight: 700;
    z-index: 2
}

.ios-browser #buyWrap {
    bottom: 64px;
    height: 70px
}

.ios-browser #buy {
    border-radius: 20px
}

body.onItems #buyWrap,
.ios-browser body.onItems #buyWrap {
    bottom: calc(env(safe-area-inset-bottom) + 130px);
    height: 70px
}

body.onItems #buy {
    border-radius: 20px
}

.seg {
    display: flex;
    gap: 4px;
    background: var(--card);
    border-radius: 999px;
    padding: 4px;
    margin-bottom: 12px
}

.seg button {
    flex: 1;
    border: 0;
    background: transparent;
    color: var(--sec);
    border-radius: 999px;
    padding: 9px 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer
}

.seg button.on {
    background: var(--launchBg);
    color: var(--launchTxt)
}

.chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 0 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none
}

.chips::-webkit-scrollbar {
    display: none
}

.chip {
    flex: none;
    border: 1px solid var(--hair);
    background: var(--card);
    color: var(--sec);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer
}

.chip.on {
    background: var(--btn);
    color: var(--pri);
    border-color: var(--accent)
}

.irow {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--hair);
    border-radius: 16px;
    padding: 10px;
    margin-bottom: 8px;
    cursor: pointer
}

.irow.sel {
    border-color: var(--accent);
    background: var(--card)
}

.chk {
    flex: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--off);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    color: var(--launchTxt)
}

.irow.sel .chk {
    background: var(--launchBg);
    border-color: var(--launchBg)
}

.thumb {
    flex: none;
    width: 52px;
    height: 52px;
    border-radius: 10px;
    background: var(--card);
    object-fit: cover
}

.imeta {
    flex: 1;
    min-width: 0
}

.ititle {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden
}

.isub {
    font-size: 11.5px;
    color: var(--sec);
    margin-top: 3px
}

.itags {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end
}

#itFoot {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: var(--surface);
    border-top: 1px solid var(--hair);
    padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px)
}

#itFoot .inner {
    max-width: 560px;
    margin: 0 auto
}

#itFoot .seg {
    margin-bottom: 8px
}

#itGo {
    width: 100%;
    padding: 13px
}

#itGo:disabled {
    opacity: .45
}

body.onItems {
    padding-bottom: calc(env(safe-area-inset-bottom) + 150px)
}

.stick {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--root);
    padding: 6px 0 10px
}

#bub {
    background: var(--inputBg);
    border: 1px solid var(--hair);
    border-radius: 14px;
    padding: 8px 12px;
    height: 260px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 1px
}

.bb,
.bb.ok,
.bb.warn {
    background: none
}

.bb {
    display: flex;
    gap: 10px;
    padding: 4px 0;
    font-size: 13px;
    line-height: 1.35;
    color: var(--sec);
    border-bottom: 1px solid var(--hair)
}

.bb:last-child {
    border-bottom: 0
}

.bb time {
    order: -1;
    flex: none;
    width: 38px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11.5px;
    color: var(--meta);
    margin: 0
}

.bb.ok {
    color: var(--green)
}

.bb.warn {
    color: var(--amber)
}

.bb.wait {
    color: var(--purple)
}

.bb.hit {
    color: var(--accent);
    font-weight: 700
}

.bb.mute {
    color: var(--meta)
}

.bb.sys {
    color: var(--sec)
}

.live {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 700
}

.live i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block
}

.live.ok i {
    animation: blink 1.4s infinite
}

@keyframes blink {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: .25
    }
}

details.dt summary {
    font-size: 12px;
    color: var(--meta);
    cursor: pointer;
    margin-top: 12px
}

/* Disabled activate button */
#keySave:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

/* Loading spinner */
.loader {
    display: inline-block;
    width: 13px;
    height: 13px;
    margin-right: 8px;
    vertical-align: -2px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
