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

/*reset*/
* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

::selection {
    background: var(--red);
    color: #fff;
}

:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 2px;
}

html {
    background: var(--bg);
    scrollbar-gutter: stable;
    scroll-padding-top: env(safe-area-inset-top, 0px);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

body.modal-open {
    overflow: hidden;
}

a {
    color: inherit;
}

button {
    font-family: inherit;
    cursor: pointer;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

img {
    max-width: 100%;
}

.ic {
    display: block;
    flex-shrink: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.empty-hint {
    color: var(--muted);
    font-size: .88rem;
    padding: 14px 2px;
    text-align: center;
}

/*shell: topbar / content / tabbar*/
.app-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding-top: env(safe-area-inset-top, 0px);
}

.topbar-inner {
    max-width: var(--col);
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.topbar-title {
    font-weight: 600;
    font-size: 1.02rem;
}

.topbar-title small {
    display: block;
    font-weight: 400;
    font-size: .74rem;
    color: var(--muted);
    line-height: 1.2;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-content {
    flex: 1;
    width: 100%;
    max-width: var(--col);
    margin: 0 auto;
    padding: 0 0 calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 28px);
}

.tab-panel[hidden] {
    display: none;
}

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tabbar-inner {
    max-width: var(--col);
    margin: 0 auto;
    height: var(--tabbar-h);
    display: flex;
}

.tab-btn {
    flex: 1;
    border: 0;
    background: transparent;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--faint);
    font-size: .72rem;
    font-weight: 500;
    transition: color var(--speed) ease-out;
}

.tab-btn.active {
    color: var(--ink);
}

.tab-btn.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 28px;
    height: 3px;
    margin-left: -14px;
    background: var(--red);
    border-radius: 0 0 3px 3px;
}

.tab-btn .tab-badge {
    position: absolute;
    top: 9px;
    right: calc(50% - 20px);
    min-width: 8px;
    height: 8px;
    border-radius: var(--r-full);
    background: var(--red);
}

.icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r-full);
    padding: 0;
    flex-shrink: 0;
    transition: background var(--speed), border-color var(--speed);
}

.icon-btn:hover {
    background: var(--red-tint);
    border-color: var(--red);
    color: var(--red-text);
}

/*panel*/
.panel {
    background: var(--surface);
    padding: 18px 16px;
    margin-bottom: 8px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    min-width: 0;
}

.panel>h2,
.panel-head h2 {
    font-weight: 600;
    font-size: .98rem;
    margin: 0;
}

.panel>h2 {
    margin-bottom: 12px;
}

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

.panel-head .count {
    color: var(--muted);
    font-size: .82rem;
    font-weight: 500;
}

@media (min-width: 600px) {
    .app-content {
        padding-top: 16px;
    }

    .panel {
        border: 1px solid var(--line);
        border-radius: var(--r-panel);
        margin-bottom: 12px;
    }
}

/*buttons*/
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-ctl);
    background: var(--surface);
    color: var(--text);
    font-size: .9rem;
    font-weight: 600;
    transition: background var(--speed), border-color var(--speed), color var(--speed), opacity var(--speed);
}

.btn:hover:not(:disabled) {
    background: var(--bg);
}

.btn.primary {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

.btn.primary:hover:not(:disabled) {
    background: var(--red-strong);
    border-color: var(--red-strong);
}

.btn.ink {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--on-ink);
}

.btn.ink:hover:not(:disabled) {
    background: var(--ink-2);
}

.btn.danger {
    color: var(--red-text);
    border-color: var(--red);
}

.btn.danger:hover:not(:disabled) {
    background: var(--red-tint);
}

.btn.danger-solid {
    background: var(--red-strong);
    border-color: var(--red-strong);
    color: #fff;
}

.btn.danger-solid:hover:not(:disabled) {
    background: var(--red-deep);
}

.btn.block {
    width: 100%;
}

.btn.small {
    min-height: 36px;
    padding: 0 12px;
    font-size: .82rem;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.link-btn {
    background: none;
    border: 0;
    padding: 8px 4px;
    font-size: .84rem;
    font-weight: 600;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.link-btn:hover {
    color: var(--text);
}

.link-btn.danger {
    color: var(--red-text);
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: spin .6s linear infinite;
}

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

/*forms*/
label,
.field-label {
    display: block;
    font-size: .83rem;
    color: var(--muted);
    margin: 14px 0 6px;
    font-weight: 500;
}

label .counter {
    float: right;
    font-weight: 400;
    color: var(--faint);
    font-variant-numeric: tabular-nums;
}

input[type="text"],
input[type="password"],
input[type="time"],
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-ctl);
    font-size: 1rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--speed), box-shadow var(--speed);
}

textarea {
    resize: vertical;
    min-height: 78px;
    line-height: 1.5;
}

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

input:focus-visible,
textarea:focus-visible {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

input:disabled,
textarea:disabled {
    background: var(--bg);
    color: var(--faint);
}

input.is-error {
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-tint);
}

input.is-ok {
    border-color: var(--green);
}

.hint {
    font-size: .78rem;
    color: var(--faint);
    margin-top: 6px;
}

.field-msg {
    display: flex;
    gap: 7px;
    align-items: flex-start;
    font-size: .82rem;
    margin-top: 8px;
    min-height: 1.2em;
    color: var(--muted);
}

.field-msg .ic {
    margin-top: 2px;
}

.field-msg.err {
    color: var(--red-text);
}

.field-msg.ok {
    color: var(--green-text);
}

.field-msg.warn {
    color: var(--note-text);
}

.input-with-btn {
    position: relative;
}

.input-with-btn input {
    padding-right: 88px;
}

.input-with-btn .paste-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    height: 34px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: var(--bg);
    font-size: .8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.input-with-btn .paste-btn:hover {
    background: var(--line);
}

.disclosure-btn {
    margin-top: 14px;
    background: none;
    border: 0;
    padding: 6px 0;
    font-size: .86rem;
    font-weight: 600;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.disclosure-btn:hover {
    color: var(--text);
}

.disclosure-btn .ic {
    transition: transform var(--speed);
}

.disclosure-btn[aria-expanded="true"] .ic {
    transform: rotate(45deg);
}

.submit-row {
    margin-top: 18px;
}

.submit-row .btn {
    width: 100%;
    min-height: 50px;
    font-size: 1rem;
}

.cap-note {
    text-align: center;
    font-size: .8rem;
    color: var(--muted);
    margin-top: 10px;
}

.cap-note .full {
    color: var(--red-text);
    font-weight: 500;
}

/*turnstile slot*/
.ts-box {
    display: flex;
    justify-content: center;
    max-width: 100%;
    overflow: hidden;
    margin-top: 14px;
    min-height: 65px;
}

.ts-box:empty::before {
    content: "กำลังโหลดระบบตรวจสอบ...";
    display: flex;
    align-items: center;
    justify-content: center;
    height: 65px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-ctl);
    color: var(--faint);
    font-size: .8rem;
}

.ts-box[data-state="error"]:empty::before {
    content: "โหลดระบบตรวจสอบไม่สำเร็จ ลองรีเฟรชหน้า";
    color: var(--red-text);
    border-color: var(--red);
}

/*skeleton*/
.skeleton-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
}

.skeleton {
    background: linear-gradient(90deg, var(--sk-a) 25%, var(--sk-b) 37%, var(--sk-a) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
    border-radius: var(--r-thumb);
}

.onair .skeleton {
    background: linear-gradient(90deg, rgba(255, 255, 255, .07) 25%, rgba(255, 255, 255, .15) 37%, rgba(255, 255, 255, .07) 63%);
    background-size: 400% 100%;
}

@keyframes shimmer {
    0% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0 50%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .skeleton {
        animation: none;
    }
}

.skeleton-thumb {
    width: 88px;
    aspect-ratio: 16 / 9;
    flex-shrink: 0;
}

.skeleton-line {
    height: 11px;
}

.w-60 {
    width: 60%;
}

.w-40 {
    width: 40%;
}

.w-80 {
    width: 80%;
}

/*404*/
.notfound-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
}

.notfound-shell .code {
    font-size: 3rem;
    font-weight: 700;
    color: var(--red);
    margin-bottom: 8px;
}

.notfound-shell h1 {
    font-size: 1.1rem;
    margin: 0 0 6px;
}

.notfound-shell p {
    color: var(--muted);
    font-size: .9rem;
    margin: 0 0 20px;
}