/* Linova Options 后台编辑器 — 贴近 Shopify 后台的样式 */
:root {
  --bg: #f1f1f1; --card: #ffffff; --fg: #303030; --muted: #616161; --line: #e3e3e3; --line-strong: #c9c9c9;
  --primary: #303030; --primary-fg: #ffffff; --accent: #005bd3; --accent-soft: #eaf4ff;
  --ok: #0c5132; --ok-bg: #cdfee1; --warn-bg: #fff1e3; --warn: #5e4200; --danger: #8e0b21; --danger-bg: #fee9e8;
  --radius: 12px; --font: -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 13px/1.45 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.wrap { max-width: 1240px; margin: 0 auto; padding: 16px; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.topbar h1 { font-size: 20px; margin: 0; font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 0 rgba(0,0,0,.07), 0 0 0 1px rgba(0,0,0,.04); }
.card-pad { padding: 16px; }
.card h2 { font-size: 14px; margin: 0 0 4px; font-weight: 650; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 8px; padding: 6px 12px; min-height: 30px;
  background: var(--card); box-shadow: inset 0 0 0 1px var(--line-strong), 0 1px 0 rgba(0,0,0,.05); cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f7f7f7; }
.btn:focus-visible, .input:focus-visible, .swatch-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-primary { background: var(--primary); color: var(--primary-fg); box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.btn-primary:hover { background: #1a1a1a; }
.btn-primary[disabled] { opacity: .5; cursor: default; }
.btn-plain { box-shadow: none; background: transparent; color: var(--accent); padding: 4px 6px; }
.btn-plain:hover { background: var(--accent-soft); }
.btn-danger { color: var(--danger); }
.btn-icon { width: 28px; min-height: 28px; padding: 0; box-shadow: none; background: transparent; }
.btn-icon:hover { background: #ebebeb; }
.btn-icon[disabled] { opacity: .3; cursor: default; }
.input, select.input, textarea.input { width: 100%; border: 1px solid #8a8a8a; border-radius: 8px; padding: 6px 10px; background: #fdfdfd; min-height: 32px; }
textarea.input { min-height: 60px; resize: vertical; }
.input-sm { width: 90px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; color: var(--fg); }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { flex: 1 1 140px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 8px; font-size: 12px; background: #ebebeb; color: var(--muted); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.banner { padding: 12px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); margin-bottom: 12px; }
.banner-err { background: var(--danger-bg); color: var(--danger); }

/* 商品列表 */
.search { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.plist { list-style: none; margin: 0; padding: 0; }
.plist li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.plist li:last-child { border-bottom: 0; }
.plist li:hover { background: #fafafa; }
.plist img, .plist .noimg { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); background: #f6f6f6; flex: none; }
.plist .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

/* 编辑器布局 */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 440px); gap: 16px; align-items: start; }
.col { display: grid; gap: 12px; min-width: 0; }
.sticky { position: sticky; top: 12px; }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } .sticky { position: static; } }

.opt { overflow: hidden; }
.opt-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafafa; }
.opt-head .input { flex: 1; font-weight: 600; }
.opt-type { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.opt-body { padding: 12px; display: grid; gap: 12px; }
.opt.collapsed .opt-body { display: none; }

.choices { display: grid; gap: 8px; }
.choice { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 8px; border: 1px solid var(--line); border-radius: 10px; }
.choice-fields { display: grid; gap: 6px; min-width: 0; }
.choice-fields .row { gap: 6px; }
.choice-tools { display: flex; flex-direction: column; gap: 2px; }
.swatch-pick { width: 52px; height: 52px; border-radius: 8px; border: 1px dashed var(--line-strong); background: #fafafa center/cover no-repeat; cursor: pointer;
  display: grid; place-items: center; font-size: 11px; color: var(--muted); padding: 0; overflow: hidden; }
.swatch-pick.font { font-size: 18px; color: var(--fg); background: #fff; border-style: solid; }
.linked { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.linked img { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; border: 1px solid var(--line); }
.price { display: flex; align-items: center; gap: 4px; }
.price .input { width: 84px; }

.addmenu { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.addmenu .btn { justify-content: flex-start; padding: 10px 12px; height: auto; white-space: normal; text-align: left; }
.addmenu small { display: block; color: var(--muted); font-size: 11px; }

/* 预览 */
.stage-wrap { background: repeating-conic-gradient(#f3f3f3 0% 25%, #fafafa 0% 50%) 50% / 16px 16px; border-radius: 10px; padding: 10px; }
.stage { position: relative; margin: 0 auto; user-select: none; touch-action: none; max-width: 100%; }
.stage img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 6px; pointer-events: none; }
.stage .noimg { aspect-ratio: 1; display: grid; place-items: center; color: var(--muted); background: #fff; border-radius: 6px; padding: 20px; text-align: center; }
.layer { position: absolute; white-space: nowrap; line-height: 1; cursor: grab; padding: 2px; outline: 1px dashed transparent; }
.layer:hover { outline-color: rgba(0,91,211,.5); }
.layer.sel { outline: 1.5px solid var(--accent); background: rgba(0,91,211,.06); }
.layer.sample { opacity: .55; }
.layer.dragging { cursor: grabbing; }
.layer-list { display: grid; gap: 6px; }
.layer-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.layer-item.sel { border-color: var(--accent); background: var(--accent-soft); }
.layer-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slider { display: grid; grid-template-columns: 76px 1fr 44px; align-items: center; gap: 8px; }
.slider input[type=range] { width: 100%; }
.slider output { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
input[type=color] { width: 40px; height: 32px; padding: 2px; border: 1px solid #8a8a8a; border-radius: 8px; background: #fff; }

/* 弹窗 */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { width: min(640px, 100%); max-height: 86vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 16px; overflow: auto; display: grid; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.imggrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.imggrid button { padding: 0; border: 2px solid transparent; border-radius: 10px; background: #f6f6f6; cursor: pointer; overflow: hidden; position: relative; aspect-ratio: 1; }
.imggrid button.on { border-color: var(--accent); }
.imggrid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.imggrid .n { position: absolute; left: 4px; top: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; border-radius: 6px; padding: 0 6px; }
.colors { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1a1a1a; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; }
.toast.err { background: var(--danger); }
.savebar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: #1a1a1a; color: #fff; border-radius: 0 0 12px 12px; margin: -16px -16px 16px; }
.savebar .grow { flex: 1; }
.savebar .btn { box-shadow: none; }
.savebar .btn:not(.btn-primary) { background: #3a3a3a; color: #fff; }
.savebar .btn-primary { background: #fff; color: #1a1a1a; }
.json { font: 12px/1.5 ui-monospace, Menlo, monospace; white-space: pre-wrap; word-break: break-all; background: #f6f6f6; padding: 12px; border-radius: 8px; max-height: 50vh; overflow: auto; }
