:root {
  color-scheme: light;
  --paper: #efe6d4;
  --sheet: #fbf7ee;
  --ink: #1c1915;
  --muted: #5e574c;
  --line: #ddcfb4;
  --spruce: #234237;
  --spruce-deep: #163028;
  --brass: #8a5e2a;
  --alert: #7d2e24;
  --alert-bg: #f6e0d6;
  --todo: #d92b2b;
  --done: #1d6fd8;
  --cream: #f3ecdf;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(35, 66, 55, 0.14) 0 14px, transparent 14px),
    var(--paper);
  font-family: "Liberation Sans", "Nimbus Sans", "DejaVu Sans", sans-serif;
  font-size: 1.05rem;
  line-height: 1.5;
}

h1,
h2,
.brand strong,
.auth-card h1 {
  font-family: "Liberation Serif", "Nimbus Roman", "DejaVu Serif", Palatino, Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h1 {
  margin: 0.15rem 0 0;
  font-size: 2.05rem;
  line-height: 1.15;
}

h2 {
  margin: 0;
  font-size: 1.4rem;
}

h3 {
  margin: 0.85rem 0 0.15rem;
  font-family: "Liberation Sans", "Nimbus Sans", sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

p {
  margin: 0.35rem 0 0;
}

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

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

.skip {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  background: white;
  padding: 0.4rem 0.6rem;
  z-index: 3;
}

.skip:focus {
  left: 0.5rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1.25rem 0.8rem 1.7rem;
  background: var(--spruce-deep);
  color: var(--cream);
}

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

.topbar a:hover {
  text-decoration: underline;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  font-family: "Liberation Sans", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.68rem;
  opacity: 0.75;
}

.mark {
  display: block;
  width: 2.4rem;
  height: 2.4rem;
}

.brand:hover {
  text-decoration: none;
}

.brand:hover strong {
  text-decoration: underline;
}

.app-menu {
  position: relative;
}

.app-menu details {
  position: relative;
}

.app-menu summary {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  list-style: none;
  color: var(--cream);
  border: 1px solid rgba(243, 236, 223, 0.45);
  border-radius: 0.45rem;
  cursor: pointer;
}

.app-menu summary::-webkit-details-marker,
.app-menu summary::marker {
  display: none;
  content: "";
}

.app-menu summary:hover,
.app-menu details[open] summary {
  background: rgba(243, 236, 223, 0.14);
}

.menu-icon {
  display: block;
  width: 1.05rem;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor;
}

.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 4;
  min-width: 12.5rem;
  padding: 0.85rem 0.9rem 0.55rem;
  background: var(--sheet);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  box-shadow: 0 10px 28px rgba(22, 48, 40, 0.18);
}

.menu-panel .identity {
  margin: 0 0 0.75rem;
  line-height: 1.3;
}

.menu-panel .identity span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.topbar form {
  margin: 0;
}

.lang-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  overflow: hidden;
}

.auth-tools .lang-switch {
  width: 7.5rem;
}

.lang-switch button {
  background: transparent;
  color: var(--ink);
  border: 0;
  border-radius: 0;
  padding: 0.35rem 0.4rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.lang-switch button + button {
  border-left: 1px solid var(--line);
}

.lang-switch button:hover {
  background: var(--cream);
}

.lang-switch button[aria-pressed="true"],
.lang-switch button[aria-pressed="true"]:hover {
  background: var(--spruce);
  color: var(--cream);
}

button.menu-item {
  width: 100%;
  margin-top: 0.55rem;
  padding: 0.6rem 0.1rem 0.25rem;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
}

button.menu-item:hover {
  background: transparent;
  text-decoration: underline;
}

.auth-tools {
  display: flex;
  justify-content: flex-end;
  margin: -0.2rem 0 0.8rem;
}

main {
  width: min(64rem, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

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

.lede,
.quiet,
.signed,
.by,
.who span {
  color: var(--muted);
}

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

.actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.actions form {
  margin: 0;
}

.back {
  margin: 0 0 0.8rem;
}

button,
.button {
  display: inline-block;
  background: var(--spruce);
  color: var(--cream);
  border: 1px solid var(--spruce);
  border-radius: 2px;
  padding: 0.5rem 0.85rem;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--spruce-deep);
}

button.danger {
  background: transparent;
  color: var(--alert);
  border-color: var(--alert);
}

button.danger:hover {
  background: var(--alert-bg);
}

button.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  text-decoration: underline;
}

button.linkish:hover {
  background: none;
}

.search {
  display: flex;
  align-items: end;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.search .field {
  flex: 1;
  margin: 0;
}

.field {
  margin-bottom: 0.9rem;
}

.field.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.field.check input {
  width: auto;
}

.field.check label {
  margin: 0;
}

.field label,
.search label {
  display: block;
  margin-bottom: 0.3rem;
}

input,
textarea,
select {
  width: 100%;
  background: white;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.55rem 0.65rem;
}

textarea {
  resize: vertical;
}

.field-error {
  margin: 0.3rem 0 0;
  color: var(--alert);
  font-size: 0.92rem;
}

.banner {
  background: var(--alert-bg);
  color: var(--alert);
  padding: 0.7rem 0.85rem;
  margin: 0 0 1rem;
}

.sheet-form,
.auth-card,
.roster,
.chart {
  background: var(--sheet);
  border: 1px solid var(--line);
}

.sheet-form,
.auth-card {
  padding: 1.2rem 1.25rem 1.3rem;
  max-width: 36rem;
}

.auth-card {
  margin: 8vh auto;
}

.auth-card h1 {
  font-size: 2.2rem;
}

.form-actions {
  margin-top: 0.4rem;
}

.roster {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 1.75rem;
}

.roster li {
  border-bottom: 1px solid var(--line);
}

.roster li:last-child {
  border-bottom: 0;
}

.roster a,
.roster .who {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.roster a {
  color: inherit;
  text-decoration: none;
  padding: 0.9rem 1rem;
}

.roster .who {
  display: block;
  padding: 0.9rem 1rem;
}

.roster a .who {
  padding: 0;
}

.roster a:hover strong {
  text-decoration: underline;
}

.who span {
  display: block;
}

.chip {
  flex: none;
  color: var(--alert);
  background: var(--alert-bg);
  padding: 0.15rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.empty {
  color: var(--muted);
  padding: 0.4rem 0 0.2rem;
}

.chart {
  padding: 1.3rem 1.35rem 0.6rem;
}

.allergy {
  margin-top: 1.1rem;
  background: var(--alert-bg);
  color: var(--alert);
  border-left: 4px solid var(--alert);
  padding: 0.75rem 0.9rem;
}

.allergy strong {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.allergy p,
.quiet {
  margin-top: 0.2rem;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem 1.5rem;
  margin: 1.1rem 0 0;
}

.facts div {
  margin: 0;
}

.facts dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.facts dd {
  margin: 0.15rem 0 0;
}

.flags .on {
  font-weight: 700;
}

.chart section {
  margin-top: 1.4rem;
}

.visits .page-head {
  align-items: center;
  margin-bottom: 0.4rem;
}

.visit-table-wrap {
  overflow-x: auto;
  margin-top: 0.4rem;
}

.visit-table {
  width: 100%;
  min-width: 42rem;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.visit-table th,
.visit-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--line);
}

.visit-table thead th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.visit-table tbody th {
  font-weight: 600;
  white-space: nowrap;
}

.by {
  display: block;
  margin: 0.15rem 0 0;
  font-weight: 400;
  font-size: 0.8rem;
}

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

.prose {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.text-link {
  color: var(--spruce);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.odontogram {
  margin-top: 0.75rem;
  overflow-x: auto;
}

.odontogram-inner {
  min-width: 50rem;
}

.arch-labels,
.arch {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  column-gap: 0.7rem;
}

.arch-labels {
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.arch-labels span:last-child {
  text-align: right;
}

.arch-name {
  margin: 0.55rem 0 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.quad {
  display: flex;
  justify-content: center;
  gap: 0.18rem;
}

.midline {
  background: var(--line);
}

.tooth {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 2.7rem;
  gap: 0.1rem;
  color: inherit;
  text-decoration: none;
}

.tooth .face-svg {
  width: 2.2rem;
  height: 2.2rem;
  display: block;
}

.tooth .num {
  font-size: 0.68rem;
  letter-spacing: -0.03em;
  color: var(--muted);
}

.tooth-gap {
  width: 2.7rem;
  flex: 0 0 2.7rem;
}

.arch.primary .tooth .face-svg {
  width: 1.7rem;
  height: 1.7rem;
}

.face-svg .region {
  fill: white;
  stroke: var(--ink);
  stroke-width: 1.5px;
  vector-effect: non-scaling-stroke;
}

.face-svg .region.todo,
.swatch.part-todo {
  fill: var(--todo);
  background: var(--todo);
  stroke: var(--ink);
  border-color: var(--todo);
}

.face-svg .region.done,
.swatch.part-done {
  fill: var(--done);
  background: var(--done);
  stroke: var(--ink);
  border-color: var(--done);
}

.face-editor {
  display: flex;
  justify-content: center;
}

.face-svg-lg {
  width: min(16rem, 100%);
  height: auto;
  margin: 0.7rem 0 1rem;
}

.face-svg a {
  cursor: pointer;
}

.face-svg a.is-selected .region {
  stroke: var(--spruce-deep);
  stroke-width: 3px;
}

.face-letter {
  fill: var(--ink);
  font-size: 34px;
  font-weight: 700;
  font-family: "Liberation Sans", "Nimbus Sans", "DejaVu Sans", sans-serif;
  pointer-events: none;
}

.surface-jump {
  color: inherit;
  text-decoration: none;
}

.surface.is-selected,
.surface:target {
  background: var(--cream);
  margin-left: -0.4rem;
  margin-right: -0.4rem;
  padding: 0.45rem 0.4rem 0.75rem;
}

.surfaces {
  border: 0;
  margin: 0.4rem 0 0;
  padding: 0;
}

.surfaces legend {
  font-weight: 700;
  padding: 0;
}

.surface {
  display: grid;
  grid-template-columns: 1fr 9rem;
  gap: 0.35rem 0.75rem;
  align-items: end;
  margin-bottom: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.surface h3 {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 1rem;
}

.surface .detail {
  grid-column: 1 / -1;
}

.surface .field,
.surface .done-by {
  margin: 0;
}

.surface .mine {
  grid-column: 1 / -1;
}

.done-by {
  color: var(--spruce-deep);
  font-size: 0.92rem;
}

.tooth:hover .region,
.tooth:focus-visible .region {
  stroke: var(--brass);
}

.tooth.caries .face-svg {
  outline: 2px solid var(--alert);
  outline-offset: 1px;
}

.swatch.caries {
  background: var(--alert-bg);
  border-color: var(--alert);
}

.tooth.restoration .face-svg {
  outline: 2px solid var(--spruce);
  outline-offset: 1px;
}

.swatch.restoration {
  background: #e5f0ea;
  border-color: var(--spruce);
}

.tooth.missing .region {
  stroke-dasharray: 16 12;
}

.swatch.missing {
  background: transparent;
  border-style: dashed;
  border-color: var(--muted);
}

.tooth.missing .num {
  text-decoration: line-through;
}

.tooth.crown .face-svg {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
}

.swatch.crown {
  background: #f4e7c8;
  border-color: var(--brass);
}

.tooth.root_canal .face-svg {
  outline: 2px solid var(--spruce-deep);
  outline-offset: 1px;
}

.swatch.root_canal {
  background: #dbe7e2;
  border-color: var(--spruce-deep);
}

.tooth.implant .face-svg {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.swatch.implant {
  background: #eceae4;
  border-color: var(--ink);
}

.tooth.fracture .face-svg {
  outline: 2px solid var(--alert);
  outline-offset: 1px;
}

.swatch.fracture {
  border-color: var(--alert);
  background:
    linear-gradient(135deg, transparent 46%, var(--alert) 46% 54%, transparent 54%),
    white;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  list-style: none;
  padding: 0.8rem 0 0;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.swatch {
  width: 0.75rem;
  height: 0.75rem;
  border: 1.5px solid var(--ink);
  background: white;
}

@media (max-width: 640px) {
  .page-head,
  .search {
    flex-direction: column;
    align-items: flex-start;
  }

  main {
    width: min(64rem, calc(100% - 1.5rem));
  }

  .actions {
    width: 100%;
  }
}

@media print {
  body {
    background: white;
  }

  .topbar,
  .no-print {
    display: none !important;
  }

  .chart,
  .roster,
  .sheet-form {
    border: 0;
  }
}
