/* 颜色变量（浅色默认） */
:root {
  --bg: #ffffff;
  --bg-2: #f6f7f8;
  --text: #222;
  --muted: #7a7a7a;
  --border: #e4e6eb;
  --line: #e5e5e5;
  --accent: #000;
  --scroll-track: #efefef;
  --scroll-thumb: #b5b5b5;
  --scroll-thumb-hover: #979797;
  --select-checked: #e0e0e0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151515;
    --bg-2: #1f1f1f;
    --text: #e8e8e8;
    --muted: #a0a0a0;
    --border: #3a3a3a;
    --line: #2f2f2f;
    --accent: #fff;
    --scroll-track: #242424;
    --scroll-thumb: #595959;
    --scroll-thumb-hover: #6e6e6e;
    --select-checked: #2a2a2a;
  }
}

html[data-theme="dark"] {
  --bg: #151515;
  --bg-2: #1f1f1f;
  --text: #e8e8e8;
  --muted: #a0a0a0;
  --border: #3a3a3a;
  --accent: #fff;
}

* { box-sizing: border-box; }
html, body, .app { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Inter,system-ui,Arial,sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden; /* 桌面端隐藏页面滚动条，由编辑区承载滚动 */
}

.app { display: flex; flex-direction: column; min-height: 100dvh; }

.header {
  display: flex; align-items: center; gap: .75rem;
  max-width: 1200px; width: min(92vw, 1200px); margin: 0 auto; padding: .75rem .25rem .5rem;
}
.title { font-size: 1.5rem; font-weight: 800; margin: 0; }
.badge { margin-left: auto; font-size: .85rem; color: var(--muted); background: var(--bg-2); border: 1px solid var(--border); padding: .25rem .5rem; border-radius: .5rem; }
.hidden { display: none !important; }

.btn { border: none; border-radius: .5rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .5ch; }
.btn-primary { background: var(--accent); color: var(--bg); padding: .4rem .8rem; font-size: .9rem; }
.header > .btn-primary { margin-left: auto; }

/* 分享按钮样式（替代文字按钮） */
.btn-share { width: 36px; height: 36px; border-radius: 10px; margin-left: auto; background: var(--bg-2); border: 1px solid var(--border); color: var(--text); }
.btn-share:hover { background: var(--bg); }
.share-icon { position: relative; width: 18px; height: 18px; display: inline-block; }
.share-icon::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 8px; border: 2px solid currentColor; border-top: 0; border-radius: 0 0 4px 4px; }
.share-icon::after { content: ""; position: absolute; left: 50%; transform: translateX(-50%); bottom: 6px; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 8px solid currentColor; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.btn-secondary { background: var(--bg-2); color: var(--text); border: 1px solid var(--border); padding: .4rem .8rem; font-size: .9rem; }
.btn-secondary.copied { position: relative; animation: pop .45s ease, glowLight .6s ease; border-color: var(--accent); }
@keyframes glowLight { 0% { box-shadow: 0 0 0 0 rgba(0,0,0,0); } 50% { box-shadow: 0 0 0 4px rgba(0,0,0,.22); } 100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); } }
@media (prefers-color-scheme: dark) { .btn-secondary.copied { animation: pop .45s ease, glowDark .6s ease; } @keyframes glowDark { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,0); } 50% { box-shadow: 0 0 0 4px rgba(255,255,255,.35); } 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); } } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }
.icon-btn { background: transparent; border: 0; color: var(--muted); font-size: 1.25rem; cursor: pointer; }

/* 分享按钮加载中状态（明/暗主题自适应） */
.btn-share.loading { position: relative; pointer-events: none; opacity: .85; }
.btn-share.loading .share-icon { opacity: 0; }
.btn-share.loading::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--text); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.main { flex: 1; min-height: 0; display: flex; padding-bottom: .5rem; }
.main, .modal-card { max-width: 1200px; width: min(92vw, 1200px); margin: 0 auto; }

.editor {
  width: 100%; height: 100%; min-height: 40dvh;
  padding: 1rem; border: 2px solid var(--border); border-radius: .75rem; resize: none;
  font-size: 1rem; line-height: 1.6; background: var(--bg); color: var(--text);
  overflow: auto;
  flex: 1 1 auto;
  box-sizing: border-box;
}
.editor:focus { outline: none; border-color: var(--muted); box-shadow: 0 0 0 2px rgba(0,0,0,.05); }
.editor::placeholder { color: var(--muted); }

/* 美化编辑区滚动条（WebKit） */
.editor::-webkit-scrollbar { width: 10px; height: 10px; }
.editor::-webkit-scrollbar-track { background: var(--scroll-track); border-radius: 8px; }
.editor::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
.editor::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }

/* Firefox 滚动条颜色 */
.editor { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) var(--scroll-track); }

/* 页脚 */
.footer { height: 56px; display: flex; align-items: center; justify-content: center; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }

.toast { position: fixed; top: 1rem; right: 1rem; background: var(--bg-2); color: var(--text); border: 1px solid var(--border); padding: .75rem 1rem; border-radius: .5rem; box-shadow: 0 6px 20px rgba(0,0,0,.15); max-width: 320px; z-index: 10000; }
/* 移动端避免遮挡右上角按钮，适配安全区域 */
@media (max-width: 768px) {
  .toast { right: .75rem; }
  .toast.center-mobile { left: 50%; right: auto; transform: translateX(-50%); }
  .toast.center-mobile.showing { animation: toastDrop .24s ease-out; }
  @keyframes toastDrop { from { transform: translate(-50%, -10px); opacity: .01; } to { transform: translate(-50%, 0); opacity: 1; } }
}

/* 离线提示条 */
.offline-banner {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: .5rem;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-left: 0; border-right: 0;
  padding: .5rem .75rem; margin: 0 0 .5rem 0;
  font-size: .9rem;
}
.offline-banner .dot { width: 8px; height: 8px; border-radius: 50%; background: #e67e22; box-shadow: 0 0 0 0 rgba(230,126,34,.6); animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(230,126,34,.6);} 70% { box-shadow: 0 0 0 10px rgba(230,126,34,0);} 100% { box-shadow: 0 0 0 0 rgba(230,126,34,0);} }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 1rem; }
.modal-card { background: var(--bg); border: 1px solid var(--border); border-radius: .75rem; overflow: hidden; width: min(560px, 92vw); box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.modal-title { margin: 0; font-size: 1.1rem; }
.modal-body { padding: 1rem; display: grid; gap: .75rem; }
.share-row { display: grid; grid-template-columns: 1fr auto; gap: .5rem; }
.share-input { width: 100%; border: 1px solid var(--border); background: var(--bg-2); color: var(--text); border-radius: .5rem; padding: .6rem .75rem; font-family: ui-monospace,SFMono-Regular,Menlo,monospace; outline: none; }
.share-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,0,0,.08); }
.muted { color: var(--muted); font-size: .9rem; margin: 0; text-align: center; }
/* QR 区域 */
.qr-wrap { display: grid; place-items: center; padding-top: .5rem; position: relative; }
.qr-wrap canvas { border: 0; border-radius: 16px; background: transparent; box-shadow: 0 12px 32px rgba(0,0,0,.18); }
/* 允许移动端在二维码图片上长按呼出保存菜单，仅在该区域开放 */
.qr-wrap img#qrImg { -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; -webkit-user-drag: auto; }

/* 二维码加载动画 */
.qr-spinner { display: none; position: absolute; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--text); animation: spin .7s linear infinite; }
.qr-wrap.loading .qr-spinner { display: block; }
.qr-wrap.loading canvas { opacity: .55; filter: blur(1px); transition: opacity .2s ease; }

/* OTP 输入增强（与 share-input 同风格） */
#twoFACode { text-align: center; letter-spacing: .35ch; font-weight: 700; }

/* 2FA 分段输入样式 */
.otp-group { display: flex; gap: 8px; justify-content: center; align-items: center; }
.otp-input { width: 42px; height: 42px; text-align: center; font-weight: 700; font-size: 1.1rem; border: 1px solid var(--border); background: var(--bg-2); color: var(--text); border-radius: .5rem; outline: none; }
.otp-input:focus { border-color: var(--muted); box-shadow: 0 0 0 3px rgba(0,0,0,.08); }
@media (max-width: 768px) { .otp-input { width: 36px; height: 36px; font-size: 1rem; } }
.otp-group.shake { animation: otp-shake .25s ease; }
@keyframes otp-shake { 10% { transform: translateX(-3px); } 30% { transform: translateX(3px); } 50% { transform: translateX(-2px); } 70% { transform: translateX(2px); } 100% { transform: translateX(0); } }

/* 选择过期时间样式（下拉） */
.form-row { display: flex; }
.select-input { width: 100%; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: .5rem; background: var(--bg-2); color: var(--text); }
.select-input:focus { outline: none; border-color: var(--muted); }
.select-input option { background: var(--bg-2); color: var(--text); }
.select-input option:hover { background: var(--select-checked); }
.select-input option:checked { background: var(--select-checked) !important; color: var(--text); }

/* 弹窗底部统一按钮区域 */
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.modal-actions .btn { min-width: 96px; height: 36px; border-radius: 8px; }

@media (max-width: 768px) {
  .title { font-size: 1.2rem; }
  .btn-primary { padding: .35rem .7rem; font-size: .85rem; }
  .modal-card { width: min(92vw, 480px); }
  /* 移动端文本框聚焦时降低高亮感 */
  .editor:focus { box-shadow: none; border-color: var(--muted); }
}

