:root {
  --bg: #eef2ef;
  --panel: #fcfcfb;
  --panel-strong: #f3f5f1;
  --text: #1a201d;
  --muted: #5e6862;
  --line: #d8ded9;
  --accent: #17624a;
  --accent-2: #d96d3f;
  --accent-soft: rgba(23, 98, 74, 0.12);
  --shadow: 0 20px 48px rgba(26, 32, 29, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(217, 109, 63, 0.08), rgba(217, 109, 63, 0) 220px),
    linear-gradient(140deg, rgba(23, 98, 74, 0.08), rgba(23, 98, 74, 0) 260px),
    var(--bg);
}

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

button,
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: 160ms ease;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0.7rem 0.8rem;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.92rem;
}

label span {
  color: var(--text);
  font-weight: 600;
}

.app-shell {
  padding: 1.25rem;
}

.mobile-nav {
  display: none;
}

.mobile-view-switch {
  display: none;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.brand-block {
  max-width: 42rem;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.topbar h1,
.preview-meta h2,
.panel-card h2 {
  margin: 0;
  font-size: clamp(1.6rem, 2vw, 2.2rem);
  line-height: 1.05;
}

.subtitle,
.panel-copy {
  margin: 0.45rem 0 0;
  color: var(--muted);
  max-width: 48rem;
  line-height: 1.5;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: flex-end;
}

.btn {
  background: #fff;
  color: var(--text);
  padding: 0.72rem 0.95rem;
  font-weight: 700;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(26, 32, 29, 0.08);
}

.btn-secondary {
  border-color: var(--line);
  background: var(--panel-strong);
}

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

.btn-small {
  padding: 0.55rem 0.72rem;
  font-size: 0.88rem;
}

.file-btn {
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 470px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.editor-panel,
.preview-panel {
  min-width: 0;
}

.preview-panel {
  position: sticky;
  top: 1rem;
}

.panel-card,
.preview-controls {
  background: var(--panel);
  border: 1px solid rgba(94, 104, 98, 0.14);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-card {
  padding: 1rem;
  margin-bottom: 1rem;
}

.editor-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0 0 0.95rem;
}

.section-tab.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.panel-card[hidden] {
  display: none;
}

.intro-card {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.status-pill {
  white-space: nowrap;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 700;
}

.section-head {
  margin-bottom: 0.9rem;
}

.section-head-inline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.field-grid {
  display: grid;
  gap: 0.85rem;
}

.field-grid.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.9rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.94rem;
}

.checkbox-label input {
  width: auto;
  margin: 0;
}

.photo-btn {
  width: fit-content;
}

.stack-list {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.stack-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(243, 245, 241, 0.92));
}

.stack-card-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.stack-card h3 {
  margin: 0;
  font-size: 1rem;
}

.card-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.icon-btn {
  min-width: 2rem;
  padding: 0.45rem 0.55rem;
  background: #fff;
  border: 1px solid var(--line);
}

.preview-controls {
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.preview-stage {
  overflow: auto;
  padding: 0.5rem 0 0;
  max-height: calc(100vh - 10rem);
}

.preview-frame {
  width: min(100%, 850px);
  margin: 0 auto;
}

.preview-frame.is-scaled {
  width: 100%;
  height: var(--preview-height, 1100px);
  overflow: hidden;
}

.preview-frame.is-scaled .resume-paper {
  width: 850px;
  max-width: none;
  margin: 0;
  transform: scale(var(--preview-scale, 1));
  transform-origin: top left;
}

.resume-paper {
  width: 100%;
  max-width: 850px;
  min-height: 1100px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid rgba(94, 104, 98, 0.16);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(26, 32, 29, 0.14);
  padding: 3rem;
}

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

.resume-paper.font-serif {
  font-family: Georgia, "Times New Roman", serif;
}

.resume-paper.font-grotesk {
  font-family: "Arial Narrow", Arial, Helvetica, sans-serif;
}

.resume-paper.density-tight {
  padding: 2.45rem;
}

.resume-header {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
  align-items: flex-start;
}

.identity h1 {
  margin: 0;
  font-size: 2.25rem;
  line-height: 0.96;
}

.identity .headline {
  margin: 0.45rem 0 0.35rem;
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
}

.contact-line {
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.94rem;
}

.headshot {
  width: 92px;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--accent-soft);
}

.resume-divider {
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  margin: 1rem 0 1.25rem;
}

.resume-body {
  display: grid;
  gap: 1rem;
}

.template-sidebar .resume-body {
  grid-template-columns: 1.05fr 1.9fr;
  gap: 1.2rem;
}

.template-sidebar .sidebar-column {
  background: linear-gradient(180deg, rgba(23, 98, 74, 0.08), rgba(23, 98, 74, 0.02));
  border: 1px solid rgba(23, 98, 74, 0.08);
  border-radius: 8px;
  padding: 1rem;
}

.template-sidebar .main-column {
  min-width: 0;
}

.template-compact .resume-header {
  align-items: end;
}

.template-compact .resume-divider {
  margin: 0.85rem 0 0.95rem;
  height: 2px;
}

.template-compact .resume-grid-compact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.1rem;
}

.resume-section {
  min-width: 0;
}

.resume-section h2 {
  margin: 0 0 0.55rem;
  font-size: 0.84rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px solid rgba(23, 98, 74, 0.22);
  padding-bottom: 0.35rem;
}

.resume-section p {
  margin: 0;
  line-height: 1.55;
  color: #2a322d;
}

.resume-section + .resume-section {
  margin-top: 0.95rem;
}

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

.chip {
  border: 1px solid rgba(23, 98, 74, 0.18);
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  background: rgba(23, 98, 74, 0.05);
  font-size: 0.86rem;
}

.skill-group + .skill-group,
.experience-item + .experience-item,
.project-item + .project-item,
.education-item + .education-item {
  margin-top: 0.85rem;
}

.skill-group h3,
.experience-item h3,
.project-item h3,
.education-item h3 {
  margin: 0;
  font-size: 1rem;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.45rem 1rem;
  margin: 0.2rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.bullet-list,
.plain-list {
  margin: 0;
  padding-left: 1rem;
}

.bullet-list li,
.plain-list li {
  margin-bottom: 0.3rem;
  line-height: 1.45;
}

.empty-note {
  color: var(--muted);
  font-style: italic;
}

@page {
  size: letter;
  margin: 0.4in;
}

@media (max-width: 1040px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    order: 1;
  }

  .editor-panel {
    order: 2;
  }

  .resume-paper {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 0.7rem;
  }

  .mobile-nav {
    display: flex;
    gap: 0.55rem;
    overflow-x: auto;
    padding: 0.15rem 0 0.8rem;
    margin-bottom: 0.2rem;
    position: sticky;
    top: 0;
    z-index: 20;
    background:
      linear-gradient(180deg, var(--bg) 0%, var(--bg) 72%, rgba(238, 242, 239, 0) 100%);
  }

  .mobile-nav .btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .mobile-view-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin: 0 0 0.85rem;
    position: sticky;
    top: 2.95rem;
    z-index: 19;
    padding-bottom: 0.4rem;
    background:
      linear-gradient(180deg, var(--bg) 0%, var(--bg) 72%, rgba(238, 242, 239, 0) 100%);
  }

  .mobile-view-switch .btn {
    width: 100%;
  }

  .mobile-view-switch .btn.is-active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
  }

  .toolbar {
    width: calc(100vw - 1.4rem);
    margin-left: -0.05rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.3rem;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
  }

  .toolbar .btn,
  .toolbar .file-btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .editor-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.3rem;
    margin-bottom: 0.8rem;
    -webkit-overflow-scrolling: touch;
  }

  .editor-tabs .btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .panel-card {
    padding: 0.85rem;
    margin-bottom: 0.8rem;
  }

  .section-head-inline,
  .stack-card-head {
    align-items: start;
  }

  .field-grid.two-up,
  .template-sidebar .resume-body,
  .template-compact .resume-grid-compact {
    grid-template-columns: 1fr;
  }

  .topbar,
  .toolbar,
  .preview-controls,
  .intro-card {
    flex-direction: column;
  }

  .preview-controls {
    position: sticky;
    top: 3.2rem;
    z-index: 10;
    margin-bottom: 0.75rem;
  }

  body.mobile-mode-preview .editor-panel {
    display: none;
  }

  body.mobile-mode-editor .preview-panel {
    display: none;
  }

  .preview-stage {
    overflow: visible;
    padding-top: 0;
    max-height: none;
  }

  .resume-paper {
    padding: 1.2rem;
    border-radius: 8px;
  }

  .resume-header {
    flex-direction: column;
  }

  .identity h1 {
    font-size: 1.55rem;
  }

  .identity .headline {
    font-size: 0.94rem;
  }

  .contact-line,
  .resume-section p,
  .bullet-list li,
  .plain-list li,
  .chip,
  .meta-line {
    font-size: 0.84rem;
  }

  .resume-section h2 {
    font-size: 0.72rem;
    letter-spacing: 0.12em;
  }

  .skill-group h3,
  .experience-item h3,
  .project-item h3,
  .education-item h3 {
    font-size: 0.92rem;
  }

  .headshot {
    width: 72px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .editor-panel,
  .preview-controls {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .preview-panel,
  .preview-stage {
    padding: 0;
    margin: 0;
    display: block;
  }

  .resume-paper {
    width: 100%;
    min-height: auto;
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
  }
}
