:root {
  --navy: #13273c;
  --teal: #007182;
  --slate: #3e4b56;
  --light: #e3eaed;
  --pale: #f1f8f9;
  --bg: #eef2f5;
  --panel: #ffffff;
  --border: #d0dae0;
  --muted: #6b7a85;
  --danger: #b42318;
  --radius: 12px;
  --font: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --shadow: 0 1px 2px rgba(19, 39, 60, 0.06), 0 8px 24px rgba(19, 39, 60, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--slate);
  background:
    radial-gradient(1200px 600px at 10% -10%, #d9ebef 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #e4e9f0 0%, transparent 50%),
    var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.app {
  display: grid;
  grid-template-rows: auto auto 1fr;
  height: 100vh;
  min-height: 0;
}

/* Top bar */
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(160px, 0.9fr) auto;
  gap: 0.75rem 1rem;
  align-items: center;
  padding: 0.7rem 1rem;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 20;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.brand-mark {
  width: 12px;
  height: 36px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--teal), var(--navy));
  flex: 0 0 auto;
}

.topbar-brand h1 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--navy);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-sub {
  margin: 0.1rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.topbar-center {
  min-width: 0;
}

.resume-switcher {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  background: #fff;
  color: var(--navy);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  position: relative;
  justify-content: flex-end;
}

.status {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  transition: opacity 0.15s, background 0.15s, transform 0.12s;
}

.btn:hover {
  opacity: 0.94;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--teal);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--border);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.more-menu[hidden] {
  display: none !important;
}

.more-menu button {
  border: none;
  background: transparent;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-radius: 7px;
  color: var(--navy);
  font-size: 0.86rem;
}

.more-menu button:hover {
  background: var(--pale);
}

.more-menu button.danger {
  color: var(--danger);
}

.more-menu hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.25rem 0;
}

.mobile-tabs {
  display: none;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  gap: 0.35rem;
}

.mobile-tabs .tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.55rem;
  border-radius: 8px;
  font-weight: 600;
  color: var(--muted);
}

.mobile-tabs .tab.active {
  background: var(--pale);
  color: var(--navy);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(380px, 1.05fr);
  min-height: 0;
  height: 100%;
}

/* Editor */
.editor {
  overflow: auto;
  padding: 1rem 1.1rem 2.5rem;
  min-height: 0;
}

.privacy-note {
  margin: 0 0 0.9rem;
  padding: 0.7rem 0.85rem;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
}

.section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.7rem;
  box-shadow: var(--shadow);
  overflow: clip;
}

.section summary {
  list-style: none;
  cursor: pointer;
  padding: 0.85rem 1rem;
  font-weight: 700;
  color: var(--navy);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  user-select: none;
}

.section summary::-webkit-details-marker {
  display: none;
}

.section summary::after {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s;
  flex: 0 0 auto;
}

.section[open] summary::after {
  transform: rotate(-135deg);
}

.section-body {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--light);
}

.help {
  margin: 0.65rem 0 0.55rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 0;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.field input,
.field textarea,
.line-row input,
.line-row textarea,
.repeat-item input,
.repeat-item textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  background: #fff;
  color: var(--slate);
  width: 100%;
}

.field input:focus,
.field textarea:focus,
.line-row input:focus,
.line-row textarea:focus,
.repeat-item input:focus,
.repeat-item textarea:focus,
.resume-switcher:focus {
  outline: 2px solid rgba(0, 113, 130, 0.25);
  border-color: var(--teal);
}

.field textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.4;
}

.line-list,
#experience-editor,
#certifications-editor,
#skills-editor,
#languages-editor {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.55rem;
}

.line-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
  align-items: start;
}

.repeat-item {
  border: 1px solid var(--light);
  background: #fafcfd;
  border-radius: 10px;
  padding: 0.7rem;
}

.item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.55rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--navy);
}

.item-actions {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.panel-actions {
  margin-top: 0.45rem;
}

/* Preview pane */
.preview-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: linear-gradient(180deg, #dce6eb 0%, #cfd9df 100%);
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 1rem;
  background: rgba(255, 255, 255, 0.55);
  border-bottom: 1px solid rgba(201, 212, 218, 0.8);
}

.preview-toolbar h2 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--navy);
}

.preview-scroll {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 1rem;
  min-height: 0;
}

.preview-fit {
  position: relative;
  flex: 0 0 auto;
  max-width: 100%;
}

.preview-scale {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
}

.resume-pages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

/* Letter resume page — USA professional format */
.resume-page {
  width: 8.5in;
  height: 11in;
  background: #fff;
  box-shadow: 0 10px 30px rgba(19, 39, 60, 0.18);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  font-family: Helvetica, Arial, sans-serif;
  color: var(--slate);
}

.resume-accent {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  background: var(--teal);
  z-index: 1;
}

.resume-header {
  background: var(--navy);
  color: #fff;
  padding: 18px 44px 14px 52px;
  position: relative;
  flex: 0 0 auto;
}

.resume-header::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 14px;
  background: var(--teal);
}

.resume-header::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 0;
  bottom: -3px;
  height: 3px;
  background: var(--teal);
}

.resume-header h1 {
  margin: 0;
  font-size: 20pt;
  letter-spacing: 0.02em;
  font-weight: 700;
}

.resume-header .tagline {
  margin: 5px 0 8px;
  font-size: 8.5pt;
  font-weight: 700;
  color: var(--light);
  letter-spacing: 0.04em;
}

.resume-header .contact {
  margin: 0;
  font-size: 8.2pt;
  color: #fff;
}

.resume-body {
  padding: 16px 44px 8px 52px;
  flex: 1 1 auto;
  overflow: hidden;
  min-height: 0;
}

.resume-footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 44px 14px 52px;
  padding-top: 8px;
  border-top: 1px solid var(--light);
  font-size: 7.2pt;
  font-weight: 700;
}

.resume-footer .footer-name {
  color: var(--navy);
  letter-spacing: 0.04em;
}

.resume-footer .footer-page {
  color: var(--teal);
  letter-spacing: 0.04em;
}

.resume-measure-host {
  position: absolute;
  left: -10000px;
  top: 0;
  visibility: hidden;
  pointer-events: none;
}

.resume-measure-body {
  font-family: Helvetica, Arial, sans-serif;
  font-size: 10.2pt;
  line-height: 1.35;
  color: var(--slate);
  box-sizing: border-box;
}

.resume-section {
  margin-bottom: 12px;
}

.resume-section-title {
  display: flex;
  align-items: center;
  background: var(--pale);
  border-left: 4px solid var(--teal);
  padding: 5px 10px;
  margin: 0 0 8px;
  font-size: 10pt;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.resume-section p {
  margin: 0 0 6px;
  font-size: 8.7pt;
}

.competency-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.competency-grid li,
.resume-bullets li,
.edu-items li {
  position: relative;
  padding-left: 12px;
  font-size: 8.4pt;
  margin: 0 0 3px;
}

.competency-grid li::before,
.resume-bullets li::before,
.edu-items li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45em;
  width: 4px;
  height: 4px;
  background: var(--teal);
}

.resume-role {
  margin-bottom: 10px;
}

.role-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.role-company {
  font-weight: 700;
  color: var(--navy);
  font-size: 9.2pt;
}

.role-location {
  font-weight: 400;
  color: var(--slate);
  font-size: 8.2pt;
}

.role-dates {
  color: var(--teal);
  font-size: 8.1pt;
  white-space: nowrap;
}

.role-title {
  font-style: italic;
  font-size: 8.5pt;
  margin: 2px 0 4px;
}

.resume-bullets,
.edu-items {
  margin: 0;
  padding: 0;
  list-style: none;
}

.resume-bullets li {
  font-size: 8.25pt;
  margin-bottom: 2px;
}

.youtube-link {
  margin: 2px 0 0 12px;
  font-size: 8.2pt;
  font-weight: 700;
  color: var(--teal);
}

.youtube-link a {
  color: inherit;
  text-decoration: none;
}

.labeled {
  margin: 0 0 4px;
  font-size: 8.3pt;
}

.pdf-capture-root {
  position: fixed;
  left: -10000px;
  top: 0;
  z-index: -1;
  pointer-events: none;
}

.pdf-export .resume-page {
  box-shadow: none;
}

@media (max-width: 1100px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .topbar-center {
    grid-column: 1 / -1;
    order: 3;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .mobile-tabs {
    display: flex;
  }

  .preview-pane,
  .editor {
    display: none;
  }

  body.show-edit .editor,
  body.show-preview .preview-pane {
    display: flex;
    flex-direction: column;
  }

  body.show-edit .editor {
    display: block;
  }

  .preview-pane {
    border-left: none;
    min-height: calc(100vh - 120px);
  }
}

@media (max-width: 640px) {
  .field-row {
    grid-template-columns: 1fr;
  }

  .topbar-actions .status {
    display: none;
  }

  .brand-sub {
    display: none;
  }
}

@media print {
  .topbar,
  .mobile-tabs,
  .editor,
  .preview-toolbar {
    display: none !important;
  }

  .workspace,
  .preview-pane,
  .preview-scroll {
    display: block !important;
    background: #fff;
    border: none;
    padding: 0;
    overflow: visible;
  }

  .preview-fit {
    width: auto !important;
    height: auto !important;
  }

  .preview-scale {
    position: static !important;
    transform: none !important;
    width: auto !important;
    height: auto !important;
  }

  .resume-page {
    box-shadow: none;
    page-break-after: always;
  }
}
