/* ============ merry·hub ============ */
:root {
  --bg: #faf6ef;
  --bg-soft: #f2ecdf;
  --card: #fffdf8;
  --ink: #23201b;
  --ink-2: #6f695e;
  --line: #e4dccb;
  --accent: #e8542f;
  --accent-ink: #fff6ef;
  --ok: #2f8f6b;
  --shadow: 0 2px 0 var(--line);
  --radius: 14px;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
[data-theme="dark"] {
  --bg: #17151a;
  --bg-soft: #201d24;
  --card: #211e26;
  --ink: #efe9df;
  --ink-2: #9a938a;
  --line: #37323e;
  --accent: #ff6a42;
  --accent-ink: #1c130f;
  --shadow: 0 2px 0 #0e0c11;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
body {
  font-family: -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  background-image: radial-gradient(color-mix(in srgb, var(--ink) 7%, transparent) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- 顶栏 ---- */
.top {
  display: flex; align-items: center; gap: 24px;
  padding: 18px 28px 14px;
  border-bottom: 2px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-dot {
  width: 14px; height: 14px; border-radius: 4px;
  background: var(--accent); align-self: center;
  box-shadow: 3px 3px 0 color-mix(in srgb, var(--accent) 30%, transparent);
}
.brand-name { font-family: var(--mono); font-size: 20px; font-weight: 700; letter-spacing: -.5px; }
.brand-name i { color: var(--accent); font-style: normal; }
.brand-tag { font-size: 12px; color: var(--ink-2); }

.tabs { display: flex; gap: 6px; margin-left: auto; }
.tab {
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 7px 16px; border: 2px solid transparent; border-radius: 999px;
  background: none; color: var(--ink-2); cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.theme-toggle {
  font-size: 18px; width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); }
.auth-btn {
  font: inherit; font-size: 12px; font-weight: 600;
  padding: 7px 13px; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--line); background: var(--card); color: var(--ink-2);
}
.auth-btn:hover { border-color: var(--accent); color: var(--ink); }
.auth-btn.authed { border-color: var(--ok); color: var(--ok); }

.dialog-desc { font-size: 12px; color: var(--ink-2); line-height: 1.7; }

/* ---- 快捷链接栏 ---- */
.linkbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 28px; border-bottom: 1px dashed var(--line);
}
.linkbar-label { font-family: var(--mono); font-size: 11px; color: var(--ink-2); letter-spacing: 2px; }
.link-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 13px; font-weight: 500;
  padding: 5px 12px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
  text-decoration: none; cursor: pointer; position: relative;
}
.chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.chip img { width: 15px; height: 15px; border-radius: 3px; }
.chip .fallback-ico {
  width: 15px; height: 15px; border-radius: 3px; background: var(--accent);
  color: var(--accent-ink); font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.chip .chip-x {
  display: none; position: absolute; top: -7px; right: -7px;
  width: 16px; height: 16px; border-radius: 50%; border: none;
  background: var(--ink); color: var(--bg); font-size: 10px; line-height: 16px;
  cursor: pointer; padding: 0;
}
.chip:hover .chip-x { display: block; }
.chip-add { color: var(--ink-2); border-style: dashed; background: none; }

/* ---- 访客欢迎语 ---- */
.hero { text-align: center; padding: 34px 0 38px; }
.hero h1 { font-size: 30px; letter-spacing: 1px; }
.hero h1 em { font-family: var(--mono); font-style: normal; color: var(--accent); }
.hero p { margin-top: 12px; font-size: 14px; color: var(--ink-2); }

/* ---- 主体 ---- */
main { flex: 1; width: 100%; max-width: 1060px; margin: 0 auto; padding: 26px 28px 60px; }
.panel { display: none; }
.panel.active { display: block; animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
h2 { font-size: 22px; letter-spacing: .5px; }
.count { font-family: var(--mono); font-size: 13px; color: var(--accent); vertical-align: super; }
.actions { display: flex; gap: 10px; }

.btn {
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 8px 18px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
  box-shadow: var(--shadow);
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger:hover { border-color: #c0392b; color: #c0392b; }
.linklike { font: inherit; border: none; background: none; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; }

/* ---- 拖放区 ---- */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 22px; text-align: center; margin-bottom: 22px;
  background: color-mix(in srgb, var(--card) 55%, transparent);
  transition: border-color .15s, background .15s;
}
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.dropzone p { font-size: 14px; }
.hint { font-size: 12px; color: var(--ink-2); margin-top: 6px; }

/* ---- 作品卡片：游戏画面实时预览 ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
#panel-games.dropping .grid { outline: 3px dashed var(--accent); outline-offset: 10px; border-radius: var(--radius); }
.head-hint { font-size: 12px; color: var(--ink-2); }

.cart {
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--card); overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .18s, box-shadow .18s, border-color .18s;
  display: flex; flex-direction: column;
}
.cart:hover { transform: translateY(-4px); box-shadow: 0 6px 0 var(--line); border-color: var(--accent); }

.cart-cover {
  display: block; position: relative; aspect-ratio: 16 / 10; overflow: hidden;
  background: linear-gradient(135deg, hsl(var(--h1) 60% 50%), hsl(var(--h2) 62% 40%));
  text-decoration: none;
}
.cart-initial { /* iframe 加载前的底色首字母 */
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 42px; font-weight: 800;
  color: rgba(255,255,255,.9); text-shadow: 2px 2px 0 rgba(0,0,0,.18);
}
.cart-cover iframe { /* 游戏本体缩放 1/4 作为活封面 */
  position: absolute; top: 0; left: 0; width: 400%; height: 400%;
  transform: scale(.25); transform-origin: 0 0;
  border: 0; pointer-events: none; background: #fff;
}
.cart-glare {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.28), transparent 45%);
  opacity: 0; transition: opacity .18s;
}
.cart-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -40%) scale(.8);
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; padding-left: 4px;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
  opacity: 0; transition: opacity .18s, transform .18s;
}
.cart:hover .cart-glare { opacity: 1; }
.cart:hover .cart-play { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.cart-body { padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.cart-info { flex: 1; min-width: 0; }
.cart-name { font-weight: 700; font-size: 15px; word-break: break-all; }
.cart-meta { font-family: var(--mono); font-size: 11px; color: var(--ink-2); margin-top: 3px; }
.cart-meta i { color: var(--accent); font-style: normal; }
.cart-del {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  border: 2px solid var(--line); background: none; color: var(--ink-2);
  font-size: 12px; cursor: pointer;
}
.cart-del:hover { border-color: #c0392b; color: #c0392b; }

.add-tile {
  border: 2px dashed var(--line); border-radius: var(--radius);
  min-height: 240px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  text-align: center; padding: 18px; color: var(--ink-2);
  transition: border-color .18s, background .18s;
}
.add-tile:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, transparent); }
.add-plus {
  width: 46px; height: 46px; border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent);
  font-size: 24px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.add-title { font-weight: 700; font-size: 14px; color: var(--ink); }
.add-actions { display: flex; gap: 8px; }
.add-tile .hint { line-height: 1.6; }

/* ---- 笔记 ---- */
.composer { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 20px; }
.composer textarea, .note-edit textarea {
  flex: 1; font: inherit; font-size: 14px; line-height: 1.6;
  padding: 12px 14px; border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink); resize: vertical; min-height: 72px;
}
.composer textarea:focus, .note-edit textarea:focus { outline: none; border-color: var(--accent); }
.note-list { display: flex; flex-direction: column; gap: 12px; }
.note {
  border: 2px solid var(--line); border-left: 6px solid var(--accent);
  border-radius: var(--radius); background: var(--card);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.note-text { font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.note-foot { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.note-time { font-family: var(--mono); font-size: 11px; color: var(--ink-2); margin-right: auto; }
.note-foot .linklike { font-size: 12px; color: var(--ink-2); text-decoration: none; }
.note-foot .linklike:hover { color: var(--accent); }
.note-edit { display: flex; flex-direction: column; gap: 8px; }
.note-edit .row { display: flex; gap: 8px; justify-content: flex-end; }

.section-title { font-size: 16px; margin: 34px 0 14px; padding-top: 22px; border-top: 1px dashed var(--line); }
.note-guest { border-left-color: var(--ok); }
.guest-badge {
  display: inline-block; font-size: 12px; font-weight: 700; color: var(--ok);
  margin-bottom: 6px;
}
.auth-switch { font-size: 12px; color: var(--ink-2); text-align: center; }

/* ---- 文件传输 ---- */
.transfer-row { display: flex; gap: 22px; align-items: flex-start; }
.transfer-left { flex: 1; min-width: 0; }
.transfer-side { width: 230px; flex-shrink: 0; }
.qr-card {
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--card); padding: 18px; text-align: center; box-shadow: var(--shadow);
}
#qrBox svg, #qrBox img { width: 150px; height: 150px; border-radius: 8px; }
[data-theme="dark"] #qrBox svg, [data-theme="dark"] #qrBox img { background: #fff; padding: 6px; }
.lan-url { font-family: var(--mono); font-size: 13px; margin-top: 10px; word-break: break-all; user-select: all; }
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  display: flex; align-items: center; gap: 12px;
  border: 2px solid var(--line); border-radius: 12px;
  background: var(--card); padding: 10px 14px;
}
.file-ico {
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  background: var(--bg-soft); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10px; font-weight: 700; color: var(--ink-2);
  text-transform: uppercase;
}
.file-name { font-size: 14px; font-weight: 500; word-break: break-all; }
.file-meta { font-family: var(--mono); font-size: 11px; color: var(--ink-2); }
.file-grow { flex: 1; min-width: 0; }
.file-row .btn { padding: 5px 12px; font-size: 12px; }

/* ---- 弹窗 / 空态 / 提示 ---- */
dialog {
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink); padding: 22px; width: 320px;
}
dialog::backdrop { background: rgba(0,0,0,.35); backdrop-filter: blur(2px); }
.dialog-form { display: flex; flex-direction: column; gap: 14px; }
.dialog-form h3 { font-size: 16px; }
.dialog-form label { font-size: 13px; color: var(--ink-2); display: flex; flex-direction: column; gap: 5px; }
.dialog-form input {
  font: inherit; font-size: 14px; padding: 8px 10px;
  border: 2px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink);
}
.dialog-form input:focus { outline: none; border-color: var(--accent); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }

.empty { text-align: center; color: var(--ink-2); font-size: 14px; padding: 40px 0; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 500;
  padding: 10px 20px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 100; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.foot {
  display: flex; gap: 10px; justify-content: center; align-items: center;
  padding: 16px; border-top: 1px dashed var(--line);
  font-family: var(--mono); font-size: 11px; color: var(--ink-2);
}
.foot i { color: var(--accent); font-style: normal; }

@media (max-width: 720px) {
  .top { flex-wrap: wrap; gap: 12px; padding: 14px 16px 10px; }
  .tabs { margin-left: 0; order: 3; width: 100%; }
  .brand-tag { display: none; }
  .linkbar, main { padding-left: 16px; padding-right: 16px; }
  .transfer-row { flex-direction: column-reverse; }
  .transfer-side { width: 100%; }
  .composer { flex-direction: column; align-items: stretch; }
}
