/* Signature Studio — app styling (light theme, matches the Custom Esignature look) */

:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --line: #e7eaf1;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --blue: #2f7df6;
  --blue-soft: #eaf2ff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
button { font: inherit; cursor: pointer; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 15px; margin: 0; }

#app { display: flex; height: 100vh; overflow: hidden; }

/* ============ sidebar ============ */
#sidebar {
  width: 200px; flex: 0 0 200px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 2px 8px 20px; }
.brand-mark { font-size: 24px; }
.brand-name { font-weight: 800; font-size: 13px; letter-spacing: .12em; line-height: 1.25; }
.brand-name small { font-weight: 500; font-size: 8.5px; letter-spacing: .34em; color: var(--ink-3); }

#tabs { display: flex; flex-direction: column; gap: 4px; }
.tab {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid transparent; border-radius: 10px;
  background: none; color: var(--ink-2); text-align: left; font-weight: 500;
}
.tab:hover { background: #f7f9fd; }
.tab.active { background: var(--blue-soft); border-color: #cfe1ff; color: var(--blue); font-weight: 600; }

.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.foot-label { font-size: 11px; color: var(--ink-3); margin-bottom: 6px; padding-left: 2px; }
#sigSelect { width: 100%; }
.sig-actions { display: flex; gap: 4px; margin-top: 8px; }
.sig-actions button {
  flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 5px 0; font-size: 13px; color: var(--ink-2);
}
.sig-actions button:hover { background: #f7f9fd; }

/* ============ control panel ============ */
#panel {
  width: 440px; flex: 0 0 440px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: hidden;
}
#panelInner { height: 100%; overflow-y: auto; padding: 22px 24px 60px; }

.panel-title { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.sec-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; }
.sec-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 9px;
  background: var(--blue-soft); color: var(--blue); flex: 0 0 auto;
}
.sec-chip.big { width: 36px; height: 36px; border-radius: 11px; }
.section {
  border-top: 1px solid var(--line);
  margin-top: 22px; padding-top: 18px;
}
.section:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }

.pill {
  background: var(--blue); color: #fff; font-size: 11px; font-weight: 600;
  border-radius: 999px; padding: 4px 10px; margin-left: auto;
}
.hint { color: var(--ink-3); font-size: 11.5px; font-weight: 400; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; }
.row-label { font-weight: 600; font-size: 13px; }
.row-label .hint { display: block; }
.row-ctl { display: flex; align-items: center; gap: 8px; }

.field-label { font-weight: 600; font-size: 13px; margin: 12px 0 6px; }
.field-block { margin-bottom: 4px; }
.field-line { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.field-label-row { display: flex; align-items: center; gap: 8px; margin: 12px 0 6px; }

.txt {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 9px;
  font: inherit; color: var(--ink); background: #fff;
}
.txt:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 125, 246, .12); }
.txt.small-lbl { width: 110px; flex: 0 0 110px; }
.txt.search { margin-bottom: 10px; }

.sel {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; font: inherit; font-size: 12.5px; color: var(--ink);
}

.style-strip { display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.mini {
  width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--ink-2); font-size: 12px; line-height: 1;
}
.mini.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.color {
  width: 26px; height: 26px; padding: 2px; border: 1px solid var(--line);
  border-radius: 7px; background: #fff;
}

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch-txt { font-size: 10px; color: var(--ink-3); letter-spacing: .04em; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; } /* focusable, invisible */
.switch input:focus-visible + .knob { box-shadow: 0 0 0 3px rgba(47, 125, 246, .45); }
.switch .knob {
  width: 40px; height: 22px; border-radius: 999px; background: #d8dee9; position: relative;
  transition: background .18s;
}
.switch .knob::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: left .18s;
}
.switch input:checked + .knob { background: var(--blue); box-shadow: 0 0 10px rgba(47, 125, 246, .55); }
.switch input:checked + .knob::after { left: 21px; }

.slider-wrap { display: inline-flex; align-items: center; gap: 10px; width: 200px; }
.slider-wrap input[type=range] { flex: 1; accent-color: var(--blue); }
.slider-val { font-size: 12px; color: var(--ink-2); min-width: 38px; text-align: right; }

.ghost-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 9px 16px; font-weight: 600; color: var(--ink); margin-top: 10px;
}
.ghost-btn:hover { background: #f7f9fd; }
.ghost-btn.sm { padding: 5px 10px; font-size: 12px; margin: 0; }
.primary {
  border: 0; border-radius: 10px; padding: 9px 18px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #4b93ff, #2f7df6);
  box-shadow: 0 0 0 4px rgba(47, 125, 246, .18), 0 6px 16px rgba(47, 125, 246, .35);
}
.primary.big { padding: 12px 22px; font-size: 15px; }
.primary:hover { filter: brightness(1.05); }

.del { border: 0; background: none; font-size: 13px; opacity: .55; }
.del:hover { opacity: 1; }

.contact-head { display: flex; gap: 8px; font-weight: 600; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.contact-head span:first-child { width: 110px; flex: 0 0 110px; }
.contact-line { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.contact-line .sel { flex: 0 0 auto; }
.contact-line .txt:not(.small-lbl) { flex: 1 1 90px; min-width: 70px; }
.field-line .txt { flex: 1 1 auto; min-width: 80px; }

/* chips */
.chips { display: inline-flex; gap: 8px; align-items: center; }
.chips.wrap { flex-wrap: wrap; max-width: 240px; }
.chip {
  position: relative;
  min-width: 34px; height: 34px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink); font-weight: 600; font-size: 12.5px;
}
.chip.selected { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 125, 246, .15); }
.chip.selected::after {
  content: '✓'; position: absolute; top: -7px; right: -7px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 9px; line-height: 15px; text-align: center;
}
.chip[disabled] { opacity: .35; pointer-events: none; }
.chip.shape svg { color: var(--ink); }
.chip.corner i { display: block; width: 20px; height: 14px; border: 2px solid var(--ink); }
.aa.aa-soft { background: #f1f5f9; }
.aa.aa-outline { border: 2px solid var(--ink); }
.aa.aa-solid { background: var(--ink); color: #fff; }
.aa.aa-ghost { color: var(--ink); font-style: italic; }

/* icon picker */
.icon-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.icon-cell {
  position: relative; aspect-ratio: 1; border: 1px solid transparent; border-radius: 8px;
  background: none; color: var(--ink-2); display: flex; align-items: center; justify-content: center;
}
.icon-cell:hover { background: #f2f5fb; }
.icon-cell.on { color: var(--ink); }
.icon-cell .check {
  display: none; position: absolute; top: -3px; right: -3px;
  width: 14px; height: 14px; border-radius: 50%; background: var(--blue); color: #fff;
  font-size: 9px; font-style: normal; line-height: 14px; text-align: center;
}
.icon-cell.on .check { display: block; }
.url-list { margin-top: 12px; }
.url-line { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.url-ic { color: var(--ink-2); flex: 0 0 18px; display: inline-flex; }

/* button presets / list */
.preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.preset {
  background: var(--ink); color: #fff; border: 0; border-radius: 6px;
  padding: 9px 6px; font-size: 12px; font-weight: 600;
}
.preset:hover { background: #1e293b; }
.btn-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.btn-chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  border: 1px dashed var(--line); border-radius: 10px; padding: 8px 26px 8px 12px;
  font-size: 12.5px; cursor: pointer; background: #fff;
}
.btn-chip.selected { border: 1px solid var(--blue); box-shadow: 0 0 0 3px rgba(47, 125, 246, .12); }
.btn-chip i { color: var(--blue); font-style: normal; }
.btn-chip b { color: var(--ink-3); font-weight: 600; }
.btn-chip .x {
  position: absolute; top: -7px; right: -7px; width: 16px; height: 16px;
  border-radius: 50%; border: 0; background: var(--ink); color: #fff; font-size: 10px; line-height: 1;
}
.btn-editor { border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; }

/* upload zone */
.drop-zone {
  border: 1.5px dashed #c9d6ef; border-radius: 12px; background: #fbfcff;
  min-height: 120px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: border-color .15s, background .15s; padding: 10px;
}
.drop-zone:hover, .drop-zone.drag { border-color: var(--blue); background: var(--blue-soft); }
.dz-empty { text-align: center; color: var(--ink-3); font-size: 12px; line-height: 1.6; }
.dz-empty b { color: var(--ink-2); }
.dz-thumb { max-height: 130px; max-width: 100%; border-radius: 8px; }
.file-chip {
  display: flex; align-items: center; gap: 8px;
  background: #eef1f7; border-radius: 9px; padding: 9px 12px; margin-top: 8px; font-size: 12.5px;
}
.file-chip .ok { color: var(--blue); }
.file-chip .fn { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .fs { color: var(--ink-3); }
.file-chip .del { margin-left: auto; }

/* layout cards */
.layout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.layout-card {
  border: 1px solid var(--line); border-radius: 14px; background: #fff;
  padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 4px;
}
.layout-card:hover { border-color: #c9d6ef; }
.layout-card.selected { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 125, 246, .15); }
.layout-card b { font-size: 13px; }
.layout-card small { color: var(--ink-3); font-size: 11px; line-height: 1.4; }
.art {
  height: 64px; border-radius: 9px; background: #f2f5fb; margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px; padding: 10px;
}
.art.col { flex-direction: column; justify-content: center; gap: 5px; }
.art i { display: block; }
.a-rail { width: 9px; height: 42px; border-radius: 5px; background: #cbd5e1; }
.a-bar { width: 4px; height: 42px; border-radius: 2px; background: var(--blue); }
.a-lines { flex: 1; height: 34px; border-radius: 4px;
  background: repeating-linear-gradient(#cbd5e1 0 5px, transparent 5px 12px); }
.a-lines.center { width: 70%; flex: 0 0 auto; }
.a-photo { width: 34px; height: 40px; background: #94a3b8; transform: skewX(-12deg); border-radius: 4px; }
.a-photo.round { border-radius: 50%; width: 34px; height: 34px; transform: none; }
.a-photo.sm { width: 22px; height: 22px; }

/* ============ preview column ============ */
#preview { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.preview-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px 8px;
}
.preview-controls { display: flex; gap: 10px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; color: var(--ink-2); font-size: 12.5px; font-weight: 500; }
.seg button.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }

#mockWrap { flex: 1; overflow: auto; padding: 18px 28px; }
#mockWrap.phone-mode { display: flex; }
#mockWrap.phone-mode .phone-frame { margin: 0 auto; } /* safe centering: never clips when overflowing */

.preview-foot { display: flex; justify-content: flex-end; gap: 12px; padding: 12px 28px; }
.preview-foot .ghost-btn { margin: 0; }
#preview footer { padding: 6px 28px 14px; color: var(--ink-3); font-size: 11.5px; }

/* browser mock */
.browser-frame {
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); overflow: hidden; max-width: 860px; margin: 0 auto;
}
.b-top { display: flex; align-items: center; gap: 12px; background: #dfe3ea; padding: 8px 14px 0; }
.dots { display: inline-flex; gap: 6px; padding-bottom: 8px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; }
.dots .r { background: #ff5f57; } .dots .y { background: #febc2e; } .dots .g { background: #28c840; }
.b-tab {
  background: #f6f7f9; border-radius: 10px 10px 0 0; padding: 7px 14px;
  font-size: 11.5px; color: var(--ink-2); max-width: 280px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.b-tab b { margin-left: 8px; font-weight: 400; }
.b-plus { color: var(--ink-2); padding-bottom: 6px; }
.b-url {
  display: flex; align-items: center; gap: 12px; background: #f6f7f9;
  padding: 8px 16px; color: var(--ink-2); font-size: 12px;
  border-bottom: 1px solid var(--line);
}
.url-box {
  flex: 1; background: #eceef1; padding: 6px 14px; border-radius: 999px; font-size: 12px;
}
.g-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; font-size: 15px; color: #5f6368; }
.g-head .g-name { font-size: 17px; color: #5f6368; }
.g-head.outlook { background: #0f6cbd; color: #fff; }
.g-head.outlook .g-name, .g-head.apple .g-name { color: inherit; font-weight: 600; }
.ol-logo { font-size: 18px; }
.g-head.apple { background: #f5f5f7; color: #333; }
.g-subject { display: flex; align-items: center; gap: 10px; padding: 10px 24px 4px; font-size: 20px; font-weight: 500; }
.chip-inbox { background: #eceef1; color: var(--ink-2); border-radius: 4px; font-size: 11px; padding: 3px 7px; }
.g-icons { margin-left: auto; color: var(--ink-3); font-size: 13px; }
.g-sender { display: flex; align-items: center; gap: 12px; padding: 12px 24px; font-size: 12.5px; }
.g-sender small { color: var(--ink-3); }
.g-time { margin-left: auto; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--ink);
  color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto;
}
.skeleton { padding: 8px 24px 4px; }
.skeleton i { display: block; height: 9px; border-radius: 5px; background: #eef0f4; margin-bottom: 9px; }
.sig-slot { padding: 18px 24px 34px; overflow-x: auto; }

/* phone mock */
.phone-frame {
  width: 400px; flex: 0 0 400px; background: #fff; border: 10px solid #1e232b; border-radius: 38px;
  box-shadow: var(--shadow); overflow: hidden; position: relative; align-self: flex-start;
}
.phone-notch {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 110px; height: 22px; background: #1e232b; border-radius: 999px;
}
.phone-status { display: flex; justify-content: space-between; padding: 12px 22px 4px; font-size: 11px; color: var(--ink-2); }
.m-head { padding: 12px 18px 4px; }
.client-name { font-size: 16px; }
.m-subject { padding: 8px 18px 0; font-size: 16.5px; font-weight: 600; }
.m-sender { display: flex; gap: 10px; align-items: center; padding: 12px 18px; font-size: 12px; }
.m-sender small { color: var(--ink-3); }
.phone-frame .skeleton { padding: 4px 18px; }
.phone-frame .sig-slot { padding: 12px 14px 30px; overflow: hidden; }

/* preview-only animation hooks (emails get GIFs / static images instead) */
.anim-icons img.ss-icon { transition: transform .18s ease; }
.anim-icons a:hover img.ss-icon { transform: translateY(-3px) scale(1.15); }
.anim-btns a.ss-btn { transition: transform .15s ease, box-shadow .15s ease; }
.anim-btns a.ss-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(15, 23, 42, .25); }

/* ============ modal / toast ============ */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: #fff; border-radius: 18px; width: 620px; max-width: calc(100vw - 40px);
  max-height: 86vh; overflow-y: auto; padding: 24px 26px; position: relative;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .35);
}
.modal .close {
  position: absolute; top: 14px; right: 16px; border: 0; background: none;
  font-size: 22px; color: var(--ink-3);
}
.modal h2 { margin-bottom: 14px; }
.modal-body .section { margin-top: 18px; padding-top: 16px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 4px; align-items: center; }
.modal-actions .ghost-btn { margin: 0; }
.how {
  background: #f7f9fd; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 12.5px; line-height: 1.7; color: var(--ink-2); margin-top: 12px;
}
.how.warn { background: #fff8ed; border-color: #fcd9a8; color: #92510a; }
.row.dim { opacity: .45; }
.row.dim .row-ctl { pointer-events: none; }
.asset-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.asset-line {
  display: flex; align-items: center; gap: 10px; font-size: 12.5px;
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px;
}
.asset-line img { width: 26px; height: 26px; object-fit: contain; background: #f2f5fb; border-radius: 6px; }
.asset-line span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 16px);
  background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 20px;
  font-size: 13.5px; opacity: 0; transition: all .25s ease; z-index: 99;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .4); max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============ narrow windows ============ */
@media (max-width: 1240px) {
  #panel { width: 390px; flex-basis: 390px; }
  #panelInner { padding: 18px 18px 60px; }
}
@media (max-width: 1080px) {
  #sidebar { width: 64px; flex: 0 0 64px; padding: 14px 8px; }
  .brand-name, .tab span, .foot-label { display: none; }
  .brand { justify-content: center; padding-bottom: 14px; }
  .tab { justify-content: center; padding: 11px 0; }
  .sig-actions { flex-wrap: wrap; }
  #sigSelect { font-size: 10px; }
  .preview-head { flex-wrap: wrap; gap: 8px; padding: 14px 16px 6px; }
  #mockWrap { padding: 12px 16px; }
  .preview-foot, #preview footer { padding-left: 16px; padding-right: 16px; }
}

/* top Save button glows when there are unsaved changes */
#quickSave.attention {
  border-color: var(--blue); color: var(--blue); font-weight: 700;
  box-shadow: 0 0 0 3px rgba(47, 125, 246, .18);
}

/* live signature previews on the layout cards */
.lay-prev {
  display: block; height: 96px; overflow: hidden;
  background: #f2f5fb; border-radius: 9px; margin-bottom: 8px; padding: 7px;
  pointer-events: none;
}
.lay-prev-inner { display: block; transform-origin: top left; }
