/* ─── 远程输入板 ──────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #52677f;
    --primary-dark: #405369;
    --danger: #b42318;
    --warning: #d97706;
    --bg: #f3f5f7;
    --card: #ffffff;
    --text: #1a1a1a;
    --text2: #667085;
    --border: #d7dde5;
    --radius: 12px;
    --shadow: 0 2px 10px rgba(0,0,0,0.07);
}

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    -webkit-tap-highlight-color: transparent;
}

/* ─── Header ─────────────────────────────────────── */
.header {
    background: var(--primary);
    color: #fff;
    padding: 16px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header h1 { font-size: 1.15rem; font-weight: 600; }
.header .sub { font-size: .75rem; opacity: .85; margin-top: 4px; }

/* ─── Container ──────────────────────────────────── */
.container {
    flex: 1;
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    padding: 12px 12px 80px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ─── Token setup ────────────────────────────────── */
.token-box {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 20px;
    text-align: center;
    margin-top: 40px;
}
.token-box h2 { font-size: 1.1rem; margin-bottom: 8px; }
.token-box p { color: var(--text2); font-size: .85rem; margin-bottom: 16px; }
.token-row { display: flex; gap: 8px; }
.token-row input {
    flex: 1; padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color .2s;
}
.token-row input:focus { border-color: var(--primary); }

/* ─── Textarea ───────────────────────────────────── */
.input-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}
textarea {
    width: 100%;
    min-height: 160px;
    max-height: 60vh;
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1.1rem;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: border-color .2s;
    -webkit-text-size-adjust: 100%;
}
textarea:focus { border-color: var(--primary); }
textarea::placeholder { color: #7c8796; }

.char-count {
    text-align: right; font-size: .8rem;
    color: var(--text2); margin-top: 6px; padding-right: 4px;
}
.char-count.over { color: var(--danger); font-weight: 600; }
.hint { text-align: center; font-size: .75rem; color: var(--text2); margin-top: 4px; }

/* ─── Buttons ────────────────────────────────────── */
.btn-group { display: flex; flex-direction: column; gap: 10px; }
.btn-row { display: flex; gap: 10px; }

.btn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 14px 20px; border: none; border-radius: 10px;
    font-size: 1.05rem; font-weight: 500;
    cursor: pointer; transition: all .15s;
    -webkit-user-select: none; user-select: none;
    touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; transform: none; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; flex: 1; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-secondary { background: #e9edf2; color: var(--text); flex: 1; }
.btn-secondary:hover:not(:disabled) { background: #dce3ea; }

.btn-outline {
    background: transparent; color: var(--text2);
    border: 1.5px solid var(--border);
    font-size: .9rem; padding: 10px 14px;
}
.btn-outline:hover:not(:disabled) { background: #eef1f5; }

/* ─── Original media upload ─────────────────────── */
.upload-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.upload-actions > .btn { width: 100%; }
.upload-action-row { display: flex; gap: 10px; }
.upload-action-row .btn { padding: 12px 10px; font-size: .92rem; }
.upload-hint {
    margin-top: 12px;
    color: var(--text2);
    font-size: .76rem;
    line-height: 1.55;
}
#uploadStatus {
    margin-top: 8px;
    color: var(--text2);
    font-size: .8rem;
    text-align: center;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.45;
}
.picker-issue {
    margin-top: 10px;
    padding: 12px;
    border: 1px solid #e6b866;
    border-radius: 10px;
    background: #fff8e8;
    color: #634512;
    font-size: .8rem;
    line-height: 1.55;
}
.picker-issue-title { font-weight: 700; margin-bottom: 5px; }
.picker-issue-text { white-space: pre-line; }
.picker-issue-dismiss {
    display: block;
    margin: 9px 0 0 auto;
    padding: 5px 12px;
    border: 1px solid #d3a24c;
    border-radius: 7px;
    background: #fff;
    color: #634512;
    font: inherit;
    cursor: pointer;
    touch-action: manipulation;
}

/* ─── Advanced action section ───────────────────── */
.advanced-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    display: none;
}
.advanced-card.show { display: block; }
.advanced-confirm {
    display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.advanced-confirm input[type="checkbox"] {
    width: 20px; height: 20px; accent-color: var(--danger); cursor: pointer;
}
.advanced-confirm label {
    font-size: .9rem; color: var(--danger); cursor: pointer;
}
.btn-confirm { background: var(--danger); color: #fff; width: 100%; }
.btn-confirm:hover:not(:disabled) { background: #912018; }

/* ─── Status bar ─────────────────────────────────── */
.status-bar {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 16px;
    display: flex; flex-direction: column; gap: 6px;
    font-size: .82rem; color: var(--text2);
}
.status-row { display: flex; justify-content: space-between; align-items: center; }
.dot {
    display: inline-block; width: 8px; height: 8px;
    border-radius: 50%; margin-right: 6px;
}
.dot.on { background: var(--primary); }
.dot.off { background: var(--danger); }
.dot.busy { background: var(--warning); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ─── Toast ──────────────────────────────────────── */
.toast-wrap {
    position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
    z-index: 1000;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
    width: 90%; max-width: 400px;
}
.toast {
    background: #333; color: #fff;
    padding: 14px 20px; border-radius: 10px;
    font-size: .95rem; text-align: center;
    animation: ti .3s ease; pointer-events: auto;
}
.toast.ok { background: var(--primary); }
.toast.err { background: var(--danger); }
.toast.warn { background: var(--warning); color: #fff; }
@keyframes ti { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Loading ────────────────────────────────────── */
.loading {
    display: none;
    position: fixed; inset: 0;
    background: rgba(255,255,255,.7); z-index: 999;
    align-items: center; justify-content: center;
}
.loading.on { display: flex; }
.spinner {
    width: 40px; height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.help-link { text-align: center; margin-top: 4px; }
.help-link a { color: var(--text2); font-size: .78rem; text-decoration: none; }
.help-link a:hover { text-decoration: underline; }

/* ─── Responsive ─────────────────────────────────── */
@media (min-width: 480px) {
    .container { padding: 20px 20px 80px; }
    textarea { min-height: 200px; font-size: 1.15rem; }
    .btn { padding: 16px 24px; font-size: 1.1rem; }
}
@media (max-width: 360px) {
    .header h1 { font-size: 1rem; }
    textarea { min-height: 120px; font-size: 1rem; }
    .btn { padding: 12px 14px; font-size: .95rem; }
}
