/* ===========================================================
   base.css —— 变量 / 主题 / 通用组件（AIDE 风格外壳）
   =========================================================== */

:root {
	/* 外框（深海蓝 ActionBar） */
	--ab-bg: #202a44;
	--ab-fg: #ffffff;
	--ab-sub: #aab7d4;
	--ab-line: #141c30;

	/* 页面 */
	--bg: #f5f7fb;
	--bg-alt: #eef2f8;
	--bg-sunken: #e6ebf3;
	--line: #e3e8f0;
	--line-strong: #d2dae7;

	/* 文字 */
	--fg: #1a2436;
	--fg-dim: #65718a;
	--fg-faint: #9aa6bb;

	/* 强调 */
	--accent: #4c6ef5;
	--accent-soft: #e8edff;
	--run: #12a870;
	--run-dark: #0d8a5b;
	--danger: #e5484d;
	--warn: #e8890c;
	--ok: #12a870;

	/* 控件 */
	--radius: 12px;
	--radius-sm: 8px;
	--shadow-1: 0 2px 8px rgba(30, 50, 90, .08);
	--shadow-2: 0 10px 30px rgba(30, 50, 90, .14);
	--shadow-3: 0 18px 48px rgba(20, 35, 70, .26);

	/* 编辑器（Eclipse / AIDE 经典浅色） */
	--ed-bg: #ffffff;
	--ed-fg: #1f2328;
	--ed-gutter-bg: #f2f3f5;
	--ed-gutter-fg: #a8afb8;
	--ed-gutter-cur: #2f7de1;
	--ed-line-cur: #f6f8fa;
	--ed-sel: #cfe3fb;
	--tok-key: #7f0055;
	--tok-str: #2a00ff;
	--tok-com: #3f7f5f;
	--tok-ann: #808080;
	--tok-num: #1a4fb4;
	--tok-type: #1a1f24;
	--tok-tag: #1a4fb4;
	--tok-attr: #7f0055;
	--tok-punc: #565b63;

	/* 控制台 */
	--con-bg: #1b1d21;
	--con-fg: #d7dae0;
	--con-dim: #7c828c;
	--con-ok: #4ec9b0;
	--con-err: #f48771;
	--con-warn: #dcdcaa;
	--con-cmd: #6fb3ff;

	--font-mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, "Courier New", monospace;
	--font-ui: -apple-system, "PingFang SC", "Noto Sans CJK SC", "Segoe UI", Roboto, sans-serif;
}

html[data-theme="dark"] {
	--ab-bg: #111827;
	--ab-line: #0a0f1a;
	--ab-sub: #98a6c4;

	--bg: #0f1420;
	--bg-alt: #151c2b;
	--bg-sunken: #0b101a;
	--line: #263145;
	--line-strong: #37445e;

	--fg: #e8edf7;
	--fg-dim: #9aa6bb;
	--fg-faint: #6f7c92;

	--accent: #6f8cff;
	--accent-soft: #1d2742;
	--run: #1fb987;
	--run-dark: #159a6d;
	--danger: #f27378;

	--ed-bg: #121a28;
	--ed-fg: #d9dce1;
	--ed-gutter-bg: #0d1420;
	--ed-gutter-fg: #5c626b;
	--ed-line-cur: #182238;
	--ed-sel: #2e4a6d;
	--tok-key: #cc7832;
	--tok-str: #6a8759;
	--tok-com: #7a8491;
	--tok-ann: #bbb529;
	--tok-num: #6897bb;
	--tok-type: #a9b7c6;
	--tok-tag: #e8bf6a;
	--tok-attr: #bababa;
	--tok-punc: #a9b7c6;

	--con-bg: #0c111b;
	--con-fg: #d0d4da;
}

* { -webkit-tap-highlight-color: transparent; }

html, body {
	margin: 0;
	padding: 0;
	height: 100%;
	overflow: hidden;
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font-ui);
	font-size: 14px;
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	overscroll-behavior: none;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

svg.ic {
	width: 22px;
	height: 22px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.9;
	stroke-linecap: round;
	stroke-linejoin: round;
	display: block;
	pointer-events: none;
}
svg.ic.solid { fill: currentColor; stroke: none; }

#app {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

/* ---------- 视图 ---------- */
.view {
	position: absolute;
	inset: 0;
	display: none;
	flex-direction: column;
	min-height: 0;
	background: var(--bg);
}
.view.active { display: flex; }

/* ---------- ActionBar ---------- */
.actionbar {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 4px;
	height: 52px;
	padding: 0 4px 0 6px;
	background: var(--ab-bg);
	color: var(--ab-fg);
	box-shadow: 0 1px 0 var(--ab-line), 0 2px 6px rgba(0, 0, 0, .10);
	position: relative;
	z-index: 20;
}

.ab-logo {
	width: 30px;
	height: 30px;
	border-radius: 8px;
	background: linear-gradient(140deg, #8bc34a, #4caf50 55%, #2e7d32);
	color: #fff;
	font-weight: 800;
	font-size: 17px;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-right: 2px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
	flex: 0 0 auto;
}

.ab-title-wrap {
	flex: 1 1 auto;
	min-width: 0;
	padding-left: 6px;
}

.ab-title {
	font-size: 16px;
	font-weight: 600;
	letter-spacing: .2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	line-height: 1.25;
}

.ab-sub {
	font-size: 11px;
	color: var(--ab-sub);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	line-height: 1.3;
}

.ab-btn {
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: 0;
	border-radius: 50%;
	color: inherit;
	transition: background .15s;
}
.ab-btn:active { background: rgba(255, 255, 255, .14); }
.ab-btn.sm { width: 32px; height: 32px; }
.ab-btn.sm svg.ic { width: 18px; height: 18px; }

/* ---------- 内容区 ---------- */
.content {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	background: var(--bg);
}
.list-pad { height: 24px; }

/* ---------- 列表（AIDE 项目列表） ---------- */
.list-head {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 16px 6px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .4px;
	color: var(--fg-dim);
	text-transform: uppercase;
	background: var(--bg);
	border-bottom: 1px solid var(--line);
}
.list-head-right { font-weight: 500; color: var(--fg-faint); }

.list { list-style: none; margin: 0; padding: 0; }

.list-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 11px 14px;
	background: var(--bg);
	border-bottom: 1px solid var(--line);
	position: relative;
}
.list-item:active { background: var(--bg-alt); }

.li-icon {
	width: 38px;
	height: 38px;
	border-radius: 9px;
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-weight: 700;
	font-size: 16px;
	box-shadow: var(--shadow-1);
	letter-spacing: .5px;
}
.li-icon.folder { background: #f0b429; }
.li-icon.dir { background: #8a94a6; }

.li-main { flex: 1 1 auto; min-width: 0; }
.li-title {
	font-size: 14.5px;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.li-sub {
	font-size: 12px;
	color: var(--fg-dim);
	margin-top: 2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	direction: ltr;
}
.li-meta {
	font-size: 11px;
	color: var(--fg-faint);
	margin-top: 3px;
	display: flex;
	gap: 8px;
}
.li-arrow { color: var(--fg-faint); flex: 0 0 auto; }
.li-arrow svg.ic { width: 18px; height: 18px; }

.list-empty {
	padding: 60px 30px;
	text-align: center;
	color: var(--fg-dim);
}
.list-empty p { margin: 4px 0; }
.list-empty .dim { color: var(--fg-faint); font-size: 12.5px; }
.empty-ic {
	width: 64px;
	height: 64px;
	margin: 0 auto 14px;
	border-radius: 18px;
	background: var(--bg-alt);
	border: 1px solid var(--line);
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--fg-faint);
}
.empty-ic svg.ic { width: 30px; height: 30px; }

/* ---------- 按钮 ---------- */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	height: 42px;
	padding: 0 18px;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius);
	background: var(--bg);
	color: var(--fg);
	font-size: 14px;
	font-weight: 600;
	font-family: inherit;
	transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn svg.ic { width: 18px; height: 18px; }
.btn-primary {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}
.btn-run {
	background: var(--run);
	border-color: var(--run);
	color: #fff;
}
.btn-ghost { background: var(--bg-alt); }
.btn-danger { color: var(--danger); border-color: var(--line-strong); background: var(--bg); }
.btn-block { flex: 1 1 auto; width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn[disabled] { opacity: .5; }

.bottom-bar {
	flex: 0 0 auto;
	display: flex;
	gap: 10px;
	padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
	background: var(--bg-alt);
	border-top: 1px solid var(--line);
}

/* ---------- 表单 ---------- */
.group-title {
	padding: 18px 16px 8px;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .5px;
	text-transform: uppercase;
	color: var(--accent);
}
.group {
	background: var(--bg);
	border-top: 1px solid var(--line);
	border-bottom: 1px solid var(--line);
}
.field {
	display: block;
	padding: 10px 16px;
	border-bottom: 1px solid var(--line);
}
.field:last-child { border-bottom: 0; }
.field-label {
	display: block;
	font-size: 12px;
	color: var(--fg-dim);
	margin-bottom: 4px;
}
.field-input {
	width: 100%;
	box-sizing: border-box;
	border: 1px solid var(--line-strong);
	background: var(--bg-alt);
	color: var(--fg);
	border-radius: var(--radius-sm);
	padding: 9px 11px;
	font-size: 14px;
	font-family: inherit;
	outline: none;
}
.field-input:focus { border-color: var(--accent); background: var(--bg); }
select.field-input { height: 40px; appearance: none; }
.field-input.compact { width: auto; min-width: 150px; }
.field-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 16px;
	border-bottom: 1px solid var(--line);
}
.field-row:last-child { border-bottom: 0; }
.field-row .field-label { margin: 0; font-size: 14px; color: var(--fg); }
.field-hint {
	padding: 10px 16px;
	font-size: 12px;
	color: var(--fg-dim);
	line-height: 1.5;
}
.field-hint.ok { color: var(--ok); }
.field-hint.err { color: var(--danger); }
.range { width: 100%; accent-color: var(--accent); }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i {
	position: absolute;
	inset: 0;
	background: var(--line-strong);
	border-radius: 24px;
	transition: background .18s;
}
.switch i::after {
	content: "";
	position: absolute;
	width: 18px;
	height: 18px;
	left: 3px;
	top: 3px;
	background: #fff;
	border-radius: 50%;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
	transition: transform .18s;
}
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }

/* ---------- 对话框 ---------- */
.dialog-wrap {
	position: fixed;
	inset: 0;
	z-index: 90;
	background: rgba(0, 0, 0, .42);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 18px;
	animation: fade .14s ease-out;
}
.dialog-wrap[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.dialog {
	width: 100%;
	max-width: 420px;
	max-height: 86vh;
	display: flex;
	flex-direction: column;
	background: var(--bg);
	border-radius: 14px;
	box-shadow: var(--shadow-3);
	overflow: hidden;
	animation: pop .16s ease-out;
}
@keyframes pop { from { transform: scale(.94); opacity: .6; } to { transform: scale(1); opacity: 1; } }

.dlg-title {
	padding: 16px 18px 10px;
	font-size: 16px;
	font-weight: 700;
	color: var(--fg);
}
.dlg-body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	padding: 0 18px 8px;
	font-size: 13.5px;
	color: var(--fg-dim);
	line-height: 1.6;
}
.dlg-foot {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid var(--line);
	background: var(--bg-alt);
}

/* 对话框内表单 */
.dlg-field { margin: 10px 0; }
.dlg-field label { display: block; font-size: 12px; color: var(--fg-dim); margin-bottom: 5px; }
.dlg-field input {
	width: 100%;
	box-sizing: border-box;
	padding: 10px 12px;
	border: 1px solid var(--line-strong);
	border-radius: 8px;
	background: var(--bg-alt);
	color: var(--fg);
	font-size: 14px;
	font-family: inherit;
	outline: none;
}
.dlg-field input:focus { border-color: var(--accent); background: var(--bg); }

.type-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
	margin: 6px 0 2px;
}
.type-card {
	border: 1.5px solid var(--line-strong);
	border-radius: 10px;
	padding: 10px 6px 8px;
	background: var(--bg);
	text-align: center;
	transition: border-color .15s, background .15s;
}
.type-card.on {
	border-color: var(--accent);
	background: var(--accent-soft);
}
.type-card .ti {
	width: 30px;
	height: 30px;
	margin: 0 auto 6px;
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-weight: 700;
	font-size: 13px;
}
.type-card .tn { font-size: 11.5px; color: var(--fg); font-weight: 600; line-height: 1.3; }

/* ---------- 浮动菜单 ---------- */
.menu-pop {
	position: fixed;
	z-index: 95;
	min-width: 190px;
	padding: 6px;
	background: var(--bg);
	border-radius: 10px;
	box-shadow: var(--shadow-2);
	border: 1px solid var(--line);
	animation: pop .12s ease-out;
}
.menu-pop[hidden] { display: none; }
.menu-item {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 10px 12px;
	border: 0;
	background: transparent;
	color: var(--fg);
	font-size: 14px;
	font-family: inherit;
	text-align: left;
	border-radius: 7px;
}
.menu-item:active { background: var(--bg-alt); }
.menu-item svg.ic { width: 18px; height: 18px; color: var(--fg-dim); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger svg.ic { color: var(--danger); }
.menu-sep { height: 1px; margin: 5px 6px; background: var(--line); }

/* ---------- Toast ---------- */
.toast {
	position: fixed;
	left: 50%;
	bottom: 76px;
	transform: translate(-50%, 12px);
	max-width: 82vw;
	padding: 10px 16px;
	background: rgba(28, 30, 34, .95);
	color: #fff;
	font-size: 13px;
	line-height: 1.45;
	border-radius: 20px;
	opacity: 0;
	pointer-events: none;
	transition: opacity .2s, transform .2s;
	z-index: 120;
	text-align: center;
	box-shadow: var(--shadow-2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 通用工具 ---------- */
.spacer { flex: 1 1 auto; }
.dim { color: var(--fg-dim); }
.hidden { display: none !important; }
