/* ============================================================
   纸张烫色模拟器 —— 界面样式
   主题变量集中在 :root，改这里即可整体换肤
   ============================================================ */

   :root {
    /* === 🟢 主题一：赛博科技（黑绿） === */
    --bg: #000000;            /* 页面底：极深的墨绿黑 */
    --panel: #000000;         /* 面板底：带一点绿 */
    --panel-2: #000000;       /* 卡片/输入底 */
    --line: #264035;          /* 分隔线：暗绿 */
    --text: #d1f2e3;          /* 主文字：冷白偏绿 */
    --text-dim: #6e9c83;      /* 次要文字：灰绿 */
    --accent: #00ff88;        /* 主题色：霓虹绿 */
    --accent-2: #6effb8;      /* 亮色：浅绿 */
    --danger: #ff5c5c;
    --radius: 10px;
    --shadow: 0 6px 24px rgba(0, 255, 136, 0.1);
    
    /* 额外变量 */
    --bg-viewport: #0d1612;   /* 3D视图区背景色 */
    --btn-grad-1: #00cc6a;    /* 按钮渐变1 */
    --btn-grad-2: #00994f;    /* 按钮渐变2 */
    --btn-text: #002b13;      /* 按钮文字颜色 */
  }
  
  /* === ⚪️ 主题二：极简明亮（白蓝）=== */
  [data-theme="light-blue"] {
    --bg: #f4f7fa;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --line: #d1d9e6;
    --text: #1e293b;
    --text-dim: #64748b;
    --accent: #3b82f6;
    --accent-2: #60a5fa;
    --danger: #ef4444;
    --radius: 12px;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
    
    --bg-viewport: #e2e8f0;
    --btn-grad-1: #3b82f6;
    --btn-grad-2: #2563eb;
    --btn-text: #ffffff;
  }
  
  /* ====== 修复：补全基础全局设定与高度，防止页面塌陷 ====== */
  * { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
  }
  
  html, body { 
    height: 100vh;        /* 撑满整个视口高度 */
    width: 100%; 
    overflow: hidden;     /* 禁止出现多余的滚动条 */
  }
  
  body {
    display: flex; 
    flex-direction: column; /* 纵向排列：顶栏在上，主体在下 */
    background: var(--bg); 
    color: var(--text);
    font: 14px/1.5 "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  }
  
  /* ---------- 顶栏 ---------- */
  #topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; background: var(--panel);
    border-bottom: 1px solid var(--line); flex: none;
  }
  .brand { display: flex; align-items: baseline; gap: 10px; }
  .brand .logo { color: var(--accent); font-size: 18px; }
  .brand b { font-size: 16px; letter-spacing: 1px; }
  .brand small { color: var(--text-dim); font-size: 12px; }
  .top-actions { display: flex; gap: 8px; }
  
  /* ---------- 主体布局 ---------- */
  #app { 
    flex: 1;               /* 关键：占满顶栏之下所有剩余高度 */
    display: flex; 
    min-height: 0; 
  }
  
  #panel {
    width: 340px; flex: none; background: var(--panel);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column; min-height: 0;
  }
  
  #tabs { display: flex; flex: none; border-bottom: 1px solid var(--line); }
  #tabs button {
    flex: 1; padding: 10px 0; background: none; border: none;
    color: var(--text-dim); font-size: 14px; cursor: pointer;
    border-bottom: 2px solid transparent;
  }
  #tabs button:hover { color: var(--text); }
  #tabs button.active { color: var(--accent-2); border-bottom-color: var(--accent); }
  
  .tab { display: none; padding: 14px 16px 30px; overflow-y: auto; }
  .tab.active { display: block; }
  .tab::-webkit-scrollbar { width: 8px; }
  .tab::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
  
  .tab h3 {
    font-size: 13px; color: var(--text-dim); font-weight: 600;
    margin: 18px 0 8px; letter-spacing: 1px;
  }
  .tab h3:first-child { margin-top: 2px; }
  
  #viewport { flex: 1; position: relative; min-width: 0; background: var(--bg-viewport); }
  #viewport canvas { display: block; }
  
  #view-hint {
    position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
    color: rgba(255, 255, 255, .38); font-size: 12px; pointer-events: none;
    white-space: nowrap;
  }
  #drop-hint {
    position: absolute; inset: 14px; border: 2px dashed var(--accent);
    border-radius: 14px; display: none; align-items: center; justify-content: center;
    background: rgba(23, 25, 29, .72); color: var(--accent-2); font-size: 16px;
    pointer-events: none; z-index: 5;
  }
  #viewport.dragging #drop-hint { display: flex; }
  
  /* ---------- 控件 ---------- */
  .btn {
    padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--line);
    background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 13px;
  }
  .btn:hover { border-color: var(--accent); color: var(--accent-2); }
  .btn.gold {
    background: linear-gradient(135deg, var(--btn-grad-1), var(--btn-grad-2));
    border: none; color: var(--btn-text); font-weight: 600;
  }
  .btn.gold:hover { filter: brightness(1.08); }
  .btn.subtle { background: none; color: var(--text-dim); }
  .btn.wide { width: 100%; padding: 9px; }
  .btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
  
  .field { margin: 10px 0; }
  .field > label { display: block; color: var(--text-dim); font-size: 12px; margin-bottom: 5px; }
  .field output { color: var(--accent-2); }
  .field.row { display: flex; align-items: center; justify-content: space-between; }
  .field.row > label { margin: 0; }
  
  input[type="range"] { width: 100%; accent-color: var(--accent); }
  input[type="color"] {
    width: 46px; height: 26px; padding: 0; border: 1px solid var(--line);
    border-radius: 6px; background: none; cursor: pointer;
  }
  select {
    width: 100%; padding: 7px 8px; border-radius: 8px;
    border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  }
  input[type="checkbox"] { accent-color: var(--accent); margin-right: 5px; vertical-align: -1px; }
  
  details { margin: 12px 0; color: var(--text-dim); font-size: 12px; }
  details summary { cursor: pointer; user-select: none; }
  details input[type="range"] { margin-top: 8px; }
  
  .hint { color: var(--text-dim); font-size: 12px; margin-top: 10px; line-height: 1.7; }
  .hint b { color: var(--accent-2); font-weight: 600; }
  .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  
  /* ---------- 预设按钮 ---------- */
  .preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .preset-grid button {
    padding: 9px 4px; border-radius: var(--radius); border: 1px solid var(--line);
    background: var(--panel-2); color: var(--text); font-size: 12px; cursor: pointer;
  }
  .preset-grid button:hover { border-color: var(--accent); }
  .preset-grid button.active {
    border-color: var(--accent); color: var(--accent-2);
    background: rgba(0, 255, 136, .12); /* 匹配绿色主题的激活背景 */
  }
  
  /* ---------- 烫色图层卡片 ---------- */
  .layer {
    display: flex; gap: 10px; padding: 10px; margin: 10px 0;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  }
  .layer.off { opacity: .45; }
  .layer .thumb {
    width: 52px; height: 52px; flex: none; object-fit: contain;
    background:
      repeating-conic-gradient(#2c3037 0 25%, #23262c 0 50%) 0 0 / 14px 14px;
    border: 1px solid var(--line); border-radius: 6px;
  }
  .layer-body { flex: 1; min-width: 0; }
  .layer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
  .layer-name {
    font-size: 13px; color: var(--text); overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
  }
  .layer-tools { display: flex; gap: 2px; flex: none; }
  .layer-tools .icon {
    width: 22px; height: 22px; border: none; border-radius: 6px;
    background: none; color: var(--text-dim); cursor: pointer; font-size: 10px;
  }
  .layer-tools .icon:hover { background: var(--line); color: var(--text); }
  .layer-tools .icon.danger:hover { color: var(--danger); }
  .layer .mini { display: block; color: var(--text-dim); font-size: 11px; margin: 6px 0 0; }
  .layer .mini input[type="range"] { display: inline-block; width: 105px; margin-left: 6px; vertical-align: middle; }
  .layer .mini.row { display: flex; align-items: center; }
  .layer select { margin-top: 6px; font-size: 12px; padding: 5px 6px; }
  
  /* ---------- 弹窗 / 提示 ---------- */
  .modal {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(10, 11, 13, .6); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
  }
  .modal.hidden { display: none; }
  .modal-card {
    width: 340px; padding: 18px; border-radius: 14px;
    background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  }
  .modal-card p { margin-bottom: 10px; color: var(--text-dim); font-size: 13px; }
  .modal-card #drop-modal-name { color: var(--accent-2); font-size: 13px; }
  
  #toast-box {
    position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
    z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center;
    pointer-events: none;
  }
  .toast {
    padding: 9px 18px; border-radius: 999px; font-size: 13px;
    background: rgba(38, 42, 49, .95); border: 1px solid var(--line);
    color: var(--text); box-shadow: var(--shadow);
    animation: toast-in .25s ease;
  }
  .toast.error { border-color: var(--danger); color: #ffb0a6; }
  .toast.out { opacity: 0; transition: opacity .3s; }
  @keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } }
  
  /* ---------- 小屏适配 ---------- */
  @media (max-width: 760px) {
    #panel { width: 280px; }
    .brand small { display: none; }
  }