/*
 * Softaware taskpane theme: warm document-like workspace, deep teal brand,
 * persistent rail navigation, and pill controls. The stylesheet intentionally
 * styles both custom shell markup and remaining Fluent primitives so migrated
 * panels share one visual system while their existing behavior stays intact.
 */

@font-face {
  font-family: "Roboto";
  src: url("/assets/fonts/Roboto-VariableFont_wdth,wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Roboto";
  src: url("/assets/fonts/Roboto-Italic-VariableFont_wdth,wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

:root {
  --page-bg: #f9f6ee;
  --surface: #ffffff;
  --surface-soft: #eef5f4;
  --surface-muted: #e8efef;
  --paper: #fbfaf4;
  --ink: #161d1d;
  --ink-soft: #414849;
  --ink-muted: #717879;
  --brand: #00282c;
  --brand-strong: #001a1e;
  --brand-soft: #c0eaf0;
  --brand-wash: rgba(0, 40, 44, 0.06);
  --teal: #0f766e;
  --border: #c0c8c9;
  --border-soft: #d7d9d4;
  --success: #15803d;
  --warning: #b45309;
  --warning-soft: #fff7db;
  --error: #ba1a1a;
  --error-soft: #ffdad6;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow-soft: 0 12px 28px rgba(0, 40, 44, 0.08);
  --focus-ring: 0 0 0 3px rgba(15, 118, 110, 0.22);
  --font-sans: "Roboto", "Segoe UI", sans-serif;
  --font-serif: "Libre Caslon Text", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(249, 246, 238, 0.92);
}

.spinner {
  width: 2.25rem;
  height: 2.25rem;
  border: 0.24rem solid rgba(0, 40, 44, 0.16);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

body,
div,
section,
main,
header,
p,
span,
button,
label {
  min-width: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 40, 44, 0.04);
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 40, 44, 0.25);
  border-radius: var(--radius-pill);
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  min-width: 320px;
  background: var(--page-bg);
}

.app-header {
  min-height: 4.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.app-header__brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 0.75rem;
}

.app-header__mark {
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), #a4ced4);
  color: #ffffff;
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
}

.app-header__title,
.content-shell__title,
.panel-heading,
.fui-Subtitle2,
.fui-Body1Strong {
  font-family: var(--font-serif);
}

.app-header__title {
  min-width: 0;
  color: var(--brand);
  font-size: clamp(1.05rem, 2.4vw, 1.45rem);
  font-weight: 800;
  line-height: 1.08;
  overflow-wrap: anywhere;
  white-space: normal;
}

.app-header__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.5rem;
}

.header-pill {
  min-height: 2rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.25rem 0.75rem;
  background: var(--surface-soft);
  color: var(--ink-muted);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.header-pill:focus-visible,
.side-rail__item:focus-visible,
.control-button:focus-visible,
.segmented-control__option:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.header-pill--quota {
  border-color: rgba(15, 118, 110, 0.18);
  color: var(--teal);
}

.header-pill__dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: currentColor;
}

.quota-tooltip {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.25rem;
}

.app-shell__body {
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(6.75rem, 10vw, 7.75rem) minmax(0, 1fr);
  overflow: hidden;
}

.side-rail {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.side-rail__top,
.side-rail__bottom {
  display: flex;
  flex-direction: column;
}

.side-rail__top {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0.4rem 0.6rem;
  gap: 0.35rem;
}

.side-rail__bottom {
  border-top: 1px solid var(--border);
  padding: 0.6rem 0.4rem;
}

.side-rail__item {
  width: 100%;
  min-height: 3.55rem;
  border: 0;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  background: transparent;
  color: var(--ink-muted);
  text-align: center;
}

.side-rail__item:hover {
  color: var(--brand);
  background: var(--brand-wash);
}

.side-rail__item--active {
  color: var(--brand);
  font-weight: 900;
}

.side-rail__item--active .side-rail__icon-wrap {
  background: var(--brand);
  color: #ffffff;
}

.side-rail__icon-wrap {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.75rem;
  display: grid;
  place-items: center;
  color: currentColor;
}

.side-rail__icon,
.content-shell__icon {
  width: 1.15rem;
  height: 1.15rem;
}

.side-rail__label {
  width: 100%;
  overflow: hidden;
  text-overflow: clip;
  font-size: 0.72rem;
  line-height: 1.05;
  white-space: nowrap;
}

.content-shell {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--page-bg);
  overflow: hidden;
}

.content-shell__header {
  min-height: 3.1rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--brand);
}

.content-shell__title {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  line-height: 1.05;
  font-weight: 900;
}

.content-shell__body {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
}

.panel-stack,
.panel-section,
.panel-card,
.status-card {
  display: flex;
  flex-direction: column;
}

.panel-stack {
  gap: 0.9rem;
}

.panel-section {
  gap: 1rem;
}

.panel-card,
.status-card,
.fui-Card {
  max-width: 100%;
  border: 1px solid var(--border-soft) !important;
  border-radius: var(--radius-lg) !important;
  background: var(--paper) !important;
  color: var(--ink) !important;
  box-shadow: none !important;
}

.panel-card {
  padding: 0.8rem;
  gap: 0.6rem;
}

.info-card {
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: normal;
}

.status-card {
  padding: 0.7rem 0.8rem !important;
  color: var(--ink-soft) !important;
  overflow-wrap: anywhere !important;
  white-space: normal !important;
}

.status-card--warning {
  background: var(--warning-soft) !important;
  border-color: rgba(180, 83, 9, 0.22) !important;
  color: var(--warning) !important;
}

.rule-summary-card {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.rule-summary-card__text {
  min-width: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.rule-summary-card__count {
  flex: 0 0 auto;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: var(--radius-pill);
  padding: 0.25rem 0.65rem;
  background: var(--surface-soft);
  color: var(--teal);
  font-weight: 900;
  white-space: nowrap;
}

.segmented-control {
  min-height: 2.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.25rem;
  padding: 0.25rem;
  border: 0;
  border-radius: 1.1rem;
  background: var(--surface-muted);
}

.segmented-control__option {
  border: 0;
  border-radius: 0.9rem;
  display: grid;
  place-items: center;
  padding: 0.45rem 0.4rem;
  background: transparent;
  color: var(--ink-muted);
  font-weight: 900;
  font-size: 0.84rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-align: center;
  min-width: 0;
}

.segmented-control__option--active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--shadow-soft);
}

.actions-stack,
.actions-row {
  display: flex;
  gap: 0.6rem;
}

.actions-stack {
  flex-direction: column;
}

.actions-row {
  flex-wrap: wrap;
  align-items: center;
}

.control-button,
.fui-Button {
  min-height: 2.45rem !important;
  border-radius: var(--radius-pill) !important;
  border: 2px solid var(--brand) !important;
  padding: 0.45rem 0.85rem !important;
  font-weight: 900 !important;
  font-size: 0.86rem !important;
  line-height: 1.15 !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.control-button--primary,
.fui-Button[data-appearance="primary"],
.fui-Button.fui-Button {
  --colorNeutralForegroundOnBrand: #ffffff;
  --colorBrandBackground: var(--brand);
  --colorBrandBackgroundHover: var(--brand-strong);
  --colorBrandBackgroundPressed: var(--brand-strong);
  --colorBrandForeground1: var(--brand);
  --colorBrandStroke1: var(--brand);
}

.control-button--primary,
.fui-Button[data-appearance="primary"] {
  background: var(--brand) !important;
  color: #ffffff !important;
}

.control-button--primary:hover,
.fui-Button[data-appearance="primary"]:hover {
  background: var(--brand-strong) !important;
  border-color: var(--brand-strong) !important;
}

.control-button--secondary,
.fui-Button[data-appearance="secondary"],
.fui-Button[data-appearance="outline"] {
  background: transparent !important;
  color: var(--brand) !important;
}

.control-button--subtle,
.fui-Button[data-appearance="subtle"],
.fui-Button[data-appearance="transparent"] {
  border-color: transparent !important;
  background: transparent !important;
  color: var(--brand) !important;
}

.account-card {
  gap: 1rem !important;
}

.account-token-strip {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  gap: 0.45rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(3, 51, 56, 0.04);
}

.account-token-strip__value {
  min-width: 0;
  overflow: hidden;
  color: var(--brand);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-action-section {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.account-link-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem;
}

.account-link-button.fui-Button {
  justify-content: flex-start !important;
  min-height: 2rem !important;
  border: 0 !important;
  border-radius: var(--radius-md) !important;
  padding: 0.25rem 0.35rem !important;
  color: var(--brand) !important;
  font-size: 0.82rem !important;
  font-weight: 800 !important;
  text-align: left !important;
}

.account-link-button.fui-Button:hover {
  background: rgba(3, 51, 56, 0.07) !important;
}

.account-session-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.6rem;
  padding-top: 0.1rem;
}

.account-session-button.fui-Button {
  width: 100%;
  min-height: 2.35rem !important;
}

.account-session-button--danger.fui-Button {
  color: #8a2f2f !important;
  border-color: #d8b7b7 !important;
}

.account-session-button--danger.fui-Button:hover {
  background: #fff5f5 !important;
  border-color: #bf8f8f !important;
}

.progress-line,
.fui-ProgressBar {
  overflow: hidden;
  border-radius: var(--radius-pill) !important;
}

.progress-line {
  height: 0.55rem;
  background: var(--surface-muted);
}

.progress-line__bar {
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.helper-text,
.muted-text,
.fui-Caption1,
.fui-Text {
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: normal;
}

.fui-MessageBar,
.fui-MessageBarBody,
.fui-MessageBarBody__body,
.fui-MessageBarBody__text {
  max-width: 100% !important;
  min-width: 0 !important;
  overflow-wrap: anywhere !important;
  white-space: normal !important;
}

.fui-MessageBar {
  overflow: hidden !important;
}

.muted-text,
.fui-Caption1 {
  color: var(--ink-muted) !important;
}

.fui-Input,
.fui-Select,
.fui-Textarea,
input,
select,
textarea {
  border-radius: var(--radius-md) !important;
}

.sentence-context {
  display: block;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  background: var(--surface);
  color: var(--ink-soft);
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: normal;
}

.sentence-token {
  border-radius: 0.4rem;
  padding: 0.05rem 0.25rem;
}

.sentence-token--before,
.repetition-highlight {
  background: var(--error-soft);
  color: var(--error);
}

.sentence-token--after {
  background: #e3f8ea;
  color: var(--success);
}

.sentence-arrow {
  margin: 0 0.35rem;
  color: var(--ink-muted);
}

.repetition-highlight {
  border-radius: 0.35rem;
  padding: 0 0.25rem;
}

.collapsible-section {
  display: flex;
  flex-direction: column;
}

.collapsible-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 2rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--ink-soft);
  line-height: 1.15;
  user-select: none;
}

.collapsible-section__header:hover {
  background: var(--brand-wash);
}

.collapsible-section__title {
  min-width: 0;
  overflow-wrap: anywhere;
}

.collapsible-section__chevron {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  transition: transform 0.18s ease;
  color: var(--ink-muted);
  /* The chevron glyph points right; point it down when collapsed, up when open. */
  transform: rotate(90deg);
}

.collapsible-section__chevron--open {
  transform: rotate(-90deg);
}

.collapsible-section__body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 0.75rem;
}

@media (max-width: 420px) {
  .app-header {
    min-height: 3.75rem;
    padding: 0.5rem 0.65rem;
  }

  .app-header__mark {
    width: 2rem;
    height: 2rem;
    font-size: 1.25rem;
  }

  .app-header__title {
    font-size: 1rem;
  }

  .app-shell__body {
    grid-template-columns: 6.75rem minmax(0, 1fr);
  }

  .side-rail__top,
  .side-rail__bottom {
    padding-left: 0.35rem;
    padding-right: 0.35rem;
  }

  .side-rail__item {
    min-height: 3.35rem;
  }

  .side-rail__icon-wrap {
    width: 2.05rem;
    height: 2.05rem;
    border-radius: 0.7rem;
  }

  .side-rail__label {
    font-size: 0.68rem;
  }

  .content-shell__header {
    min-height: 3rem;
    padding: 0.5rem 0.75rem;
  }

  .content-shell__title {
    font-size: 1.18rem;
  }

  .content-shell__body {
    padding: 0.75rem;
  }

  .segmented-control {
    min-height: 3.1rem;
  }
}
