/* 表情包工具 — sticker workbench */

:root{
  --bg: #E9EBF1;
  --bg-dot: rgba(20,19,26,.06);
  --card: #FFFFFF;
  --ink: #14131A;
  --ink-2: #57545F;
  --ink-3: #696674;
  --line: #DFE1E8;
  --line-strong: #C3C5CF;
  --inner: #F5F6FA;
  --yellow: #FFC93C;
  --meme: #FF4B36;
  --password: #2F5BFF;
  --invoice: #00A97A;
  --palette: #B14BF4;
  --stage: #17161D;
  --radius-lg: 22px;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-card: 0 1px 0 rgba(20,19,26,.04), 0 12px 34px -24px rgba(20,19,26,.5);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "Noto Serif CJK SC", "SimSun", Georgia, serif;
}

*,*::before,*::after{ box-sizing: border-box; }
html{ -webkit-text-size-adjust: 100%; }
body{
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body::before{
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--bg-dot) 1.1px, transparent 1.2px);
  background-size: 22px 22px;
}
button, input, textarea, select{ font: inherit; color: inherit; }
button{ -webkit-tap-highlight-color: transparent; }
svg{ display: block; }
:focus-visible{ outline: 2px solid var(--ink); outline-offset: 2px; }

#app{
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 26px 64px;
}

/* boot */
.boot{ min-height: 70vh; display: flex; align-items: center; justify-content: center; gap: 7px; }
.boot-dot{ width: 9px; height: 9px; border-radius: 50%; background: var(--ink); animation: boot .9s ease-in-out infinite; }
.boot-dot:nth-child(2){ animation-delay: .12s; background: var(--meme); }
.boot-dot:nth-child(3){ animation-delay: .24s; background: var(--password); }
@keyframes boot{ 0%,100%{ transform: translateY(0); opacity: .45 } 50%{ transform: translateY(-7px); opacity: 1 } }
.noscript{ padding: 40px; text-align: center; }

/* masthead */
.top{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 26px 0 22px;
}
.brand{ display: flex; align-items: center; gap: 13px; }
.brand-mark{
  width: 46px; height: 46px;
  border-radius: 14px;
  background: var(--ink);
  display: grid; place-items: center;
  transform: rotate(-6deg);
  box-shadow: 3px 3px 0 var(--yellow);
  transition: transform .28s cubic-bezier(.2,.7,.3,1);
}
.brand:hover .brand-mark{ transform: rotate(0deg); }
.brand-mark svg{ width: 27px; height: 27px; }
.brand-text strong{ display: block; font-size: 19px; font-weight: 900; letter-spacing: -.015em; line-height: 1.15; }
.brand-text small{ display: block; margin-top: 3px; font-size: 11.5px; letter-spacing: .03em; color: var(--ink-3); }
.privacy-pill{
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 12px; font-weight: 650;
  color: var(--ink-2);
  white-space: nowrap;
}
.privacy-pill svg{ width: 14px; height: 14px; color: var(--invoice); flex: 0 0 auto; }

/* tool tabs */
.tabs{
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 12px;
  margin: 4px 0 30px;
}
.tab{
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 13px 14px;
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: 16px;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.tab:hover{ transform: translate(-1px,-1px); box-shadow: 5px 5px 0 var(--ink); }
.tab[aria-selected="true"]{ background: var(--ink); color: #fff; box-shadow: 4px 4px 0 var(--accent); }
.tab-icon{
  flex: 0 0 auto; width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--inner); color: var(--ink);
  display: grid; place-items: center;
}
.tab-icon svg{ width: 20px; height: 20px; }
.tab[aria-selected="true"] .tab-icon{ background: var(--accent); color: #fff; }
.tab-copy{ min-width: 0; flex: 1; }
.tab-copy strong{ display: block; font-size: 14.5px; font-weight: 800; line-height: 1.25; }
.tab-copy small{ display: block; margin-top: 2px; font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab[aria-selected="true"] .tab-copy small{ color: rgba(255,255,255,.55); }
.tab-num{ align-self: flex-start; font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.tab[aria-selected="true"] .tab-num{ color: rgba(255,255,255,.45); }

/* panel + tool heading */
.panel[hidden]{ display: none; }
[hidden]{ display: none !important; }
.panel{ animation: rise .34s cubic-bezier(.2,.7,.3,1) both; }
@keyframes rise{ from{ opacity: 0; transform: translateY(10px) } to{ opacity: 1; transform: none } }

.tool-head{ display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 22px; }
.eyebrow{
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .13em;
  color: var(--ink-3); text-transform: uppercase;
}
.eyebrow::before{ content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); transform: rotate(45deg); }
.tool-head h1{ margin: 9px 0 0; font-size: clamp(28px, 3.5vw, 38px); font-weight: 900; letter-spacing: -.03em; line-height: 1.1; }
.squig{
  width: 148px; height: 9px; margin-top: 7px;
  background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 148 9'%3E%3Cpath d='M1.5 6.5C19 1.6 31 8 48.5 5.2s30-4 47-1.2 30 3.2 50-2.3' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 148 9'%3E%3Cpath d='M1.5 6.5C19 1.6 31 8 48.5 5.2s30-4 47-1.2 30 3.2 50-2.3' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.tool-head p{ max-width: 560px; margin: 11px 0 0; font-size: 14px; line-height: 1.7; color: var(--ink-2); }

.card{ background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }

/* generic controls */
.btn{
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 15px;
  border: 1.5px solid var(--ink);
  border-radius: 11px;
  background: #fff; color: var(--ink);
  font-size: 13px; font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .14s, box-shadow .14s, background .14s, border-color .14s;
}
.btn svg{ width: 16px; height: 16px; }
.btn:hover{ transform: translate(-1px,-1px); }
.btn:active{ transform: translate(1px,1px); }
.btn-primary{ background: var(--ink); color: #fff; box-shadow: 3px 3px 0 var(--accent); }
.btn-primary:hover{ box-shadow: 5px 5px 0 var(--accent); }
.btn-primary:active{ box-shadow: 1px 1px 0 var(--accent); }
.btn-ghost{ border-color: var(--line-strong); background: transparent; color: var(--ink-2); }
.btn-ghost:hover{ border-color: var(--ink); color: var(--ink); }
.btn-danger{ background: #fff; border-color: #E5B4AC; color: #B72516; }
.btn-danger:hover{ background: #FFF4F2; }
.btn-sm{ height: 32px; padding: 0 10px; border-radius: 9px; font-size: 12px; }
.btn-block{ width: 100%; }
.btn:disabled{ opacity: .45; pointer-events: none; }

.group + .group{ margin-top: 20px; padding-top: 20px; border-top: 1px dashed var(--line); }
.group-title{
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 12px;
  font-size: 12px; font-weight: 800; letter-spacing: .04em; color: var(--ink-2);
}
.group-title .gt{ display: inline-flex; align-items: center; gap: 7px; }
.group-title .gt::before{ content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--accent); }
.group-link{
  display: inline-flex; align-items: center; min-height: 24px;
  border: 0; background: none; padding: 2px 0; cursor: pointer;
  font-size: 11.5px; font-weight: 700; color: var(--ink-3);
  text-decoration: underline; text-underline-offset: 3px;
}
.group-link:hover{ color: var(--ink); }

.seg{ display: flex; gap: 2px; background: var(--inner); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button{
  flex: 1; border: 0; background: transparent; border-radius: 7px;
  padding: 6px 4px; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--ink-3);
  white-space: nowrap;
}
.seg button[aria-pressed="true"]{ background: #fff; color: var(--ink); font-weight: 800; box-shadow: 0 1px 2px rgba(20,19,26,.14); }

.field{ min-width: 0; }
.field-label{
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 6px;
  font-size: 11.5px; font-weight: 700; color: var(--ink-2);
}
.field-label .val{ font-family: var(--mono); font-size: 11px; color: var(--ink-3); font-weight: 500; }
.input, textarea.input, select.input{
  width: 100%; height: 38px;
  border: 1.5px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  padding: 0 10px;
  font-size: 13px; color: var(--ink);
  min-width: 0;
}
textarea.input{ height: auto; padding: 9px 11px; resize: vertical; line-height: 1.55; }
.input:focus, textarea.input:focus, select.input:focus{
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(20,19,26,.08);
}
.input::placeholder, textarea.input::placeholder{ color: #A9A7B1; }
select.input{ appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
input[type="range"]{ width: 100%; accent-color: var(--accent); height: 26px; cursor: pointer; }
.range-row{ display: flex; align-items: center; gap: 10px; }
.range-row input[type="range"]{ flex: 1; }
.range-val{ font-family: var(--mono); font-size: 11px; color: var(--ink-2); min-width: 42px; text-align: right; }

.pair{ display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pair-3{ display: grid; grid-template-columns: 1.2fr .8fr; gap: 8px; }

/* meme editor */
.editor{ display: grid; grid-template-columns: 372px minmax(0,1fr); gap: 20px; align-items: start; }
.controls{ padding: 20px; }
.stage-wrap{ position: sticky; top: 18px; }

.tpl-grid{ display: grid; grid-template-columns: repeat(4,1fr); gap: 7px; }
.tpl{
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 3px; border: 1.5px solid transparent; border-radius: 11px;
  background: transparent; color: var(--ink-2); cursor: pointer;
  min-width: 0;
}
.tpl canvas{ width: 100%; height: auto; aspect-ratio: 1; display: block; border-radius: 8px; border: 1px solid rgba(20,19,26,.14); }
.tpl span{ width: 100%; font-size: 10.5px; line-height: 1.2; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl:hover{ background: var(--inner); border-color: var(--line-strong); }
.tpl[aria-pressed="true"]{ border-color: var(--ink); background: var(--inner); box-shadow: 2px 2px 0 var(--ink); color: var(--ink); font-weight: 700; }

.upload{
  display: flex; align-items: center; gap: 11px;
  margin-top: 10px; padding: 11px;
  border: 1.5px dashed var(--line-strong); border-radius: 12px;
  background: var(--inner);
}
.upload.has-image{ border-style: solid; border-color: var(--line-strong); background: #fff; }
.upload-thumb{ width: 46px; height: 46px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); flex: 0 0 auto; }
.upload-ico{ width: 40px; height: 40px; border-radius: 9px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; color: var(--ink-3); flex: 0 0 auto; }
.upload-ico svg{ width: 18px; height: 18px; }
.upload-copy{ flex: 1; min-width: 0; font-size: 11.5px; line-height: 1.5; color: var(--ink-3); }
.upload-copy strong{ display: block; font-size: 12px; color: var(--ink); font-weight: 700; margin-bottom: 1px; }
.upload .btn{ flex: 0 0 auto; }
.file-input{ display: none; }

.chips{ display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 11px; }
.chip{
  max-width: 138px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink-2);
  font-size: 11.5px; cursor: pointer;
}
.chip[aria-pressed="true"]{ background: var(--ink); border-color: var(--ink); color: #fff; }
.chip-add{ border-style: dashed; color: var(--ink-3); background: transparent; }
.chip-add:hover{ border-color: var(--ink); color: var(--ink); }

.text-editor{ display: grid; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--inner); }
.swatches{ display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.swatch{
  width: 24px; height: 24px; padding: 0; border-radius: 50%;
  border: 1.5px solid rgba(20,19,26,.18); background: var(--sw); cursor: pointer;
}
.swatch[aria-pressed="true"]{ box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.color-pick{
  position: relative; width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px dashed var(--line-strong); display: grid; place-items: center;
  overflow: hidden; color: var(--ink-3);
}
.color-pick input{ position: absolute; inset: -8px; width: 44px; height: 44px; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.color-pick svg{ width: 12px; height: 12px; }

.toggle-row{ display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 28px; }
.toggle-label{ font-size: 12px; color: var(--ink-2); font-weight: 600; }
.switch{ position: relative; display: inline-flex; flex: 0 0 auto; }
.switch input{ position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 2; width: 100%; height: 100%; }
.switch i{
  width: 38px; height: 22px; border-radius: 999px;
  background: #D6D8E0; border: 1px solid rgba(20,19,26,.14);
  position: relative; transition: background .18s;
}
.switch i::after{
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25);
  transition: transform .18s;
}
.switch input:checked + i{ background: var(--accent); border-color: transparent; }
.switch input:checked + i::after{ transform: translateX(16px); }
.switch input:focus-visible + i{ outline: 2px solid var(--ink); outline-offset: 2px; }

.stage{
  position: relative; overflow: hidden;
  padding: 18px;
  background: var(--stage);
  border-radius: var(--radius-lg);
  box-shadow: 0 26px 56px -34px rgba(20,19,26,.85);
}
.stage::before{
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.10) 1px, transparent 1.2px);
  background-size: 18px 18px; opacity: .55;
}
.stage-top{ position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.stage-seg{ display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.15); }
.stage-seg button{
  border: 0; background: transparent; border-radius: 6px;
  padding: 5px 10px; cursor: pointer;
  font-size: 11px; font-weight: 700; color: rgba(255,255,255,.55);
}
.stage-seg button[aria-pressed="true"]{ background: #fff; color: var(--ink); }
.stage-dims{ font-family: var(--mono); font-size: 10.5px; letter-spacing: .07em; color: rgba(255,255,255,.45); }
.canvas-area{ position: relative; display: flex; justify-content: center; min-height: 200px; }
.canvas-holder{ position: relative; display: inline-block; max-width: 100%; }
.canvas-holder canvas{ display: block; width: 100%; height: auto; border-radius: 3px; box-shadow: 0 18px 50px rgba(0,0,0,.55); touch-action: none; cursor: move; }
.crop{ position: absolute; width: 11px; height: 11px; border: 2px solid rgba(255,255,255,.5); pointer-events: none; }
.crop.tl{ top: -7px; left: -7px; border-right: 0; border-bottom: 0; }
.crop.tr{ top: -7px; right: -7px; border-left: 0; border-bottom: 0; }
.crop.bl{ bottom: -7px; left: -7px; border-right: 0; border-top: 0; }
.crop.br{ bottom: -7px; right: -7px; border-left: 0; border-top: 0; }
.stage-foot{ position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.stage-hint{ display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: rgba(255,255,255,.5); }
.stage-hint svg{ width: 13px; height: 13px; }
.stage-actions{ display: flex; gap: 8px; flex-wrap: wrap; }
.btn-on-dark{ background: #fff; border-color: #fff; color: var(--ink); box-shadow: 3px 3px 0 var(--accent); }
.btn-on-dark:hover{ box-shadow: 5px 5px 0 var(--accent); }
.btn-outline-dark{ background: transparent; border-color: rgba(255,255,255,.3); color: #fff; }
.btn-outline-dark:hover{ background: rgba(255,255,255,.08); border-color: #fff; }
.stage .btn:focus-visible{ outline-color: #fff; }

/* password */
.pass-grid{ display: grid; grid-template-columns: minmax(0,1.12fr) minmax(0,.88fr); gap: 20px; align-items: start; }
.pass-card{
  position: relative; overflow: hidden;
  display: flex; flex-direction: column;
  min-height: 300px; padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--ink); color: #fff;
  box-shadow: 0 26px 56px -36px rgba(20,19,26,.95);
}
.pass-glow{ position: absolute; top: -120px; right: -100px; width: 320px; height: 320px; border-radius: 50%; background: var(--password); filter: blur(90px); opacity: .38; pointer-events: none; }
.pass-top{ position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pass-label{ font-family: var(--mono); font-size: 10.5px; letter-spacing: .15em; text-transform: uppercase; color: rgba(255,255,255,.45); }
.pass-tools{ display: flex; align-items: center; gap: 7px; }
.icon-btn{
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.07); color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover{ background: rgba(255,255,255,.15); }
.icon-btn svg{ width: 16px; height: 16px; }
.pass-value{
  position: relative; margin: 30px 0 30px;
  font-family: var(--mono); font-size: clamp(21px, 2.9vw, 30px); font-weight: 600;
  line-height: 1.5; letter-spacing: .03em; word-break: break-all;
}
.pass-value.is-phrase{ font-family: var(--sans); font-size: clamp(19px, 2.5vw, 26px); letter-spacing: .04em; }
.pass-value.empty{ color: rgba(255,255,255,.35); font-family: var(--sans); font-size: 16px; }
.pass-bottom{ position: relative; margin-top: auto; }
.pass-meter{ height: 6px; border-radius: 999px; background: rgba(255,255,255,.13); overflow: hidden; }
.pass-meter i{ display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--password), #8EA8FF); transition: width .4s cubic-bezier(.2,.7,.3,1); }
.pass-meta{ display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 11.5px; color: rgba(255,255,255,.55); flex-wrap: wrap; }
.pass-meta strong{ color: #fff; font-weight: 700; }
.pass-note{ position: relative; display: flex; align-items: flex-start; gap: 7px; margin-top: 18px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.1); font-size: 11px; line-height: 1.6; color: rgba(255,255,255,.62); }
.pass-note svg{ width: 13px; height: 13px; flex: 0 0 auto; margin-top: 2px; }

.options{ padding: 20px; display: grid; gap: 16px; }
.opt-block{ display: grid; gap: 9px; }
.opt-title{ font-size: 12px; font-weight: 800; color: var(--ink-2); letter-spacing: .03em; }
.opt-list{ display: grid; gap: 7px; }
.opt-line{ display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.opt-line span{ font-size: 12.5px; color: var(--ink-2); }
.opt-hint{ font-size: 11px; color: var(--ink-3); line-height: 1.55; }

/* invoice */
.invoice-grid{ display: grid; grid-template-columns: 402px minmax(0,1fr); gap: 20px; align-items: start; }
.invoice-form{ padding: 20px; display: grid; gap: 16px; }
.form-section{ display: grid; gap: 10px; }
.form-section + .form-section{ padding-top: 15px; border-top: 1px dashed var(--line); }
.form-sub{ font-size: 11.5px; font-weight: 800; color: var(--ink-2); letter-spacing: .03em; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.form-sub .mini{ font-size: 10.5px; color: var(--ink-3); font-weight: 500; }
.item-head, .item-row{ display: grid; grid-template-columns: minmax(0,1fr) 56px 88px 30px; gap: 6px; align-items: center; }
.item-head{ font-size: 10px; color: var(--ink-3); letter-spacing: .05em; padding: 0 2px; }
.item-row input{
  width: 100%; height: 36px; min-width: 0;
  border: 1.5px solid var(--line-strong); border-radius: 8px;
  padding: 0 8px; font-size: 12.5px; background: #fff;
}
.item-row input:focus{ outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(20,19,26,.08); }
.item-del{
  width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent;
  color: var(--ink-3); display: grid; place-items: center; cursor: pointer;
}
.item-del:hover{ background: #FFF0ED; color: #B72516; }
.item-del:disabled{ opacity: .3; cursor: not-allowed; }
.item-del svg{ width: 15px; height: 15px; }
.invoice-actions{ display: flex; gap: 8px; flex-wrap: wrap; }
.invoice-actions .btn-primary{ flex: 1 1 auto; }
.print-hint{ font-size: 10.5px; color: var(--ink-3); line-height: 1.55; }

.paper-wrap{ position: relative; }
.paper{
  max-width: 780px; margin: 0 auto;
  padding: clamp(22px, 4vw, 44px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 34px 70px -44px rgba(20,19,26,.6);
  font-variant-numeric: tabular-nums;
}
.paper-head{ display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 2px solid var(--ink); }
.paper-title{ font-family: var(--serif); font-size: clamp(26px, 3.4vw, 32px); font-weight: 700; letter-spacing: .2em; line-height: 1; }
.paper-sub{ margin-top: 8px; font-family: var(--mono); font-size: 9px; letter-spacing: .34em; color: var(--ink-3); }
.paper-meta{ text-align: right; font-size: 11px; line-height: 1.95; color: var(--ink-2); white-space: nowrap; }
.paper-meta b{ font-family: var(--mono); font-weight: 600; color: var(--ink); letter-spacing: .02em; }
.parties{ display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 18px 0 16px; border-bottom: 1px dashed var(--line); }
.party-label{ margin-bottom: 5px; font-size: 9.5px; letter-spacing: .13em; color: var(--ink-3); }
.party-name{ min-height: 19px; font-size: 13.5px; font-weight: 700; line-height: 1.4; }
.party-tax{ margin-top: 3px; font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.paper-table{ width: 100%; border-collapse: collapse; font-size: 12px; }
.paper-table th{ padding: 12px 6px 9px; border-bottom: 1px solid var(--line); font-size: 9.5px; font-weight: 600; letter-spacing: .1em; text-align: left; color: var(--ink-3); }
.paper-table td{ padding: 11px 6px; border-bottom: 1px solid #EFF0F4; vertical-align: top; line-height: 1.5; }
.paper-table .num{ text-align: right; font-family: var(--mono); white-space: nowrap; }
.paper-table .idx{ width: 26px; color: var(--ink-3); font-family: var(--mono); font-size: 10px; }
.totals{ width: min(310px, 100%); margin: 15px 0 0 auto; font-size: 12px; }
.total-row{ display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; color: var(--ink-2); }
.total-row b{ font-family: var(--mono); font-weight: 600; color: var(--ink); }
.grand{ display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 8px; padding-top: 10px; border-top: 2px solid var(--ink); font-size: 13.5px; font-weight: 800; }
.grand b{ font-family: var(--mono); font-size: 19px; letter-spacing: .01em; }
.upper{ margin-top: 15px; padding: 9px 12px; border-radius: 8px; background: var(--inner); font-size: 10.5px; line-height: 1.6; color: var(--ink-2); }
.upper b{ font-weight: 700; color: var(--ink); }
.paper-note{ margin-top: 14px; font-size: 11px; line-height: 1.65; color: var(--ink-2); }
.paper-disclaimer{ margin-top: 18px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 9.5px; line-height: 1.7; color: var(--ink-3); }
.paper-empty td{ color: var(--ink-3); }

/* palette */
.pal-controls{ display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 15px 17px; margin-bottom: 16px; }
.base-color{ display: flex; align-items: center; gap: 9px; }
.base-swatch{
  position: relative; width: 40px; height: 40px; border-radius: 12px; overflow: hidden;
  border: 1.5px solid var(--ink); background: var(--base); box-shadow: 2px 2px 0 var(--ink);
}
.base-swatch input{ position: absolute; inset: -10px; width: 60px; height: 60px; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.base-meta{ display: grid; gap: 1px; }
.base-meta span{ font-size: 10px; color: var(--ink-3); letter-spacing: .06em; }
.base-meta b{ font-family: var(--mono); font-size: 12.5px; font-weight: 600; letter-spacing: .04em; }
.pal-mode{ min-width: 250px; flex: 1 1 250px; max-width: 380px; }
.pal-actions{ display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.pal-hint{ display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--ink-3); }
.sr-only{ position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.kbd{
  font-family: var(--mono); font-size: 9.5px; padding: 2px 6px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px;
  background: #fff; color: var(--ink-2);
}

.swatches-row{ display: grid; grid-template-columns: repeat(5,1fr); gap: 10px; margin-bottom: 26px; }
.swatch-tile{
  position: relative; display: flex; flex-direction: column; justify-content: space-between;
  min-height: 264px; padding: 14px;
  border-radius: 16px; border: 1px solid rgba(20,19,26,.12);
  cursor: pointer; text-align: left;
  transition: transform .18s cubic-bezier(.2,.7,.3,1), box-shadow .18s;
  overflow: hidden; isolation: isolate;
}
.swatch-tile:hover{ transform: translateY(-5px); box-shadow: 0 20px 34px -20px rgba(20,19,26,.55); }
.swatch-tile:active{ transform: translateY(-2px); }
.swatch-top{ display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.swatch-index{ font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em; opacity: .55; }
.lock{
  position: relative; z-index: 2;
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  border: 1px solid currentColor; background: rgba(255,255,255,.18); color: inherit;
  opacity: .65; cursor: pointer; padding: 0;
}
.lock:hover{ opacity: 1; }
.lock[aria-pressed="true"]{ opacity: 1; background: rgba(255,255,255,.92); color: #14131A; }
.lock svg{ width: 13px; height: 13px; }
.swatch-bottom{ display: grid; gap: 2px; }
.swatch-hex{ font-family: var(--mono); font-size: 13px; font-weight: 600; letter-spacing: .05em; }
.swatch-rgb{ font-family: var(--mono); font-size: 9.5px; opacity: .65; letter-spacing: .02em; }
.swatch-copy{ font-size: 9.5px; opacity: .55; margin-top: 5px; }

.saved-section{ margin-top: 6px; }
.saved-head{ display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.saved-head h2{ margin: 0; font-size: 14px; font-weight: 800; letter-spacing: .02em; }
.saved-head span{ font-size: 11px; color: var(--ink-3); }
.saved-grid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(190px,1fr)); gap: 12px; }
.saved-card{ background: #fff; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; box-shadow: var(--shadow-card); }
.saved-stripes{ display: flex; height: 54px; cursor: pointer; }
.saved-stripes i{ flex: 1; }
.saved-stripes:hover{ filter: saturate(1.1) brightness(1.03); }
.saved-foot{ display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 11px; font-size: 10.5px; color: var(--ink-3); }
.saved-del{ width: 28px; height: 28px; border: 0; background: none; padding: 0; cursor: pointer; color: var(--ink-3); display: grid; place-items: center; border-radius: 6px; }
.saved-del:hover{ color: #B72516; background: #FFF0ED; }
.saved-del svg{ width: 14px; height: 14px; }
.saved-empty{
  grid-column: 1 / -1;
  padding: 22px; border: 1.5px dashed var(--line-strong); border-radius: 13px;
  text-align: center; font-size: 12px; color: var(--ink-3); line-height: 1.7;
}

/* footer + toast */
.foot{
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin-top: 52px; padding-top: 20px;
  border-top: 1px dashed var(--line-strong);
  font-size: 11.5px; color: var(--ink-3);
}
.foot-note{ display: flex; align-items: center; gap: 7px; margin: 0; line-height: 1.6; }
.foot-note svg{ width: 14px; height: 14px; color: var(--invoice); flex: 0 0 auto; }
.foot-right{ display: flex; align-items: center; gap: 11px; }
.foot-sep{ width: 3px; height: 3px; border-radius: 50%; background: var(--line-strong); }
.link-btn{ display: inline-flex; align-items: center; min-height: 24px; border: 0; background: none; padding: 0; font-size: inherit; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn:hover{ color: #B72516; }

.toast{
  position: fixed; left: 50%; bottom: 26px; z-index: 60;
  padding: 10px 18px; border-radius: 999px;
  background: var(--ink); color: #fff;
  font-size: 12.5px; font-weight: 600; text-align: center;
  max-width: calc(100vw - 40px);
  box-shadow: 0 12px 32px rgba(0,0,0,.28);
  opacity: 0; transform: translate(-50%, 18px); pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show{ opacity: 1; transform: translate(-50%, 0); }

/* responsive */
@media (max-width: 1080px){
  .tabs{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  .editor{ grid-template-columns: 336px minmax(0,1fr); }
  .invoice-grid{ grid-template-columns: 360px minmax(0,1fr); }
  .swatches-row{ gap: 8px; }
  .swatch-tile{ min-height: 230px; padding: 12px; }
}
@media (max-width: 980px){
  .editor, .pass-grid, .invoice-grid{ grid-template-columns: 1fr; }
  .stage-wrap{ position: static; order: -1; }
  .pass-card{ min-height: 250px; }
  .paper-wrap{ margin-top: 4px; }
}
@media (max-width: 680px){
  #app{ padding: 0 16px 44px; }
  .top{ padding: 18px 0 16px; }
  .brand-mark{ width: 42px; height: 42px; border-radius: 12px; }
  .brand-text strong{ font-size: 17px; }
  .brand-text small{ font-size: 10.5px; }
  .privacy-pill{ padding: 7px 11px; font-size: 10.5px; gap: 6px; }
  .privacy-pill svg{ width: 12px; height: 12px; }
  .tabs{ gap: 8px; margin-bottom: 24px; }
  .tab{ padding: 10px; gap: 8px; border-radius: 13px; box-shadow: 2px 2px 0 var(--ink); }
  .tab:hover{ transform: none; box-shadow: 2px 2px 0 var(--ink); }
  .tab[aria-selected="true"]{ box-shadow: 3px 3px 0 var(--accent); }
  .tab-icon{ width: 32px; height: 32px; border-radius: 9px; }
  .tab-icon svg{ width: 17px; height: 17px; }
  .tab-copy strong{ font-size: 12.5px; }
  .tab-copy small{ display: none; }
  .tab-num{ display: none; }
  .tool-head{ gap: 14px; margin-bottom: 18px; }
  .tool-head h1{ font-size: 27px; }
  .tool-head p{ font-size: 13px; }
  .squig{ width: 120px; }
  .controls, .options, .invoice-form{ padding: 16px; }
  .stage{ padding: 12px; border-radius: 18px; }
  .stage-top{ margin-bottom: 10px; }
  .stage-actions{ width: 100%; }
  .stage-actions .btn{ flex: 1; }
  .stage-hint{ width: 100%; }
  .pass-card{ padding: 18px; border-radius: 18px; }
  .pass-value{ margin: 22px 0 26px; }
  .swatches-row{ grid-template-columns: repeat(5,1fr); gap: 5px; margin-bottom: 20px; }
  .swatch-tile{ min-height: 158px; padding: 8px 8px 10px; border-radius: 12px; }
  .swatch-tile:hover{ transform: none; }
  .swatch-hex{ font-size: 10px; letter-spacing: 0; }
  .swatch-rgb{ display: none; }
  .swatch-copy{ display: none; }
  .swatch-index{ font-size: 8px; }
  .lock{ width: 24px; height: 24px; border-radius: 6px; }
  .lock svg{ width: 11px; height: 11px; }
  .pal-controls{ padding: 13px; gap: 11px; }
  .pal-actions{ width: 100%; margin-left: 0; }
  .pal-actions .btn{ flex: 1; }
  .pal-mode{ max-width: none; }
  .pal-hint{ display: none; }
  .paper{ padding: 18px 14px; border-radius: 12px; }
  .paper-title{ font-size: 24px; }
  .paper-meta{ font-size: 9.5px; }
  .paper-table th, .paper-table td{ padding: 9px 4px; }
  .paper-table .hide-sm{ display: none; }
  .item-head, .item-row{ grid-template-columns: minmax(0,1fr) 48px 76px 28px; gap: 5px; }
  .foot{ margin-top: 36px; font-size: 10.5px; }
  .foot-right{ width: 100%; justify-content: space-between; }
  .toast{ bottom: 16px; font-size: 12px; }
}
@media (max-width: 420px){
  .pair{ grid-template-columns: 1fr; }
  .tpl-grid{ grid-template-columns: repeat(4,1fr); gap: 5px; }
  .tpl span{ font-size: 9.5px; }
  .swatch-hex{ font-size: 10px; }
  .swatches-row{ gap: 4px; }
  .swatch-tile{ min-height: 142px; padding: 7px; }
  .stage-dims{ font-size: 9px; }
}

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{ animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* print: only the invoice paper */
@media print{
  body{ background: #fff; }
  body::before{ display: none; }
  #app{ max-width: none; padding: 0; }
  body *{ visibility: hidden !important; }
  #invoice-paper, #invoice-paper *{ visibility: visible !important; }
  #invoice-paper{
    position: absolute; left: 0; top: 0;
    width: 100%; max-width: none; margin: 0;
    padding: 0; border: 0; border-radius: 0; box-shadow: none;
  }
  @page{ size: A4; margin: 14mm; }
}
