:root {
  --canvas: #ffffff;
  --paper: #ffffff;
  --ink: #121212;
  --muted: #6b6b6b;
  --soft: #f6f6f3;
  --line: #ddddda;
  --focus: #eef4ff;
  --accent: #245bd6;
  --page-width-px: 794px;
  --page-height-px: 1123px;
  --content-height-px: 1000px;
  --page-stack-gap: 1.25rem;
  --margin-top-mm: 16mm;
  --margin-right-mm: 16mm;
  --margin-bottom-mm: 18mm;
  --margin-left-mm: 16mm;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: "Archivo";
}

button,
select,
input,
[contenteditable="true"] {
  font: inherit;
}

a {
  color: var(--accent);
}

.app-shell {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid #efefeb;
}

.app-bar,
.toolbar,
.workspace {
  width: min(100%, 13rem + var(--page-width-px));
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

.app-bar {
  padding-top: 1rem;
  padding-bottom: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-lockup h1,
.rail-label {
  margin: 0;
}

.document-context {
  margin: 0.35rem 0 0;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.language-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.3rem;
  min-height: 1.7rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: #f3f4ef;
  color: #404040;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 0.22rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand-lockup h1 {
  font-size: 1.35rem;
  letter-spacing: -0.04em;
}

.status-cluster {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.save-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.mode-switch {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem;
  border: 1px solid #ddd8cc;
  border-radius: 999px;
  background: #f7f4eb;
}

.mode-switch-button {
  min-height: 2.1rem;
  padding: 0.42rem 0.88rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.mode-switch-button[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 8px 18px rgba(18, 18, 18, 0.12);
}

body[data-is-localhost="false"] [data-local-only] {
  display: none !important;
}

.button,
.mini-button {
  border-radius: 999px;
  border: 1px solid #dadad4;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.button {
  padding: 0.72rem 1rem;
}

.button.ghost {
  background: #fff;
}

.button.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.button:disabled,
.mini-button:disabled {
  opacity: 0.55;
  cursor: progress;
}

.button,
.mini-button,
.popover-action,
.shortcuts-toggle,
.toolbar-tab {
  transition:
    background-color 140ms ease,
    color 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    opacity 140ms ease;
}

.button:hover,
.mini-button:hover,
.popover-action:hover {
  border-color: #c7c7c1;
  background: #f8f8f5;
}

.button.primary:hover,
.popover-action.primary-action:hover {
  background: #242424;
}

.header-popover {
  position: relative;
}

.popover-toggle {
  list-style: none;
}

.popover-toggle::-webkit-details-marker {
  display: none;
}

.header-popover-panel {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  z-index: 25;
  display: grid;
  gap: 0.8rem;
  width: min(22rem, calc(100vw - 2rem));
  padding: 0.95rem;
  border: 1px solid #e2e2dc;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 50px rgba(18, 18, 18, 0.12);
}

.popover-heading {
  display: grid;
  gap: 0.22rem;
}

.popover-heading p {
  margin: 0;
}

.popover-heading p:not(.rail-label) {
  color: var(--muted);
  font-size: 0.86rem;
}

.action-panel {
  width: 13rem;
}

.popover-action {
  min-height: 2.75rem;
  padding: 0.72rem 0.9rem;
  border: 1px solid #dadad4;
  border-radius: 0.95rem;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.popover-action.primary-action {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.language-panel {
  width: min(24rem, calc(100vw - 2rem));
}

.language-list {
  display: grid;
  gap: 0.55rem;
}

.language-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.78rem 0.85rem;
  border: 1px solid #e4e4de;
  border-radius: 0.95rem;
  background: #fbfbf8;
}

.language-item strong,
.language-item p {
  margin: 0;
}

.language-item p {
  color: var(--muted);
  font-size: 0.84rem;
}

.language-switch {
  min-height: 2.3rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid #d7d7d1;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.language-switch[aria-current="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.language-form {
  display: grid;
  gap: 0.7rem;
}

body[data-app-mode="preview"] [data-edit-only] {
  display: none !important;
}

body[data-app-mode="preview"] .block-row {
  grid-template-columns: minmax(0, 1fr);
}

body[data-app-mode="preview"] .line-block {
  cursor: default;
}

body[data-app-mode="preview"] .line-block:hover,
body[data-app-mode="preview"] .line-block:focus,
body[data-app-mode="preview"] .line-block.is-selected,
body[data-app-mode="preview"] .line-block.is-selected:focus {
  background: transparent;
}

.toolbar {
  padding-bottom: 0.95rem;
  display: grid;
  gap: 0.6rem;
}

.toolbar-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem;
  width: fit-content;
  border: 1px solid #e7e7e2;
  border-radius: 999px;
  background: #fbfbf8;
}

.toolbar-tab {
  min-height: 2.5rem;
  padding: 0.58rem 1rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
}

.toolbar-tab[aria-selected="true"] {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 10px 24px rgba(18, 18, 18, 0.12);
}

.toolbar-tab:focus-visible {
  outline: 2px solid #b9cfff;
  outline-offset: 2px;
}

.toolbar-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.55rem;
  padding: 0.7rem;
  background: var(--soft);
  border-radius: 1rem;
}

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

.settings-strip {
  align-items: center;
}

.field {
  display: grid;
  gap: 0.28rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.field select,
.field input {
  min-height: 2.35rem;
  border-radius: 0.85rem;
  border: 1px solid #ddddda;
  background: #fff;
  color: var(--ink);
  padding: 0.55rem 0.78rem;
}

.field.small-field input {
  width: 5.4rem;
}

.field.color-field input {
  width: 3.2rem;
  padding: 0.18rem;
}

.action-group {
  display: flex;
  gap: 0.4rem;
}

.mini-button {
  min-height: 2.35rem;
  min-width: 2.5rem;
  padding: 0.5rem 0.8rem;
}

.workspace {
  padding-top: 1rem;
  padding-bottom: 3rem;
  width: 100%;
  max-width: none;
  padding-left: 1rem;
  padding-right: 1rem;
  position: relative;
}

.editor-rail {
  position: fixed;
  top: 12rem;
  left: max(1rem, calc(50vw - (var(--page-width-px) / 2) - 13.2rem));
  width: 12rem;
  display: flex;
  align-items: flex-start;
  color: var(--muted);
  font-size: 0.84rem;
}

.shortcuts-popover {
  position: relative;
}

.shortcuts-toggle {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: 1px solid #d8d8d2;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #404040;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  list-style: none;
  box-shadow: 0 10px 24px rgba(18, 18, 18, 0.06);
}

.shortcuts-toggle::-webkit-details-marker {
  display: none;
}

.shortcuts-toggle:hover,
.shortcuts-toggle:focus-visible {
  border-color: #bfc9da;
  background: #f7faff;
  outline: none;
}

.shortcuts-popover[open] .shortcuts-toggle {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.shortcuts-panel {
  position: absolute;
  top: calc(100% + 0.6rem);
  left: 0;
  z-index: 10;
  display: grid;
  gap: 0.28rem;
  width: min(15rem, calc(100vw - 2rem));
  padding: 0.85rem 0.95rem;
  border: 1px solid #e2e2dc;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 50px rgba(18, 18, 18, 0.12);
}

.rail-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #404040;
}

.editor-rail p {
  margin: 0;
}

.page-stack {
  width: var(--page-width-px);
  margin: 0 auto;
  display: grid;
  gap: var(--page-stack-gap);
}

.page-separator {
  display: none;
}

.page-frame {
  width: var(--page-width-px);
  min-height: var(--page-height-px);
  background: var(--paper);
  border: 1px solid #d9d9d4;
}

.page-content {
  height: var(--content-height-px);
  margin-top: var(--margin-top-mm);
  margin-right: var(--margin-right-mm);
  margin-bottom: var(--margin-bottom-mm);
  margin-left: var(--margin-left-mm);
  display: grid;
  align-content: start;
  gap: 0.04rem;
  overflow: hidden;
}

.block-row {
  display: grid;
  grid-template-columns: 1.15rem minmax(0, 1fr);
  gap: 0.45rem;
  align-items: start;
  border-radius: 0.45rem;
}

.block-row.experience-title-row {
  margin-top: 0.36rem;
}

.block-row.dragging {
  opacity: 0.48;
}

.block-row.drop-before {
  border-top: 2px solid #b9cfff;
}

.block-row.drop-after {
  border-bottom: 2px solid #b9cfff;
}

.drag-handle {
  border: 0;
  background: transparent;
  color: #9b9b95;
  cursor: grab;
  padding: 0.28rem 0 0;
  font-size: 14px;
  line-height: 14px;
  user-select: none;
}

body[data-app-mode="preview"] .drag-handle {
  display: none;
}

body[data-app-mode="preview"] .block-row {
  grid-template-columns: minmax(0, 1fr);
}

.line-block,
.rule-block {
  width: 100%;
}

.line-block {
  min-height: 1.55rem;
  padding: 0.12rem 0.18rem;
  border-radius: 0.45rem;
  outline: none;
  font-size: 16px;
  white-space: pre-wrap;
  tab-size: 4;
  line-height: 1.48;
  transition: background-color 140ms ease;
}

.line-block:hover {
  background: #f8f8f6;
}

.line-block:focus {
  background: var(--focus);
}

.line-block.is-selected {
  background: #dce8ff;
}

.line-block.is-selected:focus {
  background: #d0e0ff;
}

.line-block[data-variant="title"] {
  padding-left: 0;
  padding-right: 0;
  font-size: 2.9rem;
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.06em;
}

.line-block[data-variant="subtitle"] {
  padding-left: 0;
  padding-right: 0;
  color: #3f3f3f;
  font-size: 1.26rem;
  line-height: 1.35;
}

.line-block.experience-title-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 0.9rem;
}

.line-block.experience-title-line .experience-title-main {
  min-width: 0;
}

.line-block.experience-title-line .experience-title-date {
  white-space: nowrap;
  justify-self: end;
}

.line-block[data-variant="meta"],
.line-block[data-variant="link"] {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.line-block[data-variant="section"] {
  margin-top: 1.45rem;
  padding-left: 0;
  padding-right: 0;
  font-size: 1.42rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.line-block[data-variant="subtle"] {
  color: #575757;
}

.line-block[data-variant="body"],
.line-block[data-variant="subtle"] {
  line-height: 1.52;
}

.line-block[data-variant="bullet"] {
  position: relative;
  padding-left: 1.25rem;
}

.line-block[data-variant="bullet"]::before {
  content: "•";
  position: absolute;
  left: 0.28rem;
  color: var(--muted);
}

.line-block[data-variant="quote"] {
  padding-left: 1rem;
  border-left: 3px solid #d7d7d2;
  color: #474747;
}

.rule-block {
  padding: 0.32rem 0 0.1rem;
}

.rule-block hr {
  margin: 0;
  border: 0;
  border-top: 1px solid #d9d9d4;
}

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

  .editor-rail {
    position: static;
    padding-bottom: 0.4rem;
  }

  .shortcuts-panel {
    left: 0;
  }
}

@media (max-width: 900px) {
  .app-bar {
    display: grid;
  }

  .status-cluster {
    justify-content: flex-start;
  }

  .header-popover-panel {
    right: auto;
    left: 0;
  }

  .toolbar-tabs {
    width: 100%;
    justify-content: stretch;
  }

  .toolbar-tab {
    flex: 1 1 0;
    text-align: center;
  }

  .page-frame {
    width: 100%;
    min-height: auto;
  }

  .page-content {
    height: auto;
    min-height: calc(var(--content-height-px) * 0.6);
  }

  .line-block[data-variant="title"] {
    font-size: 2.2rem;
  }
}

@media print {
  .app-shell,
  .editor-rail,
  .page-separator,
  .drag-handle {
    display: none;
  }

  .workspace {
    width: 100%;
    display: block;
    padding: 0;
  }

  .page-stack {
    gap: 0;
  }

  .editor-page {
    page-break-after: always;
  }

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

  .page-frame,
  .page-content {
    width: auto;
    min-height: 0;
    height: auto;
    margin: 0;
  }

  .page-frame {
    border: 0;
  }
}
