:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e4e9;
  --border2: #d0d3db;
  --accent: #4f6ef7;
  --text: #1a1d23;
  --text-muted: #8b90a0;
  --danger: #e5484d;
  --green: #22c55e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-box {
  width: 22px; height: 22px;
  background: var(--accent);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}

.hdr-btns { display: flex; gap: 6px; }

.btn {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: white;
  color: var(--text-muted);
  transition: all 0.12s;
}

.btn:hover { color: var(--text); border-color: var(--border2); }
.btn-accent { background: var(--accent); color: white; border-color: transparent; }
.btn-accent:hover { background: #3d5ce4; color: white; }

.main { display: flex; flex: 1; overflow: hidden; }

/* SIDEBAR */
.sidebar {
  width: 210px;
  background: white;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sb-block { padding: 14px; border-bottom: 1px solid var(--border); }

.sb-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
}

.form-col { display: flex; flex-direction: column; gap: 7px; }

.inp {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  padding: 7px 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color 0.12s;
}

.inp:focus { border-color: var(--accent); background: white; }
.inp::placeholder { color: var(--text-muted); }

.swatches { display: flex; gap: 5px; flex-wrap: wrap; }

.sw {
  width: 16px; height: 16px;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s;
}

.sw:hover { transform: scale(1.15); }
.sw.on { border-color: #1a1d23; }

.page-list { flex: 1; overflow-y: auto; padding: 8px; }
.page-list::-webkit-scrollbar { width: 3px; }
.page-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.prow {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 8px; border-radius: 5px; cursor: pointer;
  transition: background 0.1s; margin-bottom: 2px;
}

.prow:hover { background: var(--bg); }

.pdot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.pname { font-size: 12px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pdel {
  opacity: 0; background: none; border: none; cursor: pointer;
  color: var(--danger); font-size: 15px; line-height: 1; padding: 0 2px;
  transition: opacity 0.1s;
}

.prow:hover .pdel { opacity: 1; }

/* CANVAS */
.canvas-wrap {
  flex: 1; position: relative; overflow: hidden;
  background: var(--bg);
  background-image: radial-gradient(circle, #d0d3db 1px, transparent 1px);
  background-size: 22px 22px;
}

#c { position: absolute; top: 0; left: 0; }

/* MODE BAR */
.modebar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; background: white; border: 1px solid var(--border);
  border-radius: 8px; padding: 3px; gap: 2px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08); z-index: 10;
}

.mbtn {
  font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 500;
  padding: 5px 12px; border-radius: 5px; border: none;
  background: transparent; color: var(--text-muted); cursor: pointer;
  transition: all 0.12s;
}

.mbtn:hover { color: var(--text); }
.mbtn.on { background: var(--accent); color: white; }

/* LINK STEP BANNER */
.link-banner {
  position: absolute; top: 54px; left: 50%; transform: translateX(-50%);
  font-size: 12px; font-weight: 500;
  padding: 5px 14px; border-radius: 20px; display: none; pointer-events: none;
  white-space: nowrap;
}

.link-banner.on { display: flex; align-items: center; gap: 8px; }

.link-banner.step1 {
  background: rgba(79,110,247,0.1);
  border: 1px solid rgba(79,110,247,0.3);
  color: var(--accent);
}

.link-banner.step2 {
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.35);
  color: #16a34a;
}

.banner-src {
  background: var(--accent);
  color: white;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ZOOM */
.zoombar {
  position: absolute; bottom: 14px; right: 14px;
  display: flex; align-items: center; gap: 2px;
  background: white; border: 1px solid var(--border); border-radius: 7px; padding: 3px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.zbtn {
  width: 26px; height: 26px; background: none; border: none; cursor: pointer;
  border-radius: 4px; font-size: 15px; color: var(--text-muted); transition: all 0.1s;
  display: flex; align-items: center; justify-content: center;
}

.zbtn:hover { background: var(--bg); color: var(--text); }
.zlabel { font-size: 11px; color: var(--text-muted); padding: 0 4px; min-width: 38px; text-align: center; }

/* EMPTY */
.empty {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  text-align: center; pointer-events: none;
}

.empty-icon { font-size: 32px; margin-bottom: 8px; opacity: 0.2; }
.empty-text { font-size: 13px; color: var(--text-muted); line-height: 1.7; }

/* CTX */
.ctx {
  position: fixed; background: white; border: 1px solid var(--border);
  border-radius: 8px; padding: 4px; z-index: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1); display: none; min-width: 148px;
}

.ctx.on { display: block; }

.ci {
  padding: 7px 10px; font-size: 12px; cursor: pointer;
  border-radius: 5px; transition: background 0.1s;
  display: flex; align-items: center; gap: 7px;
}

.ci:hover { background: var(--bg); }
.ci.danger { color: var(--danger); }
.csep { height: 1px; background: var(--border); margin: 3px 0; }

/* MODAL */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.22);
  z-index: 300; display: none; align-items: center; justify-content: center;
}

.overlay.on { display: flex; }

.modal {
  background: white; border: 1px solid var(--border); border-radius: 10px;
  padding: 20px; width: 300px; box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

.modal-title { font-size: 14px; font-weight: 600; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 7px; justify-content: flex-end; margin-top: 14px; }

/* LINK DELETE TOOLTIP */
.link-tooltip {
  position: fixed;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  color: var(--danger);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  pointer-events: none;
  display: none;
  gap: 5px;
  align-items: center;
  z-index: 200;
  font-weight: 500;
}

.link-tooltip.on { display: flex; }

/* EXPORT DIALOG */
.export-opts {
  display: flex;
  gap: 12px;
  margin: 8px 0 16px;
}

.export-opt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: white;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.export-opt:hover {
  border-color: var(--accent);
  background: #f5f7ff;
}

.export-opt-icon { font-size: 28px; line-height: 1; }
.export-opt-label { font-size: 15px; font-weight: 600; color: var(--text); }
.export-opt-desc { font-size: 11px; color: var(--text-muted); }

.export-progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 6px;
}

#export-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.1s linear;
}

#export-progress-label {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 4px;
}

#export-overlay .export-opts { display: flex; }
#export-overlay .export-opts.hidden { display: none; }
