:root {
  --accent: #0d6e6e;
  --accent-dark: #0a4f4f;
  --a4-height: 297mm;
  --ink: #1f242b;
  --muted: #5e6a75;
  --paper: #e8eff1;
  --paper-soft: #dce7ea;
  --panel: #0f1723;
  --panel-soft: #1a2433;
  --line: #d9d9d3;
  --radius: 14px;
  --shadow: 0 18px 60px rgba(13, 23, 38, 0.24);
}

* {
  box-sizing: border-box;
}

@page {
  size: A4;
  margin: 0;
}

body {
  margin: 0;
  color: #e9edf2;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 8% 12%, #28425f 0%, rgba(40, 66, 95, 0) 36%),
    radial-gradient(circle at 78% 18%, #25595f 0%, rgba(37, 89, 95, 0) 33%),
    linear-gradient(135deg, #111927 0%, #171f30 45%, #1f2f36 100%);
  min-height: 100vh;
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  min-height: 100vh;
}

.builder-panel {
  padding: 1rem;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-soft) 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  overflow-y: auto;
}

.panel-head {
  margin-bottom: 0.75rem;
  animation: rise-in 420ms ease;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 0.9rem;
}

.panel-head-left {
  min-width: 0;
}

.panel-head h1 {
  margin: 0;
  font-size: 1.42rem;
  letter-spacing: 0.3px;
}

.panel-subtitle {
  margin: 0.35rem 0 0;
  color: #b7c5d3;
  font-size: 0.9rem;
}

.panel-credit {
  margin: 0.2rem 0 0 !important;
  font-size: 0.78rem !important;
  color: #8ca0b5 !important;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.meta-side {
  flex: 0 0 auto;
  max-width: 170px;
  padding: 0.45rem 0.5rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.qr-code {
  width: 84px;
  height: 84px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.25rem;
}

.contribution {
  margin: 0;
  font-size: 0.72rem;
  color: #b7c5d3;
  line-height: 1.25;
  text-align: center;
}

.panel-credit a {
  color: #d6f3f1;
  text-decoration: none;
}

.credit-highlight {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(214, 243, 241, 0.12);
  border: 1px solid rgba(214, 243, 241, 0.22);
  color: #e8fffd;
}

.credit-label,
.credit-separator {
  color: #a6bacb;
}

.panel-credit a:hover {
  text-decoration: underline;
}

.panel-stats {
  margin-top: 0.7rem;
  display: inline-flex;
  align-items: center;
  padding: 0.42rem 0.68rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #d6e3ef;
  font-size: 0.8rem;
}

.panel-section {
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(2px);
  animation: rise-in 520ms ease;
}

.panel-section h2 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #d7dfeb;
}

.section-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.84rem;
  color: #c6d2de;
}

input,
textarea,
select {
  width: 100%;
  margin-top: 0.3rem;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(4, 11, 22, 0.45);
  color: #f1f5f9;
  font: inherit;
  padding: 0.48rem 0.6rem;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(65, 212, 212, 0.7);
  box-shadow: 0 0 0 3px rgba(26, 145, 145, 0.22);
}

.grid-two {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.repeat-list {
  display: grid;
  gap: 0.45rem;
}

.repeat-item {
  padding: 0.55rem;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(1, 8, 19, 0.36);
}

.repeat-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.25rem;
}

.field-hint {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: #9cb0c2;
  line-height: 1.35;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.4rem;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 0.58rem 0.7rem;
  color: #eff7f7;
  background: linear-gradient(145deg, var(--accent), var(--accent-dark));
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 180ms ease, filter 180ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.btn.small {
  padding: 0.42rem 0.55rem;
  font-size: 0.75rem;
}

.btn.ghost {
  background: transparent;
  border: 1px solid #b9c9d9;
  color: #1b2f42;
}

.btn.primary {
  grid-column: 1 / -1;
  background: linear-gradient(145deg, #175f8a, #0f4668);
}

.btn.danger {
  background: linear-gradient(145deg, #9f3b33, #6e2621);
}

.btn:disabled {
  opacity: 0.72;
  cursor: wait;
  transform: none;
}

.preview-panel {
  padding: 1rem;
  overflow: auto;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(210mm, 100%);
  margin: 0 auto 0.45rem;
  color: #f3f8fe;
  letter-spacing: 0.35px;
}

.resume-paper {
  width: 210mm;
  min-height: var(--a4-height);
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-soft) 100%);
  margin: 0 auto;
  color: var(--ink);
  border-radius: 7px;
  box-shadow: var(--shadow);
  overflow: visible;
  transform-origin: top center;
  animation: reveal-paper 420ms ease;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.resume-paper.paged {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  animation: none;
}

.resume-paper.paged > .resume-content {
  position: absolute;
  top: 0;
  left: -99999px;
  width: 100%;
  visibility: hidden;
  pointer-events: none;
}

.resume-pages {
  display: grid;
  gap: 14px;
}

.resume-page {
  width: 210mm;
  height: var(--a4-height);
  background: color-mix(in srgb, var(--accent) 8%, var(--paper) 92%);
  border-radius: 7px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.resume-page-viewport {
  height: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.resume-page-window {
  width: 100%;
  overflow: hidden;
}

.resume-content-clone {
  width: 100%;
}

.resume-content {
  width: 100%;
  min-height: 100%;
  background: color-mix(in srgb, var(--accent) 8%, var(--paper) 92%);
}

.resume-paper.font-modern {
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
}

.resume-paper.font-clean {
  font-family: "Inter", "Segoe UI", sans-serif;
}

.resume-paper.font-elegant {
  font-family: "Merriweather", Georgia, serif;
}

.resume-paper.font-classic {
  font-family: "Libre Baskerville", Georgia, serif;
}

.resume-header {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 0.7rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(
    125deg,
    color-mix(in srgb, var(--accent) 94%, black 6%) 0%,
    color-mix(in srgb, var(--accent) 70%, #f4efe4 30%) 100%
  );
  color: #f8fbfd;
}

.header-copy h2 {
  margin: 0;
  font-family: "Merriweather", Georgia, serif;
  font-size: 1.85rem;
  line-height: 1.1;
}

.header-copy p {
  margin: 0.2rem 0 0.45rem;
  font-size: 1.02rem;
}

.contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.contact-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.73rem;
  padding: 0.21rem 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.14);
  color: inherit;
  text-decoration: none;
  user-select: text;
  -webkit-user-select: text;
  cursor: copy;
}

.contact-chip:hover {
  background: rgba(0, 0, 0, 0.22);
}

.contact-chip.copied {
  background: rgba(255, 255, 255, 0.24);
}

.header-photo-wrap {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.8);
  align-self: center;
}

.header-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #e5ecef;
}

.resume-column {
  display: block;
  padding: 0.95rem 1.1rem 1rem;
}

.resume-section {
  margin-bottom: 0.78rem;
  break-inside: avoid;
  page-break-inside: avoid;
}

.resume-section h3 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1.15px;
  color: color-mix(in srgb, var(--accent) 74%, #1d262d 26%);
  padding-bottom: 0.23rem;
  border-bottom: 1px solid var(--line);
}

.resume-section p {
  margin: 0;
  color: #29323b;
  font-size: 0.84rem;
  line-height: 1.55;
}

.resume-section:last-child {
  margin-bottom: 0;
}

body.exporting-pdf .resume-pages {
  gap: 0;
}

body.exporting-pdf .resume-page {
  border-radius: 0;
  box-shadow: none;
}

body.exporting-pdf .resume-paper {
  box-shadow: none;
  border-radius: 0;
  background: transparent;
  animation: none;
}

body.printing .preview-panel {
  padding: 0;
  background: white;
}

body.printing .resume-pages {
  gap: 0;
}

body.printing .resume-page {
  border-radius: 0;
  box-shadow: none;
}

body.printing .resume-paper {
  width: 210mm;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  animation: none;
}

.timeline {
  display: grid;
  gap: 0.5rem;
}

.timeline-item {
  border-left: 2px solid color-mix(in srgb, var(--accent) 62%, white 38%);
  padding-left: 0.58rem;
  break-inside: avoid;
  page-break-inside: avoid;
}

.timeline-head {
  display: flex;
  gap: 0.62rem;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 0.2rem;
  padding-right: 0;
}

.timeline-title {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.32;
}

.timeline-meta {
  margin: 0;
  font-size: 0.73rem;
  color: #5b6771;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.timeline-item ul {
  margin: 0.28rem 0 0;
  padding-left: 1.05rem;
}

.timeline-item li {
  font-size: 0.79rem;
  color: #303a45;
  margin-bottom: 0.16rem;
}

.timeline-item a {
  color: color-mix(in srgb, var(--accent) 78%, black 22%);
  text-decoration: none;
  font-size: 0.75rem;
  word-break: break-all;
  display: inline-block;
  margin-top: 0.24rem;
  margin-left: 0.95rem;
}

.plain-list {
  margin: 0;
  padding-left: 1.1rem;
}

.plain-list li {
  font-size: 0.8rem;
  color: #2f3942;
  margin-bottom: 0.16rem;
  line-height: 1.45;
}

.plain-list li:last-child {
  margin-bottom: 0;
}

.chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.36rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.35rem;
  padding: 0.2rem 0.52rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, white 66%);
  background: color-mix(in srgb, var(--accent) 17%, white 83%);
  color: #21333b;
  font-size: 0.76rem;
  line-height: 1.2;
}

.empty {
  font-size: 0.76rem;
  color: #6a7681;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes reveal-paper {
  from {
    opacity: 0.5;
    transform: translateY(12px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 1200px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  .builder-panel {
    max-height: none;
  }

  .preview-toolbar,
  .resume-paper {
    width: min(210mm, calc(100vw - 1.8rem));
  }

  .resume-pages {
    width: 100%;
  }

  .resume-page {
    width: 100%;
    height: auto;
    aspect-ratio: 210 / 297;
  }
}

@media (max-width: 700px) {
  .builder-panel,
  .preview-panel {
    padding: 0.8rem;
  }

  .panel-head {
    grid-template-columns: 1fr;
  }

  .meta-side {
    max-width: none;
    justify-self: stretch;
    align-items: flex-start;
  }

  .contribution {
    text-align: left;
  }

  .grid-two,
  .actions {
    grid-template-columns: 1fr;
  }

  .resume-header {
    grid-template-columns: 1fr;
  }

  .header-photo-wrap {
    width: 80px;
    height: 80px;
  }

  .timeline-head {
    gap: 0.52rem;
    align-items: baseline;
    margin-bottom: 0.2rem;
    padding-right: 0;
  }

  .timeline-meta {
    text-align: left;
    white-space: nowrap;
  }
}

@media print {
  body {
    background: white;
  }

  .builder-panel,
  .preview-toolbar {
    display: none;
  }

  .preview-panel {
    padding: 0;
  }

  .resume-pages {
    gap: 0;
  }

  .resume-page {
    width: 210mm;
    height: var(--a4-height);
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }

  .resume-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .resume-paper {
    width: 210mm;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    animation: none;
    overflow: visible;
  }

  .resume-paper > .resume-content {
    display: none;
  }
}
