:root {
  --bg: #f4f6f8; --paper: #fff; --border: #d8dee4; --text: #1b2733; --muted: #6b7885;
  --primary: #0b7a5b; --primary-d: #095f47; --accent: #0d6efd; --err: #c0392b; --ok: #0b7a5b;
  --radius: 8px; --space: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, "Noto Sans TC", sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--err); min-height: 1.2em; }

.card { max-width: 420px; margin: 8vh auto; background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.login h1 { margin: 0 0 4px; font-size: 22px; }
form label { display: block; margin: 14px 0 4px; font-weight: 600; }
form input, form textarea, form select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff; }
button { padding: 8px 16px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font: inherit; cursor: pointer; }
button.primary { background: var(--primary); color: #fff; border-color: var(--primary-d); font-weight: 700; }
button.primary:hover { background: var(--primary-d); }
button.ghost:hover { background: var(--bg); }
#loginForm button { margin-top: 16px; width: 100%; background: var(--primary); color: #fff; border-color: var(--primary-d); font-weight: 700; }

/* 編輯器 */
.editor { max-width: 1000px; margin: 0 auto; padding: 0 16px 80px; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; background: var(--bg); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.topbar .actions { display: flex; gap: 8px; }
.hint { background: #eef6f2; border: 1px solid #cfe6db; border-radius: 6px; padding: 8px 12px; color: #2c4a3e; font-size: 13px; margin: 10px 0 16px; }

/* 固定 toast：不管捲到哪都看得到送出/部署狀態 */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); max-width: min(560px, 92vw); z-index: 50;
  background: #223; color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.25);
  font-weight: 600; white-space: pre-line; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast.busy { background: #1f3a5f; }
.toast.busy::before { content: "⏳ "; }
.toast.ok { background: var(--primary-d); }
.toast.err { background: #7a1f1f; }
.toast.warn { background: #7a5a12; }
.toast a { color: #fff; text-decoration: underline; font-weight: 800; margin-left: 6px; white-space: nowrap; }
.spin { display: inline-block; animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
button:disabled { opacity: .55; cursor: progress; }

/* 遞迴表單 */
fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 14px; padding: 10px 14px 14px; background: var(--paper); }
fieldset > legend { font-weight: 700; padding: 0 6px; color: var(--primary-d); }
fieldset.depth-1 { background: #fbfcfd; }
fieldset.depth-2 { background: #f7f9fb; }
.field { display: grid; grid-template-columns: 180px 1fr; gap: 8px 14px; align-items: center; margin: 6px 0; }
.field > label { font-weight: 600; color: #33414f; }
.field.bool { grid-template-columns: 180px auto; }
.field input[type=checkbox] { width: auto; }
.arr-item { border-left: 3px solid #e2e8ee; padding: 8px 0 8px 12px; margin: 8px 0; position: relative; }
.arr-item .arr-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.arr-item .arr-head .tag { font-size: 12px; color: var(--muted); }
.arr-tools { margin-top: 6px; }
.arr-tools button { font-size: 13px; padding: 4px 10px; }
button.del { color: var(--err); border-color: #e6b8b1; }
.primitive-list textarea { min-height: 46px; font-family: ui-monospace, monospace; font-size: 13px; }
.note { font-size: 12px; color: var(--muted); margin-top: 2px; grid-column: 2; }
