:root {
  --brand: #1E40AF;
  --brand-2: #2563EB;
  --brand-ink: #1E3A8A;
  --brand-tint: #EEF3FE;
  --bg: #F5F7FB;
  --card: #FFFFFF;
  --ink: #111827;
  --muted: #4B5563;
  --faint: #6B7280;
  --line: #E5E7EB;
  --danger: #B91C1C;
  --danger-tint: #FEF2F2;
  --ok: #047857;
  --ok-tint: #ECFDF5;
  --warn: #92400E;
  --warn-tint: #FFFBEB;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.55; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
img { display: block; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 启动 */
.boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.boot-logo img { border-radius: 14px; opacity: .9; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--brand-ink); }
.btn:focus-visible, .field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .tile:focus-visible, .icon-btn:focus-visible, .tab:focus-visible { outline: 3px solid #93B4F7; outline-offset: 2px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; min-height: 46px; font-size: 16px; }
.btn.ghost { background: var(--card); color: var(--brand); border-color: #BFD0F5; }
.btn.ghost:hover { background: var(--brand-tint); }
.btn.danger { background: var(--card); color: var(--danger); border-color: #F5C2C2; }
.btn.danger:hover { background: var(--danger-tint); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; font-weight: 500; border-radius: 8px; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--brand-tint); color: var(--brand); }
.icon-btn svg { width: 20px; height: 20px; }

/* 表单 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #D1D5DB; border-radius: 10px; background: #fff; }
.field textarea { min-height: 140px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.field .hint { font-size: 12px; color: var(--faint); }
.check { display: flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.field label.check { font-size: 14px; font-weight: 400; color: var(--ink); }
.form { display: flex; flex-direction: column; gap: 16px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.err { font-size: 13px; color: var(--danger); background: var(--danger-tint); border-radius: 8px; padding: 8px 12px; }

/* 登录页 */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.auth-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 32px 28px; }
.auth-head { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 28px; text-align: center; }
.auth-head img { width: 72px; height: 72px; border-radius: 16px; }
.auth-head h1 { margin: 0; font-size: 22px; }
.auth-head p { margin: 0; color: var(--muted); font-size: 14px; }
.auth-foot { margin-top: 20px; text-align: center; font-size: 12px; color: var(--faint); }

/* 顶栏 */
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.94); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.topbar-in { max-width: 1080px; margin: 0 auto; height: 60px; padding: 0 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 16px; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.spacer { flex: 1; }
.who { position: relative; }
.who-btn { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); cursor: pointer; }
.who-btn:hover { background: var(--brand-tint); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; }
.who-name { font-size: 14px; font-weight: 600; }
.menu { position: absolute; right: 0; top: 48px; min-width: 180px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 12px 32px rgba(17,24,39,.12); }
.menu button, .menu a { display: flex; width: 100%; align-items: center; min-height: 40px; padding: 0 12px; border: 0; background: none; border-radius: 8px; text-align: left; cursor: pointer; text-decoration: none; color: var(--ink); font-size: 14px; }
.menu button:hover, .menu a:hover { background: var(--brand-tint); }
.menu .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu .danger { color: var(--danger); }

/* 主体 */
.main { max-width: 1080px; margin: 0 auto; padding: 24px 16px calc(40px + env(safe-area-inset-bottom)); }
.greet { margin: 8px 0 24px; }
.greet h1 { margin: 0 0 4px; font-size: 24px; }
.greet p { margin: 0; color: var(--muted); }

/* 首页横幅：每日美图 + 语录 */
.hero { position: relative; overflow: hidden; aspect-ratio: 2.6 / 1; min-height: 260px; max-height: 420px; border-radius: 22px; margin: 4px 0 28px; color: #fff; isolation: isolate;
  background: linear-gradient(135deg, #1E3A8A 0%, #1E40AF 45%, #2563EB 100%); display: flex; align-items: flex-end; }
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.14); z-index: -1; }
.hero::before { width: 420px; height: 420px; right: -120px; top: -180px; box-shadow: 0 0 0 60px rgba(255,255,255,.04), 0 0 0 130px rgba(255,255,255,.03); }
.hero::after { width: 220px; height: 220px; left: 38%; bottom: -150px; }
.hero-bg { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: 0; transform: scale(1.04); transition: opacity .8s ease, transform 1.6s ease; z-index: 0; }
.hero.has-img .hero-bg { opacity: 1; transform: scale(1); }
.hero-shade { position: absolute; inset: 0; z-index: 1; opacity: 0; transition: opacity .8s ease;
  background: linear-gradient(180deg, rgba(10,18,40,.10) 0%, rgba(10,18,40,.25) 40%, rgba(10,18,40,.72) 100%), linear-gradient(90deg, rgba(10,18,40,.45) 0%, rgba(10,18,40,0) 70%); }
.hero.has-img .hero-shade { opacity: 1; }
.hero-in { position: relative; z-index: 2; padding: 28px 32px 30px; max-width: 760px; }
.hero-date { font-size: 13px; letter-spacing: .08em; opacity: .85; margin-bottom: 6px; }
.hero-hi { margin: 0 0 14px; font-size: 26px; font-weight: 700; text-shadow: 0 1px 12px rgba(0,0,0,.25); }
.hero-quote { margin: 0; padding-left: 14px; border-left: 3px solid rgba(255,255,255,.7); }
.hero-quote p { margin: 0; font-family: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif; font-size: 21px; line-height: 1.6; letter-spacing: .02em; text-shadow: 0 1px 10px rgba(0,0,0,.35); }
.hero-quote cite { display: block; margin-top: 6px; font-style: normal; font-size: 13px; opacity: .85; }
/* 后台：首页图片 */
.gal-note { flex: 1 1 320px; margin: 0; }
.pic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.pic-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.pic-card.off .pic-prev { filter: grayscale(1); opacity: .55; }
.pic-prev { position: relative; aspect-ratio: 2.6 / 1; background-color: #E5E7EB; background-size: cover; background-position: center; }
.pic-today { position: absolute; left: 10px; top: 10px; }
.pic-ctl { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.pic-ctl select { min-height: 36px; padding: 4px 8px; border: 1px solid #D1D5DB; border-radius: 8px; background: #fff; }
.pic-ctl .spacer { flex: 1; }
.section-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }
.section-head h2 { margin: 0; font-size: 18px; }
.section-head span { font-size: 13px; color: var(--faint); }
.section-head .hint-m { display: none; }

/* 拖动排序 */
.tile { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.tiles.sorting .tile { cursor: grabbing; }
.tile-placeholder { opacity: .25; border-style: dashed; border-color: #93B4F7; }
.tile-ghost { position: fixed; z-index: 70; margin: 0; pointer-events: none; transform: scale(1.06) rotate(-1.5deg); box-shadow: 0 18px 40px rgba(30,64,175,.25); border-color: #93B4F7; transition: none; }

/* 软件图标 */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 12px 18px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; cursor: pointer; text-align: center; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
.tile:hover { transform: translateY(-2px); border-color: #BFD0F5; box-shadow: 0 10px 24px rgba(30,64,175,.10); }
.tile:active { transform: translateY(0); }
.tile[aria-busy="true"] { opacity: .6; pointer-events: none; }
.tile-icon { width: 72px; height: 72px; border-radius: 16px; overflow: hidden; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 30px; font-weight: 700; }
.tile-icon img { width: 100%; height: 100%; object-fit: cover; }
.tile-name { font-weight: 600; font-size: 15px; }
.tile-desc { font-size: 12px; color: var(--faint); margin-top: -8px; }
.empty { background: var(--card); border: 1px dashed #CBD5E1; border-radius: 16px; padding: 40px 20px; text-align: center; color: var(--muted); }

/* 后台 */
.admin-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 16px; }
.admin-head h1 { margin: 0; font-size: 22px; flex: 1; }
.tabs { display: flex; gap: 4px; background: #E9EEF8; padding: 4px; border-radius: 12px; margin-bottom: 16px; width: fit-content; max-width: 100%; overflow-x: auto; }
.tab { display: inline-flex; align-items: center; text-decoration: none; min-height: 36px; padding: 0 16px; border: 0; border-radius: 9px; background: none; cursor: pointer; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--card); color: var(--brand); box-shadow: 0 1px 3px rgba(17,24,39,.08); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 220px; min-width: 0; }
.toolbar .search input, .toolbar select { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid #D1D5DB; border-radius: 10px; background: #fff; }
.toolbar select { width: auto; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #F8FAFD; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: 6px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.ok { background: var(--ok-tint); color: var(--ok); }
.tag.off { background: #F3F4F6; color: var(--muted); }
.tag.warn { background: var(--warn-tint); color: var(--warn); }
.tag.danger { background: var(--danger-tint); color: var(--danger); }
.tag.brand { background: var(--brand-tint); color: var(--brand-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.mini-icon { width: 28px; height: 28px; border-radius: 7px; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 13px; vertical-align: middle; }
.mini-icon img { width: 100%; height: 100%; object-fit: cover; }
.app-cell { display: flex; align-items: center; gap: 10px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.pager .btns { display: flex; gap: 6px; }

/* 弹窗（原生 div） */
.modal-mask { position: fixed; inset: 0; z-index: 50; background: rgba(17,24,39,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--card); border-radius: 16px; box-shadow: 0 24px 64px rgba(17,24,39,.25); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 0; }
.modal-head h2 { margin: 0; font-size: 18px; flex: 1; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; flex-wrap: wrap; }
.secret-box { display: flex; gap: 8px; align-items: stretch; }
.secret-box code { flex: 1; min-width: 0; white-space: pre-wrap; padding: 10px 12px; background: #F3F6FC; border: 1px solid #D6E0F5; border-radius: 10px; word-break: break-all; font-size: 13px; }
.notice { background: var(--warn-tint); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.result-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.result-list .row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; background: #F8FAFD; border-radius: 8px; font-size: 13px; }
.app-checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; }

/* 提示条 */
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--danger); }

@media (max-width: 640px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 16px 6px 12px; border-radius: 16px; gap: 8px; }
  .tile-icon { width: 60px; height: 60px; border-radius: 14px; }
  .tile-name { font-size: 13px; }
  .tile-desc { display: none; }
  .who-name { display: none; }
  .who-btn { padding: 0 4px; }
  .form-row, .app-checks { grid-template-columns: minmax(0, 1fr); }
  .greet h1 { font-size: 21px; }
  .hero { aspect-ratio: auto; min-height: 240px; border-radius: 18px; margin-bottom: 22px; }
  .hero-in { padding: 20px 18px 34px; }
  .hero-hi { font-size: 21px; margin-bottom: 10px; }
  .hero-quote p { font-size: 17px; }
  .section-head .hint-d { display: none; }
  .section-head .hint-m { display: inline; }
  .modal-mask { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 16px 16px 0 0; max-height: 92vh; padding-bottom: env(safe-area-inset-bottom); }
  th, td { padding: 10px; }
}
@media (prefers-reduced-motion: reduce) { .tile, #toast, .hero-bg, .hero-shade { transition: none; } .hero-bg { transform: none; } }
