/* ===========================================================
 * PhotoLite · 暗夜黑 + 橙黄点缀主题
 * 布局：顶部工具栏 + 左(素材/图层) + 中(画布) + 右(属性)
 * =========================================================== */
:root {
  --bg:        #0A0A0C;   /* 最底层背景（近黑的蓝） */
  --panel:     #151517;   /* 面板底 */
  --panel-2:   #1B1B1E;   /* 卡片/输入底 */
  --panel-3:   #242429;   /* hover */
  --line:      #2E2E33;   /* 分隔线 */
  --line-soft: #232327;
  --text:      #F0EBE1;
  --text-dim:  #A9A49B;
  --text-mute: #6F6A61;
  --accent:    #FFA51F;   /* 主蓝 */
  --accent-2:  #E08A00;
  --accent-s:  rgba(255,165,31,.16);
  --yellow:    #FFC41F;   /* 标注默认色 */
  --danger:    #FF5A5F;
  --ok:        #28C76F;
  --radius:    8px;
  --radius-s:  6px;
  --h-top:     52px;
  --w-left:    236px;
  --w-right:   288px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}
.muted { color: var(--text-mute); font-weight: 400; }
.hidden { display: none !important; }

/* ---------------- 通用控件 ---------------- */
.btn {
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover  { background: var(--panel-3); border-color: #3A3A40; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #FFBE45, #F79A0B); border-color: #FFC96B; color: #241703; font-weight: 600; }
.btn.primary:hover { background: linear-gradient(180deg, #FFC95C, #FFA51F); }
.btn.danger  { color: var(--danger); border-color: #4A2130; }
.btn.danger:hover { background: #2A1420; }
.btn.ghost   { background: transparent; }
.btn.icon    { width: 30px; padding: 0; text-align: center; }
.btn.sm      { height: 26px; padding: 0 8px; font-size: 12px; }
.btn.active  { background: var(--accent-s); border-color: var(--accent); color: #FFD37E; }
.btn[disabled] { opacity: .38; cursor: default; }
.btn .caret  { font-size: 10px; opacity: .8; margin-left: -1px; }

/* ---------- IconPark 图标（运行时注入的 svg symbol sprite） ---------- */
span[data-ic], svg.ic { width: 15px; height: 15px; flex: none; display: inline-block; }
span[data-ic] > svg  { width: 100%; height: 100%; display: block; }
.btn.sm span[data-ic], .btn.sm svg.ic { width: 13px; height: 13px; }
.btn.icon span[data-ic] { width: 16px; height: 16px; }

input[type="text"], input[type="number"], select {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  width: 100%;
}
input:focus, select:focus { border-color: var(--accent); }
input[type="color"] {
  width: 34px; height: 26px; padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--panel-2); cursor: pointer;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); }

/* 面板里的多行文本（文字图层内容） */
textarea.txt {
  width: 100%; min-height: 62px; resize: vertical;
  padding: 6px 8px; line-height: 1.55;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--panel-2); color: var(--text);
  font-family: inherit; font-size: 13px; outline: none;
}
textarea.txt:focus { border-color: var(--accent); }

/* 画布上的就地文字编辑器：位置/字号/颜色随图层实时同步 */
.text-editor {
  position: fixed; z-index: 900;
  margin: 0; padding: 0; border: 1px dashed var(--accent); border-radius: 2px;
  background: rgba(10, 12, 18, .28);
  color: #fff; outline: none; resize: none; overflow: hidden;
  white-space: pre; box-sizing: content-box;
  caret-color: var(--accent);
}

/* ---------------- 顶部工具栏 ---------------- */
.toolbar {
  height: var(--h-top);
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
  background: linear-gradient(180deg, #1A1A1D 0%, #121214 100%);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 15px; font-weight: 600; letter-spacing: .5px; color: #F5EFE3;
}
.brand .logo-ic { width: 20px; height: 20px; flex: none; color: var(--accent); }
.brand .logo-ic svg { width: 100%; height: 100%; display: block; }
.brand .sub {
  margin-left: 8px; font-size: 11px; font-weight: 400;
  color: var(--text-mute); letter-spacing: 0;
}
.tb-group { display: flex; gap: 6px; align-items: center; }
.tb-sep { width: 1px; height: 24px; background: var(--line); }
.tb-spacer { flex: 1; }
.zoom-label { min-width: 46px; text-align: center; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.export-wrap { position: relative; }

.menu {
  position: absolute; top: 34px; right: 0; z-index: 40;
  min-width: 210px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,.55);
  padding: 5px;
}
.menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  height: 30px; padding: 0 10px;
  background: transparent; border: 0; border-radius: var(--radius-s);
  color: var(--text); font-size: 13px; cursor: pointer;
}
.menu button span[data-ic] { width: 14px; height: 14px; color: var(--text-dim); }
.menu button:hover { background: var(--accent-s); color: #FFD37E; }
.menu-note { padding: 6px 10px 3px; font-size: 11px; color: var(--text-mute); }

/* ---------------- 主体三栏 ---------------- */
.workspace {
  height: calc(100vh - var(--h-top));
  display: grid;
  grid-template-columns: var(--w-left) 1fr var(--w-right);
}
.side-left, .side-right {
  background: var(--panel);
  display: flex; flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.side-left  { border-right: 1px solid var(--line); }
.side-right { border-left: 1px solid var(--line); }

.sec-head {
  padding: 10px 12px 8px;
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  letter-spacing: .4px;
  display: flex; justify-content: space-between; align-items: baseline;
}

/* 素材库 */
.library {
  flex: 0 0 auto; max-height: 34%;
  overflow-y: auto;
  padding: 0 8px 8px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.thumb {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--panel-2);
  overflow: hidden; cursor: pointer;
  padding-bottom: 16px;
}
.thumb:hover { border-color: #3A3A40; }
.thumb.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.thumb .pic {
  height: 54px; display: flex; align-items: center; justify-content: center;
  background:
    conic-gradient(#2E2E33 25%, #202023 0 50%, #2E2E33 0 75%, #202023 0) 0 0 / 12px 12px;
}
.thumb img { max-width: 100%; max-height: 54px; display: block; }
.thumb .nm {
  position: absolute; left: 0; right: 0; bottom: 0; height: 16px;
  font-size: 10px; line-height: 16px; color: var(--text-dim);
  background: rgba(8,14,24,.9);
  padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lib-empty { grid-column: 1 / -1; color: var(--text-mute); font-size: 12px; padding: 8px 4px; }

/* 图层列表 */
.layer-list { flex: 1 1 auto; overflow-y: auto; padding: 0 8px 8px; min-height: 60px; }
.layer-item {
  display: flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 6px;
  border: 1px solid transparent; border-radius: var(--radius-s);
  cursor: pointer; font-size: 12px;
}
.layer-item:hover { background: var(--panel-2); }
.layer-item.sel { background: var(--accent-s); border-color: var(--accent); color: #FFE3AD; }
.layer-item .ico { width: 16px; text-align: center; color: var(--text-dim); }
.layer-item .ico svg { width: 13px; height: 13px; display: inline-block; vertical-align: -2px; }
.layer-item.sel .ico { color: var(--accent); }
.layer-item .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-item .eye { width: 18px; text-align: center; color: var(--text-mute); font-size: 12px; }
.layer-item .eye:hover { color: var(--text); }
.layer-item.off .nm { opacity: .45; text-decoration: line-through; }

.side-actions {
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: 8px; border-top: 1px solid var(--line-soft);
}
.side-actions .btn { flex: 1 1 44%; }

/* ---------------- 画布区 ---------------- */
.stage-area { position: relative; background: #060607; overflow: hidden; }
.stage-scroll { position: absolute; inset: 0; }
/* 指针形态由 js/cursor.js 统一设置（不同工具/命中部位动态切换） */
#stage { display: block; width: 100%; height: 100%; cursor: default; touch-action: none; }

.empty-hint {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; pointer-events: none; color: var(--text-mute);
}
.eh-title { font-size: 16px; color: #6F6A61; }
.eh-sub { font-size: 12px; }
.dragover .stage-scroll::after {
  content: ""; position: absolute; inset: 10px;
  border: 2px dashed var(--accent); border-radius: 12px;
  background: rgba(61,139,255,.06);
}

.status-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 26px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 12px;
  background: rgba(9,15,26,.92);
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums;
}
.st-tip { color: var(--text-mute); }

/* ---------------- 右侧属性面板 ---------------- */
.panel-head {
  height: 38px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: #EFE9DC;
}
.panel-body { flex: 1; overflow-y: auto; padding: 10px 12px 24px; }

.sec {
  margin-bottom: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 10px;
}
.sec-t {
  font-size: 11px; color: var(--text-mute); letter-spacing: .5px;
  margin-bottom: 8px; text-transform: uppercase;
}
.field { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.field:last-child { margin-bottom: 0; }
.f-label { flex: 0 0 60px; font-size: 12px; color: var(--text-dim); }
.f-ctrl { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.f-ctrl .num { flex: 1; min-width: 0; }
.two { display: flex; gap: 6px; }
.two > * { flex: 1; min-width: 0; }

.swatches { display: flex; gap: 4px; flex-wrap: wrap; }
.sw {
  width: 18px; height: 18px; border-radius: 4px; cursor: pointer;
  border: 1px solid rgba(255,255,255,.18);
}
.sw.on { outline: 2px solid var(--accent); outline-offset: 1px; }

.seg { display: flex; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.seg button {
  flex: 1; height: 26px; border: 0; background: var(--panel-2);
  color: var(--text-dim); font-size: 12px; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-s); color: #FFD37E; }

.grid-align { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.grid-align button {
  height: 26px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--panel-2); color: var(--text-dim); cursor: pointer; font-size: 11px;
}
.grid-align button.on { background: var(--accent-s); border-color: var(--accent); color: #FFD37E; }

.hint-box {
  font-size: 12px; color: var(--text-dim); line-height: 1.6;
  background: var(--panel-2); border: 1px dashed var(--line);
  border-radius: var(--radius); padding: 8px 10px; margin-bottom: 12px;
}
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 46%; }

/* ---------------- 弹窗 / 提示 ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(3,6,12,.66);
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  width: 420px; max-width: 92vw;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.modal-body { padding: 12px; max-height: 60vh; overflow-y: auto; }
.modal-foot { padding: 10px 12px 12px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }
a.btn { text-decoration: none; }
table.kv { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.kv td { padding: 5px 4px; border-bottom: 1px solid var(--line-soft); }
table.kv td:first-child { color: var(--text-dim); width: 46%; }
table.kv td:last-child { color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%);
  z-index: 120; padding: 9px 16px;
  background: var(--panel-3); border: 1px solid var(--accent);
  border-radius: 20px; color: var(--text); font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #303036; border-radius: 6px; border: 2px solid var(--panel); }
::-webkit-scrollbar-thumb:hover { background: #3E3E45; }
