:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  color: #222426;
  background: #f5f3ee;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
}

.app-shell {
  min-height: 100vh;
  padding: 32px;
}

.panel {
  width: min(1080px, 100%);
  margin: 0 auto;
  background: #fffdfa;
  border: 1px solid #ddd8cd;
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(42, 38, 31, 0.08);
}

.title-row,
.actions,
.download-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 4px;
  color: #746d60;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: #242a2e;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.1rem;
}

.status-pill {
  border: 1px solid #bdc7bd;
  border-radius: 999px;
  padding: 7px 12px;
  background: #eef5ee;
  color: #35513d;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}

.output-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.auth-panel {
  position: relative;
  display: block;
}

.auth-summary {
  margin: 8px 0 0;
  color: #505c54;
}

.account-tab {
  padding: 7px 12px;
  border: 1px solid #bdd1c1;
  border-radius: 999px;
  color: #2f5f51;
  background: #edf6ef;
  font-size: 0.88rem;
}

.account-tab.is-signed-in {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  display: grid;
  width: min(420px, calc(100vw - 64px));
  gap: 14px;
  padding: 16px;
  border: 1px solid #d7ddd6;
  border-radius: 8px;
  background: #fffdfa;
  box-shadow: 0 18px 50px rgba(42, 38, 31, 0.16);
  white-space: normal;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.compact-confirmation {
  display: grid;
  justify-items: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid #d6dfd6;
  border-radius: 6px;
  background: #ffffff;
}

.compact-confirmation p {
  margin: 0;
  color: #47534b;
  font-weight: 700;
}

.auth-actions,
.signed-in-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#auth-message {
  min-height: 1.4em;
  margin: 0;
  color: #47534b;
  font-weight: 700;
}

.signed-in-panel {
  justify-content: space-between;
  padding: 12px;
  border: 1px solid #d6dfd6;
  border-radius: 6px;
  background: #ffffff;
}

#signed-in-user {
  overflow-wrap: anywhere;
  color: #24302a;
  font-weight: 800;
}

.saved-panel {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid #e2ded5;
  border-radius: 8px;
  background: #fffefa;
}

.saved-header,
.saved-controls,
.saved-document,
.saved-actions,
.saved-primary-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.saved-header,
.saved-document {
  justify-content: space-between;
}

.saved-controls {
  flex-wrap: wrap;
  margin-top: 14px;
}

.saved-browser {
  margin-top: 14px;
}

.saved-chooser {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.saved-primary-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.saved-controls input[type="search"] {
  max-width: 420px;
}

.saved-controls select {
  width: auto;
  min-width: 160px;
}

.admin-tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e1d7;
}

.admin-tab {
  padding: 8px 12px;
  border: 1px solid #d5d0c4;
  color: #46504a;
  background: #f7f4ee;
}

.admin-tab.is-active {
  border-color: #bdd1c1;
  color: #2f5f51;
  background: #edf6ef;
}

.admin-section {
  margin-top: 18px;
}

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.admin-stat {
  padding: 14px;
  border: 1px solid #e2ded5;
  border-radius: 6px;
  background: #fffefa;
}

.admin-stat strong {
  display: block;
  color: #242a2e;
  font-size: 1.8rem;
  line-height: 1.1;
}

.admin-stat span {
  color: #655f55;
  font-weight: 700;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

#activity-panel .admin-grid {
  grid-template-columns: 1fr;
}

.admin-card {
  min-width: 0;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.admin-detail {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid #d7ddd6;
  border-radius: 8px;
  background: #f8fbf8;
}

.admin-detail-body {
  display: grid;
  gap: 14px;
}

.admin-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.admin-detail-grid div {
  min-width: 0;
  padding-top: 8px;
  border-top: 1px solid #dbe1d9;
}

.admin-detail-grid dt {
  color: #746d60;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-detail-grid dd {
  margin: 3px 0 0;
  color: #283033;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.admin-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  color: #283033;
  font-size: 0.92rem;
}

.admin-table th,
.admin-table td {
  padding: 10px 9px;
  border-top: 1px solid #e5e1d7;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: #746d60;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-table td {
  font-weight: 650;
  overflow-wrap: anywhere;
  word-break: normal;
}

.admin-table small {
  display: block;
  margin-top: 2px;
  color: #655f55;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.event-table th:nth-child(2),
.event-table td:nth-child(2) {
  width: 116px;
}

.event-table th:nth-child(3),
.event-table td:nth-child(3) {
  width: 170px;
}

.event-table th:nth-child(4),
.event-table td:nth-child(4) {
  width: 150px;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover,
.clickable-row.is-selected {
  background: #f2f7f1;
}

.saved-documents {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.saved-more {
  margin-top: 12px;
}

.draft-library {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.coverage-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #dec6a6;
  border-radius: 6px;
  background: #fff8eb;
}

.library-entry {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid #d8d2c5;
  border-radius: 6px;
  background: #ffffff;
}

.library-entry-header,
.chip-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.library-entry-header {
  justify-content: space-between;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.library-entry h3 {
  margin: 0 0 8px;
  color: #3a403f;
  font-size: 0.95rem;
}

.library-entry p {
  margin: 0;
  color: #4f554f;
}

.library-option {
  display: grid;
  gap: 3px;
  padding: 10px 0;
  border-top: 1px solid #ece7dd;
}

.library-option strong {
  color: #2b3436;
}

.library-option small {
  color: #655f55;
  font-weight: 600;
}

.chip-row {
  flex-wrap: wrap;
}

.warning-chip {
  border-color: #dec6a6;
  color: #6a4a20;
  background: #fff5e6;
}

.saved-count {
  margin: 12px 0 0;
  color: #655f55;
  font-weight: 700;
}

.saved-document {
  padding: 12px;
  border: 1px solid #d8d2c5;
  border-radius: 6px;
  background: #ffffff;
}

.saved-document div:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.saved-meta {
  display: grid;
  grid-template-columns: minmax(120px, 160px) minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-top: 8px;
}

.saved-details {
  margin-top: 6px;
}

.saved-details summary {
  width: max-content;
  color: #2f5f51;
  font-weight: 800;
  cursor: pointer;
}

.saved-meta label {
  gap: 4px;
  color: #655f55;
  font-size: 0.82rem;
}

.saved-meta input,
.saved-meta select {
  padding: 8px 9px;
}

.saved-document strong,
.saved-document span,
.saved-document small {
  overflow-wrap: anywhere;
}

.saved-document span,
.saved-document small,
.muted {
  color: #655f55;
  font-weight: 600;
}

.saved-actions {
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.saved-actions .secondary,
.saved-meta .secondary,
.saved-header .secondary,
.saved-controls .secondary,
.saved-primary-actions .secondary {
  margin-top: 0;
}

.saved-file-note {
  white-space: nowrap;
}

.saved-document.is-archived {
  opacity: 0.72;
  background: #f8f5ee;
}

.archive-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border: 1px solid #d5d0c4;
  border-radius: 999px;
  color: #655f55;
  background: #f4f1ea;
  font-size: 0.72rem;
  font-weight: 800;
}

.version-badge {
  display: inline-block;
  margin: 0 4px;
  padding: 2px 6px;
  border: 1px solid #bdd1c1;
  border-radius: 999px;
  color: #31503b;
  background: #edf6ef;
  font-size: 0.72rem;
  font-weight: 800;
}

.version-badge.warning {
  border-color: #dec6a6;
  color: #6a4a20;
  background: #fff5e6;
}

.saved-actions a,
.saved-actions .link-button {
  color: #2f5f51;
  font-weight: 800;
}

.inline-toggle {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.inline-toggle input {
  width: 18px;
  height: 18px;
}

.compact-button {
  padding: 8px 11px;
  font-size: 0.9rem;
}

.editing-banner {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #bdd1c1;
  border-radius: 6px;
  color: #31503b;
  background: #edf6ef;
  font-weight: 800;
}

.status-item {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border: 1px solid #d5d0c4;
  border-radius: 999px;
  padding: 6px 10px;
  color: #514b43;
  background: #f4f1ea;
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: normal;
}

.status-item.ready {
  border-color: #bdd1c1;
  color: #31503b;
  background: #edf6ef;
}

.status-item.warning {
  border-color: #dec6a6;
  color: #6a4a20;
  background: #fff5e6;
}

form {
  display: grid;
  gap: 22px;
  margin-top: 28px;
}

fieldset {
  margin: 0;
  padding: 20px;
  border: 1px solid #e2ded5;
  border-radius: 8px;
}

legend {
  padding: 0 8px;
  color: #394247;
  font-weight: 800;
}

label,
.stack {
  display: grid;
  gap: 8px;
}

label {
  color: #3d4142;
  font-weight: 700;
}

.grid-two,
.builder-grid,
.helper-grid {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.builder-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 0;
  margin-bottom: 14px;
}

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

.helper-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfc8bb;
  border-radius: 6px;
  padding: 11px 12px;
  color: #1f2427;
  background: #ffffff;
  font: inherit;
  font-weight: 500;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid #d9eadf;
  border-color: #6c9778;
}

.toggle {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
}

.toggle input {
  width: 18px;
  height: 18px;
}

.option-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.choice {
  display: flex;
  grid-template-columns: none;
  align-items: flex-start;
  gap: 10px;
  padding: 13px;
  border: 1px solid #d8d2c5;
  border-radius: 6px;
  background: #fff;
}

.choice input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.choice small {
  display: block;
  margin-top: 2px;
  color: #655f55;
  font-weight: 600;
}

.participant-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.remove-participant {
  margin-top: 0;
  margin-bottom: 0;
}

button,
.download-button {
  border: 0;
  border-radius: 6px;
  padding: 12px 16px;
  color: #fff;
  background: #2f5f51;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.secondary {
  margin-top: 14px;
  color: #2f5f51;
  background: #e8f0ea;
}

.download-button.disabled {
  pointer-events: none;
  color: #776f63;
  background: #e5e0d7;
}

.download-button:disabled {
  color: #776f63;
  background: #e5e0d7;
  cursor: not-allowed;
}

.link-button {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #2f5f51;
  background: transparent;
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
}

#message,
#pdf-note {
  margin: 0;
  color: #625b50;
}

.downloads {
  margin-top: 24px;
  padding: 18px;
  border: 1px solid #d4dfd2;
  border-radius: 8px;
  background: #f4faf4;
}

.download-summary {
  margin: 8px 0 14px;
  color: #4d554f;
  font-weight: 700;
}

.suggestions {
  margin: 16px 0;
  padding: 16px;
  border: 1px solid #d8decd;
  border-radius: 8px;
  background: #f8faf3;
}

.review-panel {
  padding: 18px;
  border: 1px solid #d8decd;
  border-radius: 8px;
  background: #fbfcf7;
}

.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.source-pill.warning {
  border-color: #dec6a6;
  color: #6a4a20;
  background: #fff5e6;
}

.review-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin: 0;
}

.review-list div {
  min-width: 0;
  padding-top: 10px;
  border-top: 1px solid #e5e1d7;
}

.review-list dt {
  color: #746d60;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.review-list dd {
  margin: 3px 0 0;
  color: #283033;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.suggestion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.source-pill {
  border: 1px solid #c8d7c9;
  border-radius: 999px;
  padding: 5px 9px;
  color: #36534a;
  background: #eef5ee;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.suggestion-path {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.suggestion-path li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  color: #38463d;
  background: #f3f7f0;
  border: 1px solid #c9d8c4;
  font-size: 0.86rem;
  font-weight: 800;
}

.suggestion-path span {
  display: inline-grid;
  place-items: center;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  color: #ffffff;
  background: #2f7a4f;
  border-radius: 999px;
  font-size: 0.78rem;
}

.field-note {
  display: block;
  margin-top: 4px;
  color: #6b665d;
  font-size: 0.84rem;
  font-weight: 700;
}

.name-options,
.purpose-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.purpose-options {
  grid-template-columns: 1fr;
}

.description-draft {
  margin: 8px 0 16px;
  color: #4d554f;
  font-weight: 600;
}

.option-help {
  margin: 4px 0 0;
  color: #5d655f;
  font-size: 0.9rem;
  font-weight: 700;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  padding: 6px 9px;
  color: #36534a;
  background: #eef5ee;
  border: 1px solid #c8d7c9;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.name-option,
.purpose-option {
  display: grid;
  gap: 4px;
  padding: 12px;
  text-align: left;
  color: #283033;
  background: #ffffff;
  border: 1px solid #d8d2c5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.name-option:hover,
.purpose-option:hover,
.name-option:focus-visible,
.purpose-option:focus-visible {
  border-color: #8fb59a;
  box-shadow: 0 0 0 3px rgba(83, 132, 96, 0.14);
}

.purpose-option.is-selected {
  border-color: #2f7a4f;
  box-shadow: inset 4px 0 0 #2f7a4f, 0 0 0 3px rgba(47, 122, 79, 0.12);
}

.purpose-option.is-selected::after {
  content: "Selected";
  justify-self: start;
  padding: 3px 8px;
  color: #214a33;
  background: #e8f4ea;
  border: 1px solid #a8cfad;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
}

.name-option span,
.purpose-option span {
  color: #655f55;
  font-size: 0.9rem;
  font-weight: 600;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 16px;
  }

  .panel {
    padding: 18px;
  }

  .title-row,
  .actions,
  .download-row,
  .saved-header,
  .saved-controls,
  .saved-primary-actions,
  .saved-document {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    align-items: flex-start;
    flex-wrap: wrap;
    white-space: normal;
  }

  .auth-popover {
    left: 0;
    right: auto;
    width: min(420px, calc(100vw - 36px));
  }

  .saved-controls input[type="search"],
  .saved-controls select {
    width: 100%;
    max-width: none;
  }

  .grid-two,
  .auth-panel,
  .admin-grid,
  .admin-detail-grid,
  .admin-stat-grid,
  .builder-grid,
  .name-options,
  .suggestion-path,
  .helper-grid,
  .option-group,
  .participant-row,
  .saved-meta,
  .saved-chooser,
  .review-list {
    grid-template-columns: 1fr;
  }
}
