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

:root {
  --color-bg: #f5f5f5;
  --color-surface: #ffffff;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-text: #1a1a1a;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-danger: #dc2626;
  --color-primary-active: #1e3a8a;
  --color-danger-bg: #fef2f2;
  --radius: 6px;
}

/* === Login Page === */

.login-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--color-text);
}

.login-container {
  width: 100%;
  max-width: 360px;
  padding: 2rem;
}

.login-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 2rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
}

.login-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.login-button {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 500;
  color: #fff;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.login-button:hover {
  background: var(--color-primary-hover);
}

.login-button:active {
  background: var(--color-primary-active);
}

/* === Flash Messages === */

.flash-alert,
.flash-notice {
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.5;
  border-left: 3px solid;
  animation: flash-in 0.25s ease-out;
}

.flash-alert {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-left-color: var(--color-danger);
}

.flash-notice {
  background: #f0fdf4;
  color: #166534;
  border-left-color: #16a34a;
}

@keyframes flash-in {
  from {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === App Layout === */

turbo-frame {
  display: block;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
}

body {
  display: flex;
  flex-direction: column;
}

.app-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.app-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* === Header Nav === */

.header-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 1rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.header-nav-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-width: 0;
}

.header-nav-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
}

.header-nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.header-nav-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.header-nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  border-radius: var(--radius);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.header-nav-link:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.header-nav-link:active {
  background: var(--color-border);
}

.header-nav-link--active {
  background: var(--color-bg);
  color: var(--color-primary);
  font-weight: 600;
}

.header-nav-link--active:hover {
  background: var(--color-border);
  color: var(--color-primary);
}

.header-nav-right form.button_to {
  display: contents;
}

/* === Page Container === */

.page-container {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* === Sidebar === */

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  overflow: hidden;
}

.sidebar-header {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.sidebar-conversations {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* === Main Panel === */

.main-panel {
  overflow: hidden;
  min-width: 0;
  background: var(--color-bg);
}

.main-panel > turbo-frame {
  display: block;
  height: 100%;
}

/* === Content Area (Thread + Right Sidebar) === */

.content-area {
  display: grid;
  grid-template-columns: 1fr 340px;
  height: 100%;
  min-height: 0;
}

.content-area .thread {
  overflow-y: auto;
  max-width: none;
  margin: 0;
}

/* === Empty State === */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
  color: var(--color-text-muted);
  gap: 1rem;
}

.empty-state svg {
  opacity: 0.4;
}

.empty-state p {
  margin: 0;
  font-size: 0.9375rem;
}

/* === Conversation List === */

.conversation-list {
  display: flex;
  flex-direction: column;
}

.conversation-item {
  display: block;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background 0.1s ease;
}

.conversation-item:hover {
  background: var(--color-bg);
}

.conversation-item:active {
  background: #e5e7eb;
}

.conversation-item:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.conversation-item--active {
  background: #e8f0fe;
  border-left: 3px solid var(--color-primary);
  padding-left: calc(1.25rem - 3px);
}

.conversation-item--active:hover {
  background: #dae5fc;
}

.conversation-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.conversation-badge {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.4;
  border-radius: 3px;
  text-transform: uppercase;
}

.conversation-badge--email {
  background: #dbeafe;
  color: #1e40af;
}

.conversation-badge--sms {
  background: #dcfce7;
  color: #166534;
}

.conversation-date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.conversation-subject {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.conversation-snippet {
  flex: 1;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-count {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.375rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-radius: 10px;
}

.sidebar-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.sidebar-empty p {
  margin: 0;
}

/* === Sidebar Loading (Infinite Scroll) === */

.sidebar-loading {
  padding: 1rem 1.25rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* === Thread (Conversation Detail) === */

.thread-back {
  display: none;
}

.thread {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}

.thread-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.thread-header-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.thread-message-count {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.thread-subject {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
}

.thread-participants {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.thread-messages {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* === Message Card === */

.message {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.message--owner {
  border-left: 3px solid var(--color-primary);
}

.message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s ease;
}

.message-header:hover {
  background: var(--color-bg);
}

.message-header:active {
  background: #e5e7eb;
}

.message-header-left {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  min-width: 0;
}

.message-sender {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

.message-date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.message-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.message-service {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.message-collapse-icon {
  color: var(--color-text-muted);
  transition: transform 0.15s ease;
}

.message--expanded .message-collapse-icon {
  transform: rotate(180deg);
}

/* Collapse/expand transitions using CSS grid for smooth animation */
.message-snippet-wrapper {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.2s ease;
}

.message-snippet-wrapper > .message-snippet {
  overflow: hidden;
  padding: 0 1rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message--expanded .message-snippet-wrapper {
  grid-template-rows: 0fr;
}

.message--expanded .message-snippet-wrapper > .message-snippet {
  padding-top: 0;
  padding-bottom: 0;
}

.message-body-wrapper {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.2s ease;
}

.message-body-wrapper > .message-body {
  overflow: hidden;
}

.message--expanded .message-body-wrapper {
  grid-template-rows: 1fr;
}

/* Snippet bottom padding when visible */
.message .message-snippet-wrapper > .message-snippet {
  padding-bottom: 0.75rem;
}

.message--expanded .message-snippet-wrapper > .message-snippet {
  padding-bottom: 0;
}

/* === Message Anchor Highlight === */

.message--anchor-highlight {
  background-color: #fefce8;
}

/* === Message Headers (Gmail From/To/Cc) === */

.message-headers {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  background: #fafafa;
}

.message-header-field {
  display: flex;
  gap: 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.message-header-label {
  font-weight: 600;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.message-header-value {
  color: var(--color-text);
  word-break: break-word;
}

/* === Message Content === */

.message-content {
  padding: 1rem;
  font-size: 0.875rem;
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: break-word;
}

.message-content p {
  margin: 0 0 0.75rem;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content a {
  color: var(--color-primary);
  text-decoration: underline;
}

.message-content blockquote {
  margin: 0.75rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--color-border);
  color: var(--color-text-muted);
}

.message-content pre {
  margin: 0.75rem 0;
  padding: 0.75rem;
  background: var(--color-bg);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.8125rem;
}

.message-content img {
  max-width: 100%;
  height: auto;
}

.message-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.75rem 0;
}

.message-content th,
.message-content td {
  border: 1px solid var(--color-border);
  padding: 0.5rem;
  text-align: left;
  font-size: 0.8125rem;
}

/* === Attachments === */

.message-attachments {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.attachment--image {
  display: inline-block;
}

.attachment-image {
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius);
  object-fit: contain;
}

.attachment--file {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-bg);
  border-radius: var(--radius);
  font-size: 0.8125rem;
}

.attachment--file svg {
  flex-shrink: 0;
  color: var(--color-text-muted);
}

.attachment-link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

.attachment-link:hover {
  text-decoration: underline;
}

.attachment-filename {
  color: var(--color-text);
  font-weight: 500;
}

.attachment-size {
  color: var(--color-text-muted);
}

.attachment-placeholder {
  padding: 1rem;
  background: var(--color-bg);
  border-radius: var(--radius);
  text-align: center;
}

.attachment-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* === Search === */

.search-form {
  display: block;
}

.search-field {
  position: relative;
}

.search-input {
  width: 100%;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
  background: var(--color-surface);
}

.search-input::placeholder {
  color: var(--color-text-muted);
}

.search-clear {
  position: absolute;
  right: 0.375rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.375rem;
  height: 1.375rem;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease;
}

.search-clear:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.search-clear:active {
  background: #d1d5db;
}

.search-results-header {
  padding: 0.5rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.search-results-count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

/* Search snippet highlights */
.conversation-snippet mark {
  background: #fef08a;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* === Settings === */

.settings {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.settings-title {
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.settings-section {
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.settings-section-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.settings-description {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.settings-description code {
  font-size: 0.8125rem;
  padding: 0.125rem 0.375rem;
  background: var(--color-bg);
  border-radius: 3px;
}

.settings-button {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--color-surface);
  color: var(--color-text);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.settings-button:hover {
  background: var(--color-bg);
}

.settings-button:active {
  background: var(--color-border);
}

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

.settings-button--primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.settings-button--primary:active {
  background: var(--color-primary-active);
  border-color: var(--color-primary-active);
}

.settings-upload-form {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
}

.settings-file-field {
  flex: 1;
}

.settings-file-input {
  width: 100%;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--color-text);
}

.settings-file-input::file-selector-button {
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  margin-right: 0.75rem;
  transition: background 0.15s ease;
}

.settings-file-input::file-selector-button:hover {
  background: var(--color-bg);
}

.settings-file-input::file-selector-button:active {
  background: var(--color-border);
}

/* === Right Sidebar === */

.right-sidebar {
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  overflow-y: auto;
  min-width: 0;
}

.right-sidebar-content {
  padding: 0;
}

.right-sidebar-title {
  margin: 0;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  font-weight: 600;
  border-bottom: 1px solid var(--color-border);
}

/* === Sidebar Sections (Collapsible) === */

.sidebar-section {
  border-bottom: 1px solid var(--color-border);
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.625rem 1rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text);
  text-align: left;
  transition: background 0.1s ease;
}

.sidebar-section-header:hover {
  background: var(--color-bg);
}

.sidebar-section-header:active {
  background: #e5e7eb;
}

.sidebar-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-section-count {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-bg);
  padding: 0.0625rem 0.375rem;
  border-radius: 10px;
}

.sidebar-section-icon {
  color: var(--color-text-muted);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.sidebar-section--collapsed .sidebar-section-icon {
  transform: rotate(-90deg);
}

.sidebar-section-body-wrapper {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.2s ease;
}

.sidebar-section-body-wrapper > .sidebar-section-body {
  overflow: hidden;
}

.sidebar-section--collapsed .sidebar-section-body-wrapper {
  grid-template-rows: 0fr;
}

.sidebar-section-body {
  padding: 0 1rem 0.75rem;
}

.sidebar-section--collapsed .sidebar-section-body {
  padding-top: 0;
  padding-bottom: 0;
}

.sidebar-section-empty {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* === Summary Section === */

.summary-content {
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--color-text);
}

.summary-content p {
  margin: 0 0 0.5rem;
}

.summary-content p:last-child {
  margin-bottom: 0;
}

.summary-empty {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.summary-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--color-primary);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease;
}

.summary-edit-btn:hover {
  background: var(--color-bg);
}

.summary-trix-wrapper {
  margin-bottom: 0.5rem;
}

.summary-trix-wrapper trix-editor {
  min-height: 100px;
  max-height: 300px;
  overflow-y: auto;
  font-size: 0.8125rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.5rem;
}

.summary-trix-wrapper trix-toolbar {
  flex-wrap: wrap;
}

.summary-trix-wrapper trix-toolbar .trix-button-group {
  margin-bottom: 0.25rem;
}

.summary-trix-wrapper trix-toolbar .trix-button-group--file-tools {
  display: none;
}

.summary-actions {
  display: flex;
  gap: 0.5rem;
}

.summary-save-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: inherit;
  color: #fff;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease;
}

.summary-save-btn:hover {
  background: var(--color-primary-hover);
}

.summary-cancel-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--color-text);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease;
}

.summary-cancel-btn:hover {
  background: var(--color-bg);
}

/* === Participants Section === */

.participants-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.participant-card {
  padding: 0.5rem 0;
}

.participant-card:not(:last-child) {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.75rem;
}

.participant-name {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.125rem;
}

.participant-role {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.participant-detail {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.25rem;
}

.participant-detail svg {
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.participant-link {
  font-size: 0.75rem;
  color: var(--color-primary);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-link:hover {
  text-decoration: underline;
}

/* === Sidebar Tags === */

.sidebar-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.sidebar-tag {
  display: inline-block;
  padding: 0.1875rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  line-height: 1.4;
}

.sidebar-tag:hover {
  opacity: 0.85;
}

/* === Sidebar Milestones === */

.sidebar-milestones-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-milestone {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.375rem 0;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius);
}

.sidebar-milestone:hover {
  background-color: var(--color-bg);
}

.sidebar-milestone-title {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-primary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-milestone-date {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* === Sidebar Attachments === */

.sidebar-attachments-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.sidebar-attachment {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.375rem 0;
}

.sidebar-attachment svg {
  color: var(--color-text-muted);
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.sidebar-attachment-info {
  min-width: 0;
}

.sidebar-attachment-link {
  display: block;
  font-size: 0.8125rem;
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-attachment-link:hover {
  text-decoration: underline;
}

.sidebar-attachment-name {
  display: block;
  font-size: 0.8125rem;
  color: var(--color-text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-attachment-size {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
}

/* === Responsive === */

/* Medium screens: narrower right sidebar */
@media (min-width: 769px) and (max-width: 1200px) {
  .content-area {
    grid-template-columns: 1fr 280px;
  }
}

@media (max-width: 768px) {
  /* Header nav: tighter spacing, smaller text, scrollable links */
  .header-nav {
    padding: 0 0.5rem;
  }

  .header-nav-left {
    gap: 0.75rem;
    overflow: hidden;
  }

  .header-nav-title {
    font-size: 0.875rem;
  }

  .header-nav-links {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .header-nav-links::-webkit-scrollbar {
    display: none;
  }

  .header-nav-link {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }

  /* Page container: less padding on mobile */
  .page-container {
    padding: 1.25rem 1rem;
  }

  /* Tags grid: smaller min-width for narrow screens */
  .tags-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
  }

  /* Reports: stack item layout vertically on mobile */
  .report-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  /* Page title row: allow wrapping on mobile */
  .page-title-row {
    flex-wrap: wrap;
  }

  /* Slightly smaller page title on mobile */
  .page-title {
    font-size: 1.25rem;
  }

  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  .sidebar {
    display: flex;
  }

  .main-panel {
    display: none;
    overflow-y: auto;
  }

  /* When a conversation is active on mobile, show main panel and hide sidebar */
  .app-layout--has-conversation .sidebar {
    display: none;
  }

  .app-layout--has-conversation .main-panel {
    display: block;
  }

  .content-area {
    grid-template-columns: 1fr;
    display: block;
  }

  .right-sidebar {
    display: none;
  }

  .thread {
    padding: 1rem;
  }

  .settings {
    padding: 1rem;
  }

  .settings-upload-form {
    flex-direction: column;
    align-items: stretch;
  }

  .thread-back {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-primary);
    text-decoration: none;
  }

  .thread-back:active {
    opacity: 0.7;
  }

  .milestones-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .milestones-sidebar {
    position: static;
  }

  .milestones-sidebar-tags {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .deficiencies-layout {
    grid-template-columns: 1fr;
  }

  .deficiencies-sidebar {
    display: none;
  }

  .deficiencies-main {
    padding: 1rem;
  }

  .deficiencies-table-header {
    display: none;
  }

  .deficiency-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .def-col {
    width: auto;
    flex: none;
  }

  .def-col-title {
    width: 100%;
    flex: none;
  }

  .def-col-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }
}

/* === Page Shared Styles === */

.page-title {
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}

.page-empty {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-title-row .page-title {
  margin-bottom: 0;
}

/* === Milestones === */

.milestone-group {
  margin-bottom: 2rem;
}

.milestone-group:last-child {
  margin-bottom: 0;
}

.milestone-group-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.milestone-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}

.milestone-item .milestone-header {
  padding: 0.75rem 1rem;
}

.milestone-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.milestone-date {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.milestone-body {
  padding: 0 1rem 1rem;
}

.milestone-description {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--color-text);
  margin-bottom: 1rem;
}

.milestone-description:last-child {
  margin-bottom: 0;
}

.milestone-messages {
  border-top: 1px solid var(--color-border);
  padding-top: 0.75rem;
}

.milestone-messages-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.5rem;
}

.milestone-messages-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.milestone-message-item {
  border-bottom: 1px solid var(--color-border);
}

.milestone-message-item:last-child {
  border-bottom: none;
}

.milestone-message-link {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  padding: 0.5rem;
  text-decoration: none;
  color: var(--color-text);
  transition: background 0.1s ease;
  border-radius: var(--radius);
}

.milestone-message-link:hover {
  background: var(--color-bg);
}

.milestone-message-sender {
  font-size: 0.8125rem;
  font-weight: 600;
}

.milestone-message-date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.milestone-empty {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.milestone-message-snippet {
  width: 100%;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* === Milestones Layout === */

.milestones-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2rem;
  align-items: start;
}

.milestones-content:only-child {
  grid-column: 1 / -1;
}

.milestones-sidebar {
  position: sticky;
  top: 1rem;
}

.milestones-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.milestones-sidebar-title {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.milestones-sidebar-clear {
  font-size: 0.75rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--color-primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.milestones-sidebar-clear:hover {
  text-decoration: underline;
}

.milestones-sidebar-tags {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.tag-filter-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--color-text);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s ease, border-color 0.1s ease;
}

.tag-filter-btn:hover {
  background: var(--color-bg);
}

.tag-filter-btn--active {
  background: var(--tag-color);
  color: var(--tag-text);
  border-color: var(--tag-color);
}

.tag-filter-btn--active:hover {
  opacity: 0.9;
}

/* === Milestone Header === */

.milestone-header-left {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
}

.milestone-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.milestone-tag {
  display: inline-block;
  padding: 0.0625rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.4;
}

/* === Shared Message Link === */

.message-link {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  padding: 0.5rem;
  text-decoration: none;
  color: var(--color-text);
  transition: background 0.1s ease;
  border-radius: var(--radius);
}

.message-link:hover {
  background: var(--color-bg);
}

.message-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.message-link-subject {
  font-size: 0.8125rem;
  font-weight: 600;
}

.message-link-sender {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.message-link-date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-left: auto;
}

.message-link-tags {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.message-link-tag {
  display: inline-block;
  padding: 0.0625rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1.4;
}

/* === Tags === */

.tags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.tag-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.25rem 1rem;
  border-radius: var(--radius);
  text-decoration: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.tag-card:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.tag-card:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.tag-card-name {
  font-size: 1rem;
  font-weight: 600;
}

.tag-card-count {
  font-size: 0.8125rem;
  opacity: 0.8;
}

.tag-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 1.125rem;
  font-weight: 600;
}

.page-back-link {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: var(--color-primary);
  text-decoration: none;
}

.page-back-link:hover {
  text-decoration: underline;
}

.page-back-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.tagged-messages-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tagged-message-item {
  border-bottom: 1px solid var(--color-border);
}

.tagged-message-item:last-child {
  border-bottom: none;
}

.tagged-message-link {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  padding: 0.75rem 0.5rem;
  text-decoration: none;
  color: var(--color-text);
  transition: background 0.1s ease;
  border-radius: var(--radius);
}

.tagged-message-link:hover {
  background: var(--color-bg);
}

.tagged-message-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.tagged-message-sender {
  font-size: 0.8125rem;
  font-weight: 600;
}

.tagged-message-conversation {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.tagged-message-date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-left: auto;
}

.tagged-message-snippet {
  width: 100%;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* === Buttons === */

.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background: var(--color-bg);
}

.btn:active {
  background: var(--color-border);
}

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

.btn--primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn--primary:active {
  background: var(--color-primary-active);
  border-color: var(--color-primary-active);
}

.btn--danger {
  color: var(--color-danger);
  border-color: var(--color-danger);
  background: var(--color-surface);
}

.btn--danger:hover {
  background: var(--color-danger-bg);
}

.btn--danger:active {
  background: #fecaca;
}

.btn--small {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

/* === Forms === */

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  color: var(--color-text);
}

.form-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  padding-top: 0.25rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  cursor: pointer;
}

.checkbox-input {
  margin: 0;
}

/* === Reports === */

.reports-list {
  display: flex;
  flex-direction: column;
}

.report-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}

.report-item-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.report-item-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-primary);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-item-title:hover {
  text-decoration: underline;
}

.report-item-meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.report-item-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.report-item-actions form.button_to {
  display: contents;
}

.report-detail-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.report-detail-actions form.button_to {
  display: contents;
}

.report-description {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--color-text);
}

.report-description p {
  margin: 0 0 0.75rem;
}

.report-description p:last-child {
  margin-bottom: 0;
}

.report-milestones {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.report-milestones-title {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  margin: 0 0 0.75rem;
}

.report-milestone-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.report-milestone-content {
  flex: 1;
  min-width: 0;
}

.report-milestone-remove {
  flex-shrink: 0;
  margin-top: 0.625rem;
  padding: 0.25rem;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  line-height: 0;
  transition: color 0.15s, background-color 0.15s;
}

.report-milestone-remove:hover {
  color: var(--color-danger);
  background-color: var(--color-danger-bg);
}

/* === Deficiencies Layout === */

.deficiencies-layout {
  grid-template-columns: 280px 1fr;
}

.deficiencies-sidebar {
  overflow-y: auto;
}

.deficiencies-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.deficiencies-sidebar-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.deficiencies-filters {
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.filter-group-title {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-group-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--color-text);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s ease, border-color 0.1s ease;
}

.filter-btn:hover {
  background: var(--color-bg);
}

.filter-btn--active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.filter-btn--active:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.filter-btn.tag-filter-btn--active {
  background: var(--tag-color);
  color: var(--tag-text);
  border-color: var(--tag-color);
}

.filter-btn.tag-filter-btn--active:hover {
  opacity: 0.9;
}

/* === Deficiencies Main Panel === */

.deficiencies-main {
  overflow-y: auto;
  padding: 1.5rem;
  background: var(--color-bg);
}

.deficiencies-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.deficiencies-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

/* === Deficiencies Table === */

.deficiencies-table {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.deficiencies-table-header {
  display: flex;
  align-items: center;
  padding: 0.625rem 1rem;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.deficiency-row {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.1s ease;
}

.deficiency-row[hidden] {
  display: none;
}

.deficiency-row:last-child {
  border-bottom: none;
}

.deficiency-row:hover {
  background: var(--color-bg);
}

.def-col {
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 0.75rem;
}

.def-col-id {
  width: 80px;
  flex-shrink: 0;
}

.def-col-title {
  flex: 1;
  min-width: 0;
}

.def-col-priority {
  width: 80px;
  flex-shrink: 0;
}

.def-col-status {
  width: 90px;
  flex-shrink: 0;
}

.def-col-location {
  width: 120px;
  flex-shrink: 0;
}

.def-col-builder {
  width: 130px;
  flex-shrink: 0;
}

.def-col-actions {
  width: 140px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  justify-content: flex-end;
  padding-right: 0;
}

.def-col-actions form.button_to {
  display: contents;
}

.deficiency-link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

.deficiency-link:hover {
  text-decoration: underline;
}

/* === Priority Badges === */

.priority-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.priority-badge--1 {
  background: #fef2f2;
  color: #dc2626;
}

.priority-badge--2 {
  background: #fffbeb;
  color: #d97706;
}

.priority-badge--3 {
  background: #f0fdf4;
  color: #16a34a;
}

/* === Status Badges === */

.status-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status-badge--open {
  background: #dbeafe;
  color: #1e40af;
}

.status-badge--pending {
  background: #fffbeb;
  color: #92400e;
}

.status-badge--corrected {
  background: #f0fdf4;
  color: #166534;
}

.status-badge--closed {
  background: var(--color-bg);
  color: var(--color-text-muted);
}

/* === Deficiency Detail === */

.deficiency-detail-id {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

.deficiency-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.deficiency-meta-item {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.deficiency-section {
  margin-bottom: 1.5rem;
}

.deficiency-section-title {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* === Form Rows === */

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

.form-group--narrow {
  flex: 0 0 140px !important;
}

.form-group--wide {
  flex: 1 !important;
}

/* === Reduced Motion === */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
