/* Resume — Letter Template Studio | JRiSpace | Sylvenson Richard | https://jrispace.com */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --navy: #1e3a8a;
  --navy-deep: #172554;
  --blue: #3b82f6;
  --blue-soft: #60a5fa;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #eef2f7;
  --card: #ffffff;
}
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Top bar ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(90deg, var(--navy-deep), var(--navy) 60%, #2563eb);
  color: #fff; padding: 10px 20px;
  box-shadow: 0 2px 12px rgba(23,37,84,.35);
  z-index: 10;
  flex-shrink: 0;
}
.brand-group { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; letter-spacing: 1px;
}
.menu-toggle {
  width: 36px; height: 36px; border: none; border-radius: 10px; cursor: pointer;
  background: rgba(255,255,255,.12); color: #fff; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.menu-toggle:hover { background: rgba(255,255,255,.25); }
.brand h1 { font-size: 17px; font-weight: 700; }
.brand .sub { font-size: 11px; opacity: .75; letter-spacing: 1.5px; text-transform: uppercase; }
.actions { display: flex; gap: 8px; }
.btn {
  border: none; cursor: pointer; font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 8px;
  display: flex; align-items: center; gap: 6px;
  transition: all .15s ease;
  font-family: inherit;
}
.btn-ghost { background: rgba(255,255,255,.12); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.22); }
.btn-primary { background: #fff; color: var(--navy); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.25); }

/* ===== Layout ===== */
.workspace { flex: 1; display: flex; overflow: hidden; }

/* ===== Editor panel ===== */
.editor {
  width: 400px; min-width: 400px;
  background: #f8fafc; border-right: 1px solid var(--line);
  overflow-y: auto; padding: 18px 16px 32px;
  transition: margin-left .25s ease, opacity .2s ease;
}
.editor.collapsed { margin-left: -400px; opacity: 0; pointer-events: none; }
.editor::-webkit-scrollbar { width: 8px; }
.editor::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.panel-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 14px; padding: 0 4px;
}
.panel-head .title { font-size: 15px; font-weight: 700; color: var(--navy-deep); }
.panel-head .hint { font-size: 11px; color: var(--muted); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 12px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; cursor: pointer; user-select: none;
}
.card-head .icon {
  width: 28px; height: 28px; border-radius: 8px; font-size: 13px;
  background: linear-gradient(135deg, #eef4ff, #e0ecff); color: var(--navy);
  display: flex; align-items: center; justify-content: center;
}
.card-head .name { font-size: 13.5px; font-weight: 700; flex: 1; }
.card-head .chev { color: var(--muted); font-size: 11px; transition: transform .2s; }
.card.open .card-head .chev { transform: rotate(90deg); }
.card-body { padding: 4px 14px 16px; display: none; }
.card.open .card-body { display: block; }
.field { margin-bottom: 12px; }
.field label {
  display: block; font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px;
}
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; font-size: 13.5px; font-family: inherit; color: var(--ink);
  background: #fff; outline: none; transition: border .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.field textarea { resize: vertical; min-height: 70px; line-height: 1.5; }
.field .row { display: flex; gap: 8px; }
.field .row > * { flex: 1; }
.para-item { position: relative; margin-bottom: 12px; }
.para-item label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px;
}
.para-remove {
  border: none; background: #fee2e2; color: #b91c1c; cursor: pointer;
  font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 6px;
  letter-spacing: 0;
}
.para-remove:hover { background: #fecaca; }
.btn-add {
  width: 100%; border: 1px dashed #94a3b8; background: transparent; color: var(--muted);
  padding: 9px; border-radius: 8px; cursor: pointer; font-size: 12.5px; font-weight: 600;
  font-family: inherit; transition: all .15s;
}
.btn-add:hover { border-color: var(--blue); color: var(--blue); background: #f0f6ff; }
.btn-add.danger { border-style: solid; border-color: #fca5a5; color: #b91c1c; margin-top: 6px; }
.btn-add.danger:hover { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 8px; }
.toggle-row .lbl { font-size: 13px; font-weight: 600; }
.switch {
  position: relative; width: 38px; height: 21px; background: #cbd5e1;
  border-radius: 20px; cursor: pointer; transition: background .2s; flex-shrink: 0;
}
.switch::after {
  content: ""; position: absolute; top: 2.5px; left: 3px;
  width: 16px; height: 16px; background: #fff; border-radius: 50%;
  transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch.on { background: var(--blue); }
.switch.on::after { left: 19px; }
.sig-upload { margin-bottom: 12px; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-dot {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: transform .15s, border .15s;
}
.color-dot:hover { transform: scale(1.12); }
.color-dot.active { border-color: var(--navy-deep); transform: scale(1.12); }
.color-dot.c1 { background: linear-gradient(135deg,#1e3a8a,#3b82f6); }
.color-dot.c2 { background: linear-gradient(135deg,#065f46,#10b981); }
.color-dot.c3 { background: linear-gradient(135deg,#7c2d12,#f59e0b); }
.color-dot.c4 { background: linear-gradient(135deg,#581c87,#a855f7); }
.color-dot.c5 { background: linear-gradient(135deg,#0f172a,#475569); }

/* ===== Preview panel ===== */
.preview-pane {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(135deg, #e8edf5, #dde5f0);
}
.preview-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.7); backdrop-filter: blur(6px);
  flex-shrink: 0;
}
.preview-toolbar .lbl { font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1.5px; }
.zoom { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.zoom .zbtn {
  width: 26px; height: 26px; border: 1px solid var(--line); background: #fff;
  border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--muted);
}
.zoom .zbtn.wide { width: auto; padding: 0 8px; font-size: 11px; font-weight: 700; }
.zoom .zbtn:hover { border-color: var(--blue); color: var(--blue); }
.preview-scroll { flex: 1; overflow: auto; display: flex; justify-content: center; padding: 28px; }

/* ===== Letter (shared by preview & export) ===== */
.letter-wrap { transform-origin: top center; }
.letter {
  --navy: #1e3a8a; --navy-deep: #172554; --blue: #3b82f6; --blue-soft: #60a5fa;
  position: relative; background: #fff; width: 850px;
  padding: 72px 68px 56px; border-radius: 10px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(23,37,84,.18), 0 2px 8px rgba(23,37,84,.08);
}
.wave { position: absolute; pointer-events: none; }
.wave-tl { top: 0; left: 0; width: 46%; }
.wave-br { bottom: 0; right: 0; width: 46%; transform: rotate(180deg); }
.letter.no-waves .wave { display: none; }
.content { position: relative; z-index: 1; }
.letter header { text-align: center; padding-bottom: 28px; }
.monogram {
  width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 16px;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  color: #fff; font-weight: 700; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(30,58,138,.35);
}
.letter h1 {
  font-size: 36px;
  background: linear-gradient(90deg, var(--navy-deep), var(--navy) 55%, var(--blue));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.ltitle { color: var(--navy); font-weight: 600; font-size: 16px; margin-top: 8px;
  text-transform: uppercase; letter-spacing: 2px; }
.contact { color: var(--muted); font-size: 13.5px; margin-top: 12px; }
.contact span { margin: 0 10px; }
.contact span + span { border-left: 1px solid var(--line); padding-left: 20px; }
.rule { height: 3px; margin-top: 24px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--navy) 20%, var(--blue) 50%, var(--navy) 80%, transparent); }
.meta { display: flex; justify-content: space-between; margin: 44px 0 10px; font-size: 15px; }
.meta .label { color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: 1.5px; font-weight: 700; }
.meta .value { margin-top: 6px; line-height: 1.6; }
.meta .right { text-align: right; }
.subject {
  background: linear-gradient(90deg, #eef4ff, #f6f9ff);
  border-left: 4px solid; border-image: linear-gradient(180deg, var(--navy), var(--blue)) 1;
  padding: 16px 22px; font-weight: 700; font-size: 16px;
  border-radius: 0 8px 8px 0; margin: 30px 0 34px; color: var(--navy-deep);
}
.body-p { font-size: 15.5px; line-height: 1.75; margin-bottom: 18px; text-align: justify; }
.closing { margin-top: 28px; }
.signature-block { margin-top: 24px; }
.signature-block.manual-space { margin-top: 72px; }
.sig-img { height: 88px; display: block; margin-bottom: -8px; }
.sig-line { height: 2px; width: 320px; border-radius: 2px;
  background: linear-gradient(90deg, var(--navy), var(--blue-soft), transparent); }
.sig-label { font-weight: 700; font-size: 15px; margin-top: 8px; display: inline-block; }
.sig-date { color: var(--muted); font-size: 14px; margin-left: 44px; }
.sig-name { color: var(--muted); font-size: 14px; margin-top: 5px; }
.sig-role { color: #94a3b8; font-size: 13px; margin-top: 2px; }
.letter footer { margin-top: 60px; padding-top: 18px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  color: #94a3b8; font-size: 12px; letter-spacing: .5px; }
.letter footer .brand-r { font-weight: 700; color: var(--navy); }

/* ===== Auth gate (Clerk) — split layout ===== */
.auth-gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: stretch; justify-content: stretch;
  background: #ffffff; overflow: hidden;
}
.auth-left {
  flex: 0 0 46%; min-width: 420px;
  display: flex; align-items: center; justify-content: center;
  padding: 32px; overflow-y: auto;
  background: #ffffff;
}
.auth-right {
  position: relative; flex: 1;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #172554 0%, #1e3a8a 55%, #2563eb 100%);
  overflow: hidden;
}
.auth-wave { position: absolute; pointer-events: none; }
.auth-wave-tl { top: 0; left: 0; width: 46%; }
.auth-wave-br { bottom: 0; right: 0; width: 46%; transform: rotate(180deg); }
.auth-brand { position: relative; z-index: 1; color: #fff; text-align: left; max-width: 420px; padding: 32px; }
.auth-brand-badge {
  width: 44px; height: 44px; border-radius: 12px; margin-bottom: 20px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.auth-brand h3 { font-size: 30px; line-height: 1.25; font-weight: 700; margin-bottom: 14px; }
.auth-brand p { font-size: 15px; line-height: 1.65; color: rgba(255,255,255,.78); margin-bottom: 24px; }
.auth-features { list-style: none; }
.auth-features li {
  font-size: 14px; color: rgba(255,255,255,.9); margin-bottom: 10px;
  padding-left: 26px; position: relative;
}
.auth-features li::before {
  content: "✓"; position: absolute; left: 0; top: 0;
  color: #60a5fa; font-weight: 700;
}
.auth-card {
  position: relative; background: #fff; border-radius: 16px;
  padding: 36px 40px; width: 100%; max-width: 480px;
  text-align: center;
}
.auth-logo {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px;
  background: linear-gradient(135deg, #1e3a8a, #3b82f6); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px; box-shadow: 0 8px 20px rgba(30,58,138,.35);
}
.auth-title { font-size: 20px; color: #172554; margin-bottom: 4px; }
.auth-sub {
  font-size: 12px; color: #64748b; text-transform: uppercase;
  letter-spacing: 2px; margin-bottom: 24px;
}
.auth-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 2px dashed #cbd5e1; border-radius: 10px; padding: 30px 16px;
  color: #94a3b8; font-size: 13px; margin-bottom: 18px;
}
.spinner {
  width: 18px; height: 18px; border: 2.5px solid #e2e8f0; border-top-color: #1e3a8a;
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.auth-error { color: #b91c1c; font-size: 13px; margin-bottom: 12px; }
.auth-error p { margin-bottom: 10px; }
.btn-retry {
  border: none; background: #fee2e2; color: #b91c1c; font-weight: 700;
  font-size: 12px; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  font-family: inherit;
}
.btn-retry:hover { background: #fecaca; }
.auth-foot { margin-top: 18px; font-size: 11px; color: #94a3b8; }
#clerk-signin:empty { display: none; }
#user-button { display: flex; align-items: center; }
#user-button:empty { display: none; }
@media (max-width: 860px) {
  .auth-right { display: none; }
  .auth-left { flex: 1; min-width: 0; }
}

/* ===== Status bar ===== */
.statusbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 20px; background: #0f172a; color: #94a3b8; font-size: 11.5px;
  flex-shrink: 0;
}
.statusbar .ok { color: #34d399; }
.statusbar .domain { color: var(--blue-soft); font-weight: 600; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .editor { position: absolute; z-index: 20; height: 100%; box-shadow: 8px 0 24px rgba(15,23,42,.15); }
  .editor.collapsed { margin-left: -420px; }
}
