:root {
  --app-bg: #f4f7fc;
  --app-text: #071835;
  --app-border: #d7dfeb;
  --app-surface: #ffffff;
  --app-muted: #5c687a;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  color: var(--app-text);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: var(--app-bg);
}

.container {
  max-width: 1392px;
}

.app-header {
  background: var(--app-surface);
  border-bottom: 1px solid var(--app-border);
}

.app-header__inner {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-brand {
  color: var(--app-text);
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration: none;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-right: auto;
}

.app-nav__link {
  color: var(--app-text);
  text-decoration: none;
  font-weight: 500;
}

.app-nav__link:hover {
  text-decoration: underline;
}

.app-account {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-account__identity {
  max-width: 280px;
  overflow: hidden;
  color: var(--app-muted);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-account form {
  margin: 0;
}

.app-content {
  padding-top: 1.5rem;
  padding-bottom: 2rem;
}

.auth-shell {
  min-height: calc(100vh - 126px);
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.auth-panel {
  width: min(100%, 440px);
  padding: 2rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgb(7 24 53 / 8%);
}

.auth-heading {
  margin-bottom: 1.5rem;
}

.auth-heading h1 {
  margin: 0.35rem 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 700;
}

.auth-heading p {
  margin: 0;
  color: var(--app-muted);
  line-height: 1.5;
}

.auth-kicker {
  color: #225d9c;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.auth-form {
  display: grid;
  gap: 1rem;
}

.auth-form .alert:empty {
  display: none;
}

.auth-switch {
  margin: 1.25rem 0 0;
  color: var(--app-muted);
  text-align: center;
}

.field-validation-error {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.875rem;
}

.password-field {
  position: relative;
}

.password-field__input {
  padding-right: 2.75rem;
}

.password-field__toggle {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: var(--app-muted);
  cursor: pointer;
  transform: translateY(-50%);
}

.password-field__toggle:hover,
.password-field__toggle:focus-visible {
  color: var(--app-text);
}

.password-field__toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 0.2rem rgb(13 110 253 / 25%);
}

.accordion-button {
  font-weight: 600;
}

.accordion-button:not(.collapsed) {
  color: #073763;
  background-color: #cfe2ff;
  box-shadow: none;
}

.accordion-body {
  line-height: 1.55;
}

.document-preview-panel {
  display: flex;
  flex-direction: column;
  min-height: 280px;
  max-height: calc(100vh - 10rem);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  overflow: hidden;
}

.document-preview-panel__empty {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 2rem;
  color: var(--app-muted);
  text-align: center;
}

.document-preview-panel__result {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.document-preview-panel__header {
  flex: 0 0 auto;
  max-height: min(12rem, 35%);
  padding: 1rem 1rem 0.75rem;
  overflow-x: hidden;
  overflow-y: auto;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-surface);
}

.document-preview-panel__header .text-muted,
.document-preview-panel__header #previewSummary {
  font-size: 0.92rem;
  line-height: 1.45;
}

.preview-summary--clamped {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preserve-line-breaks {
  white-space: pre-line;
}

.document-preview-panel__main {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.document-preview-panel__body {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 1rem 1rem;
}

.document-preview-panel__nav {
  display: flex;
  flex: 0 0 160px;
  flex-direction: column;
  gap: 0.15rem;
  width: 160px;
  padding: 0.75rem 0.5rem 1rem;
  overflow-y: auto;
  border-left: 1px solid var(--app-border);
  background: rgba(0, 0, 0, 0.015);
}

.document-preview-panel__nav:empty {
  display: none;
}

.document-preview-panel__nav-link {
  overflow: hidden;
  padding: 0.3rem 0.5rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--app-muted);
  font-size: 0.95rem;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.document-preview-panel__nav-link:hover,
.document-preview-panel__nav-link:focus-visible {
  background: #cfe2ff;
  color: #073763;
  outline: none;
}

@media (max-width: 767.98px) {
  .document-preview-panel__nav {
    display: none;
  }
}

.plan-element-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.plan-element {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--app-border);
}

.plan-element:last-child {
  border-bottom: none;
}

.plan-element__controls select,
.plan-element__controls input {
  width: auto;
  max-width: 160px;
}

.open-items-panel {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: var(--app-surface);
}

.context-notes-panel {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: var(--app-surface);
}

.context-notes-feed {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 220px;
  overflow-y: auto;
  padding: 0.5rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.02);
}

.context-note-bubble {
  align-self: flex-start;
  max-width: 85%;
  background: #fff3cd;
  border: 1px solid #ffe69c;
  border-radius: 12px;
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
}

.context-note-bubble--company-wide {
  background: #cfe2ff;
  border-color: #9ec5fe;
}

.context-note-bubble__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.context-note-bubble__meta {
  font-size: 0.72rem;
  color: var(--app-muted);
}

.context-note-bubble__actions {
  display: flex;
  flex-shrink: 0;
  gap: 0.35rem;
}

.context-notes-input-bar .context-note-scope-toggle .btn {
  font-size: 0.75rem;
  white-space: nowrap;
}

.section-update-highlight {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #0d6efd;
  margin-left: 0.5rem;
  vertical-align: middle;
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
  animation: section-update-pulse 1.4s ease-in-out infinite;
}

@keyframes section-update-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25); }
  50% { box-shadow: 0 0 0 7px rgba(13, 110, 253, 0.05); }
}

.document-builder-form__intro {
  gap: 0.75rem;
}

.document-builder-form__demo-button {
  align-self: flex-start;
  white-space: nowrap;
}

.document-builder-form__inner {
  display: flex;
  flex-direction: column;
}

.document-title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.document-title-row__label {
  flex: 0 0 auto;
  margin-bottom: 0;
  white-space: nowrap;
}

.document-title-row__input {
  flex: 1 1 auto;
  min-width: 0;
}

.document-builder-form__source {
  display: flex;
  flex-direction: column;
}

.document-builder-form__source-header {
  flex-shrink: 0;
  margin-bottom: 0.5rem;
}

.document-builder-form__source-label {
  flex: 0 0 auto;
  margin-bottom: 0;
  white-space: nowrap;
}

.document-builder-form__source .form-control {
  flex: 1 1 auto;
}

.document-builder-form__actions {
  flex-shrink: 0;
}

.toggle-form-panel-button {
  white-space: nowrap;
}

.document-builder-layout.form-collapsed .document-builder-form {
  display: none;
}

.document-builder-layout.form-collapsed .document-builder-preview {
  flex: 0 0 100%;
  max-width: 100%;
}

@media (min-width: 992px) {
  .document-builder-layout > .document-builder-preview {
    position: sticky;
    top: 1.5rem;
    align-self: flex-start;
  }

  .document-builder-layout > .document-builder-form {
    position: sticky;
    top: 1.5rem;
    align-self: flex-start;
    max-height: calc(100vh - 7.5rem);
  }

  .document-builder-form__inner {
    max-height: inherit;
    min-height: 0;
  }

  .document-builder-form__source {
    flex: 1 1 auto;
    min-height: 0;
    margin-bottom: 0.75rem !important;
  }

  .document-builder-form__source .form-control {
    min-height: 7rem;
    resize: vertical;
  }

  .document-preview-panel {
    height: calc(100vh - 7.5rem);
    max-height: calc(100vh - 7.5rem);
  }
}

textarea.form-control {
  min-height: 398px;
}

.generation-progress {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 1rem;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #bfd4ee;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgb(7 24 53 / 9%);
}

.generation-progress__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
}

.generation-progress__title {
  color: var(--app-text);
  font-weight: 700;
}

.generation-progress__step {
  flex: 0 0 auto;
  color: #225d9c;
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
}

.generation-progress__detail {
  min-height: 1.35rem;
  margin-bottom: 0.75rem;
  color: var(--app-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.generation-progress__meter {
  --generation-dot-size: 0.42rem;
  --generation-dot-gap: 0.35rem;
  --generation-dots-width: calc((3 * var(--generation-dot-size)) + (2 * var(--generation-dot-gap)));
}

.generation-progress__track {
  height: 0.65rem;
  overflow: hidden;
  background: #e7eef7;
  border-radius: 999px;
}

.generation-progress__bar {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #0d6efd, #34a853);
  border-radius: inherit;
  transition: width 0.35s ease;
}

.generation-progress__activity {
  position: relative;
  height: var(--generation-dot-size);
  margin-top: 0.4rem;
  overflow: hidden;
}

.generation-progress__activity-track {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  gap: var(--generation-dot-gap);
  width: var(--generation-dots-width);
  animation: generation-progress-dots 1.85s linear infinite;
}

.generation-progress__dot {
  width: var(--generation-dot-size);
  height: var(--generation-dot-size);
  flex: 0 0 auto;
  border-radius: 50%;
  background: #073763;
}

@keyframes generation-progress-dots {
  from {
    left: 0;
  }

  to {
    left: calc(100% - var(--generation-dots-width));
  }
}

@media (prefers-reduced-motion: reduce) {
  .generation-progress__activity-track {
    animation-duration: 3.5s;
  }
}

@media (max-width: 575.98px) {
  .app-header__inner {
    min-height: 56px;
    flex-wrap: wrap;
    gap: 0.55rem 0.75rem;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
  }

  .app-brand {
    order: 1;
  }

  .app-nav {
    order: 3;
    width: 100%;
    gap: 1rem;
  }

  .app-account {
    order: 2;
    margin-left: auto;
    gap: 0.35rem;
  }

  .app-account__identity {
    display: none;
  }

  .app-content {
    padding-top: 1rem;
  }

  .auth-shell {
    min-height: calc(100vh - 104px);
    padding: 1rem 0;
  }

  .auth-panel {
    padding: 1.5rem;
  }
}
