/* Pisces 鱼汤 — 设计系统
 * 方向：深夜茶馆。纸与墨，一盏琥珀色的灯。
 * 默认是亮色“纸”主题；dark.css 里是暗色“墨”主题（#theme-css，由 main.js 的主题开关启用）。
 * 页面样式只用这里的变量，不写死颜色。
 */
:root {
    --bg: #f3efe6;
    --bg-soft: #ebe6d9;
    --surface: #fbf9f4;
    --surface-2: #f0ebdf;
    --line: #ddd5c4;
    --line-strong: #c9bfa9;
    --text: #23201b;
    --text-2: #5d564a;
    --text-3: #8c8473;
    --accent: #b8651b;
    --accent-hover: #a15616;
    --accent-ink: #ffffff;
    --accent-soft: #f1dfc7;
    --teal: #2f7d70;
    --teal-soft: #d6e9e4;
    --danger: #b4413a;
    --danger-soft: #f3dbd8;
    --warning: #a87412;
    --glow: radial-gradient(900px 420px at 50% -120px, rgba(184, 101, 27, .10), transparent 70%);
    --grain-opacity: .05;

    --r-s: 8px;
    --r-m: 12px;
    --r-l: 18px;
    --shadow-1: 0 1px 2px rgba(40, 30, 10, .06), 0 1px 1px rgba(40, 30, 10, .04);
    --shadow-2: 0 10px 30px -10px rgba(40, 30, 10, .25), 0 2px 6px rgba(40, 30, 10, .06);
    --font-sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
    --font-serif: "Noto Serif CJK SC", "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --header-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    background-image: var(--glow);
    background-repeat: no-repeat;
    min-height: 100vh;
    position: relative;
}
/* 纸张颗粒：极淡，只在页面最底层 */
body::before {
    content: "";
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    opacity: var(--grain-opacity);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .5  0 0 0 0 .45  0 0 0 0 .35  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
body > * { position: relative; z-index: 1; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- 页面骨架 ---------- */
.container { max-width: 1160px; margin: 0 auto; padding: 0 20px 48px; }
.page-title { font-family: var(--font-serif); font-weight: 700; letter-spacing: .02em; }

/* 顶栏（大厅 / 个人 / 管理 共用） */
header:not(.room-header) {
    position: sticky; top: 0; z-index: 30;
    margin: 0 -20px 28px;
    padding: 0 20px;
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 0 0 100vmax color-mix(in srgb, var(--bg) 86%, transparent);
    clip-path: inset(0 -100vmax);
}
.header-content {
    max-width: 1160px; margin: 0 auto; min-height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.header-content h1, .brand {
    display: flex; align-items: center; gap: 10px;
    font-family: var(--font-serif); font-size: 1.25rem; font-weight: 700; letter-spacing: .04em; color: var(--text);
}
.header-content h1 i, .brand i { color: var(--accent); font-size: 1.1rem; }
.user-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
#username-display {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--line);
    font-size: .9rem; color: var(--text-2);
}
#username-display i { color: var(--accent); }
footer { text-align: center; color: var(--text-3); font-size: .85rem; padding: 32px 0 8px; }
footer p::before { content: "— "; } footer p::after { content: " —"; }

/* ---------- 按钮 ---------- */
.btn, .small-btn, .primary-btn, .modal-btn, .btn-outlined, .btn-primary, .filter-btn, .refresh-btn, .page-btn, .room-btn, .soup-action-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 0 16px;
    border-radius: var(--r-s);
    border: 1px solid var(--line-strong);
    background: var(--surface); color: var(--text);
    font-size: .92rem; font-weight: 600; line-height: 1;
    transition: background .15s, border-color .15s, color .15s, transform .08s, box-shadow .15s;
    text-decoration: none; white-space: nowrap;
}
.btn:hover, .small-btn:hover, .modal-btn:hover, .btn-outlined:hover, .filter-btn:hover, .refresh-btn:hover, .page-btn:hover:not(:disabled), .room-btn:hover, .soup-action-btn:hover {
    border-color: var(--accent); color: var(--accent); background: var(--surface);
}
.btn:active, .modal-btn:active, .btn-primary:active, .primary-btn:active { transform: translateY(1px); }
.small-btn, .btn-sm { min-height: 34px; padding: 0 12px; font-size: .85rem; }
.primary-btn, .btn-primary, .modal-btn.primary, .btn.primary, .room-btn.primary, .soup-action-btn.primary {
    background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, var(--shadow-1);
}
.primary-btn:hover, .btn-primary:hover, .modal-btn.primary:hover, .btn.primary:hover, .room-btn.primary:hover, .soup-action-btn.primary:hover {
    background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink);
}
.danger-btn:hover { border-color: var(--danger); color: var(--danger); }
.btn:disabled, .modal-btn:disabled, .btn-primary:disabled, .primary-btn:disabled, .page-btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-text { background: none; border: none; color: var(--text-2); padding: 6px 10px; border-radius: var(--r-s); font-weight: 600; }
.btn-text:hover { color: var(--accent); background: var(--accent-soft); }
.full-width { width: 100%; }
.icon-btn {
    position: relative; width: 38px; height: 38px; border-radius: 50%;
    display: inline-grid; place-items: center;
    background: transparent; border: 1px solid transparent; color: var(--text-2);
}
.icon-btn:hover, .icon-btn.active { background: var(--accent-soft); color: var(--accent); }

/* ---------- 表单 ---------- */
.form-group { margin-bottom: 18px; }
.form-group > label, .filter-group > label {
    display: block; margin-bottom: 6px; font-size: .85rem; font-weight: 600; color: var(--text-2); letter-spacing: .02em;
}
input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="email"], select, textarea {
    width: 100%; min-height: 42px; padding: 9px 12px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--line-strong); border-radius: var(--r-s);
    transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.65; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-with-icon { position: relative; }
.input-with-icon > i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-with-icon > input { padding-left: 38px; }
.error-message {
    display: none; align-items: center; gap: 8px; margin-top: 12px; padding: 10px 12px;
    background: var(--danger-soft); color: var(--danger); border-radius: var(--r-s); font-size: .9rem;
}
.error-message.show, .error-message[style*="block"] { display: flex; }

/* 开关 */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--line-strong); border-radius: 999px; transition: background .2s; cursor: pointer; }
.slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: var(--shadow-1); }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.toggle-group { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px dashed var(--line); margin-top: 6px; }
.toggle-group label:first-child { font-weight: 600; color: var(--text-2); }

/* 单选卡片 */
.radio-group { display: grid; gap: 8px; }
.radio-option input { position: absolute; opacity: 0; }
.radio-option label {
    display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer;
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-s); color: var(--text-2);
    transition: border-color .15s, background .15s;
}
.radio-option label:hover { border-color: var(--accent); }
.radio-option input:checked + label { border-color: var(--accent); background: var(--accent-soft); color: var(--text); font-weight: 600; }
.radio-option label i { color: var(--accent); width: 18px; text-align: center; }

/* ---------- 弹窗 ---------- */
.modal {
    display: none; position: fixed; inset: 0; z-index: 100;
    align-items: center; justify-content: center; padding: 20px;
    background: rgba(20, 16, 8, .55); backdrop-filter: blur(4px);
}
.modal.active, .modal.show, .modal[style*="flex"], .modal[style*="block"] { display: flex; }
.modal-content {
    width: 100%; max-width: 520px; max-height: calc(100vh - 40px); overflow: auto;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-2);
    animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-header h2, .modal-header h3 { display: flex; align-items: center; gap: 10px; font-family: var(--font-serif); font-size: 1.15rem; }
.modal-header h2 i, .modal-header h3 i { color: var(--accent); }
.modal-close, .close-modal, .close-btn { width: 34px; height: 34px; border-radius: 50%; border: none; background: transparent; color: var(--text-3); }
.modal-close:hover, .close-modal:hover, .close-btn:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; }

/* ---------- 状态与小件 ---------- */
.spinner, .spinner-small {
    width: 28px; height: 28px; border-radius: 50%;
    border: 3px solid var(--line); border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}
.spinner-small { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-container { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 0; color: var(--text-3); width: 100%; }
.empty-state { text-align: center; padding: 48px 16px; color: var(--text-3); }
.empty-state i { display: block; font-size: 2rem; margin-bottom: 12px; color: var(--line-strong); }
.status-badge, .status-tag, .badge, .private-badge, .soup-badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
    font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line);
}
.badge-solved, .status-playing, .soup-badge.new { background: var(--teal-soft); color: var(--teal); border-color: transparent; }
.badge-creator, .private-badge, .soup-badge.played { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.progress-bar-container, .progress-bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress-fill, .progress-bar > div { height: 100%; background: var(--accent); border-radius: inherit; transition: width .3s; }

/* 通知 toast（lobby.js 生成 .notification.notification-{type}） */
#notification-container { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 36px)); }
.notification {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
    background: var(--surface); color: var(--text); border: 1px solid var(--line); border-left: 4px solid var(--accent);
    border-radius: var(--r-s); box-shadow: var(--shadow-2); font-size: .92rem;
}
.notification-success { border-left-color: var(--teal); } .notification-error { border-left-color: var(--danger); } .notification-warning { border-left-color: var(--warning); }
.offline-notice { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 200; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow-2); }

/* 主题开关 */
.theme-toggle { display: inline-flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--text-2); }
.theme-toggle .switch { width: 40px; height: 22px; } .theme-toggle .slider::before { width: 16px; height: 16px; }
.theme-toggle .switch input:checked + .slider::before { transform: translateX(18px); }

@media (max-width: 640px) {
    .container { padding: 0 14px 40px; }
    header:not(.room-header) { margin: 0 -14px 20px; padding: 0 14px; }
    .modal-body { padding: 18px; }
}
