/* Engram 界面基础：主流、干净、浅色为主，支持深色 */
:root {
  --bg: #f7f6f3; --surface: #ffffff; --surface-2: #f3f2ee; --surface-3: #ebe9e4; --hover: rgba(28, 25, 20, .045);
  --border: #e6e3dd; --border-strong: #d6d2ca;
  --text: #1d1b18; --text-2: #5d5953; --text-3: #8d8880;
  --brand: #e0912f; --brand-soft: #fbf0df; --brand-text: #9a5b0e;
  --primary: #1d1b18; --primary-text: #ffffff;
  --ok: #2f9e6b; --ok-soft: #e4f4ec; --warn: #d9534f; --warn-soft: #fbe9e8; --info: #3b7ddd; --info-soft: #e7effb;
  --shadow-sm: 0 1px 2px rgba(28, 25, 20, .05); --shadow: 0 1px 3px rgba(28, 25, 20, .06), 0 6px 18px -6px rgba(28, 25, 20, .08);
  --shadow-lg: 0 20px 50px -12px rgba(28, 25, 20, .25);
  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  --font: 'Geist', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: light;
}
:root:lang(ja) { --font: 'Geist', -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Noto Sans CJK JP', sans-serif; }
:root[data-theme="dark"] {
  --bg: #121110; --surface: #1a1918; --surface-2: #222120; --surface-3: #2b2a28; --hover: rgba(255, 250, 240, .05);
  --border: #2c2a28; --border-strong: #3a3835;
  --text: #eeece8; --text-2: #aaa69f; --text-3: #7a766f;
  --brand: #eda54a; --brand-soft: rgba(237, 165, 74, .14); --brand-text: #f2bc73;
  --primary: #eeece8; --primary-text: #161514;
  --ok: #4cc08a; --ok-soft: rgba(76, 192, 138, .13); --warn: #ef7a74; --warn-soft: rgba(239, 122, 116, .13); --info: #6ea2f0; --info-soft: rgba(110, 162, 240, .13);
  --shadow-sm: none; --shadow: 0 1px 0 rgba(255, 255, 255, .03); --shadow-lg: 0 20px 50px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--brand-soft); }
img, svg { display: block; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }

/* 品牌 */
.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 650; font-size: 16px; letter-spacing: -.01em; }
.logo-mark { width: 26px; height: 26px; border-radius: 8px; background: radial-gradient(circle at 50% 50%, #fff6e6 0 2.5px, transparent 3px), radial-gradient(circle at 30% 30%, #ffd79a, #e0912f 55%, #a35a13);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25), 0 2px 8px -2px rgba(224, 145, 47, .6); flex: none; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13.5px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, opacity .15s; box-shadow: var(--shadow-sm); }
.btn:hover { background: var(--surface-2); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary); opacity: .88; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand); opacity: .9; }
.btn-ghost { background: none; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-danger { color: var(--warn); }
.btn-danger:hover { background: var(--warn-soft); border-color: var(--warn-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: var(--r); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: var(--r-sm); border: none; background: none; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

/* 表单 */
.input, .select, .textarea { width: 100%; height: 38px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.65; }
.select { appearance: none; padding-right: 32px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%238d8880' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='m3 4.5 3 3 3-3'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 500; color: var(--text); }
.hint { font-size: 12.5px; color: var(--text-3); }
.err { font-size: 12.5px; color: var(--warn); }
input[type=range] { accent-color: var(--brand); width: 100%; }
input[type=checkbox] { accent-color: var(--brand); width: 15px; height: 15px; }
.switch { position: relative; width: 36px; height: 21px; border-radius: 99px; background: var(--surface-3); border: none; cursor: pointer; flex: none; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch.on { background: var(--brand); } .switch.on::after { transform: translateX(15px); }

/* 卡片与布局 */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 14.5px; }
.card-head .sub { font-size: 12.5px; color: var(--text-3); }
.card-body { padding: 16px 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); } .small { font-size: 12.5px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* 标签 */
.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag-brand { background: var(--brand-soft); color: var(--brand-text); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-info { background: var(--info-soft); color: var(--info); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--brand)); flex: none; }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; }

/* 分段切换 */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 8px; }
.seg button { height: 28px; padding: 0 12px; border: none; background: none; border-radius: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; font-weight: 500; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border); }
.tabs button, .tabs a { padding: 10px 0; border: none; background: none; font-size: 14px; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs .on { color: var(--text); border-color: var(--text); }

/* 列表 */
.list-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--hover); }
.list-item .dot { margin-top: 7px; }
.list-item .t { font-size: 14px; font-weight: 500; color: var(--text); }
.list-item .m { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.empty { padding: 40px 20px; text-align: center; color: var(--text-3); font-size: 13.5px; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; font-weight: 600; }

/* 表格 */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--text-3); padding: 10px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.table td { padding: 11px 20px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }

/* 弹窗、提示 */
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(20, 18, 15, .38); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; animation: fade .15s; }
.dialog { width: min(480px, 100%); max-height: 90vh; overflow-y: auto; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: pop .18s cubic-bezier(.2, .8, .3, 1); }
.dialog.wide { width: min(640px, 100%); }
.dialog-head { display: flex; align-items: center; padding: 18px 20px 0; } .dialog-head h3 { font-size: 16px; flex: 1; }
.dialog-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); opacity: 0; z-index: 99; background: var(--primary); color: var(--primary-text); font-size: 13.5px; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); transition: all .25s; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r); background: var(--info-soft); color: var(--text); font-size: 13px; line-height: 1.6; }
.notice.brand { background: var(--brand-soft); }
.notice svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--info); }
.notice.brand svg { color: var(--brand-text); }

/* 语言切换 */
.lang { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 8px; }
.lang button { border: none; background: none; height: 26px; padding: 0 9px; border-radius: 6px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.lang button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }

pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; font: 12.5px/1.6 var(--mono); overflow-x: auto; white-space: pre; color: var(--text); }
kbd, code.k { font: 12px var(--mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
