/* ElasticForest identity shared (carried over from ForestMail) base + component layer.
   Depends on tokens.css. Framework-free: plain CSS classes consumed by every
   app. Keep component rules here; put app-specific layout in the app's own css.
   Tuned for a premium, calm feel: soft elevation, a confident gradient brand
   action, a visible focus ring, and restrained motion. */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: var(--fm-fs-2)/1.6 var(--fm-font);
  color: var(--fm-text);
  background: var(--fm-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, figure { margin: 0 0 var(--fm-s-4); }
h1 { font-size: var(--fm-fs-7); font-weight: 680; letter-spacing: -.9px; line-height: 1.1; }
h2 { font-size: var(--fm-fs-5); font-weight: 640; letter-spacing: -.5px; line-height: 1.22; }
h3 { font-size: var(--fm-fs-3); font-weight: 620; letter-spacing: -.2px; }
h4 { font-size: var(--fm-fs-2); font-weight: 620; }
a { color: var(--fm-link); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg, video { max-width: 100%; height: auto; }
hr { border: 0; border-top: 1px solid var(--fm-line); margin: var(--fm-s-6) 0; }
code, kbd, pre { font-family: var(--fm-mono); }
kbd {
  font-size: var(--fm-fs-0); border: 1px solid var(--fm-line); background: var(--fm-surface-2);
  border-radius: 6px; padding: 2px 6px; color: var(--fm-text-muted); box-shadow: 0 1px 0 var(--fm-line);
}
::selection { background: var(--fm-green-soft); color: var(--fm-text); }

/* Focus + a11y helpers — a soft ring instead of a hard outline. */
:where(a, button, input, select, textarea, summary, [tabindex], [contenteditable]):focus-visible {
  outline: 2px solid transparent; outline-offset: 2px;
  box-shadow: var(--fm-ring); border-radius: 6px;
}
.fm-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.fm-skip {
  position: absolute; left: 8px; top: -60px; z-index: 50; background: var(--fm-surface);
  color: var(--fm-text); padding: 10px 16px; border-radius: var(--fm-r-2);
  box-shadow: var(--fm-shadow-2); transition: top var(--fm-dur) var(--fm-ease);
}
.fm-skip:focus { top: 8px; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Form controls */
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--fm-surface); border: 1px solid var(--fm-line);
  border-radius: var(--fm-r-1); padding: 10px 12px; width: 100%;
  transition: border-color var(--fm-dur) var(--fm-ease), box-shadow var(--fm-dur) var(--fm-ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--fm-text-muted); }
input:focus, select:focus, textarea:focus { border-color: var(--fm-focus); box-shadow: var(--fm-ring); outline: none; }
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--fm-green); }
label { display: inline-block; }
.fm-field { display: grid; gap: 6px; margin-bottom: var(--fm-s-4); }
.fm-field > span { font-size: var(--fm-fs-1); font-weight: 560; color: var(--fm-text-muted); }
.fm-field-error { color: var(--fm-danger); font-size: var(--fm-fs-1); }

/* Buttons */
.fm-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--fm-s-2);
  border: 1px solid var(--fm-line); border-radius: var(--fm-r-2); background: var(--fm-surface);
  color: var(--fm-text-soft); padding: 9px 15px; font-size: var(--fm-fs-2); font-weight: 580;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--fm-dur) var(--fm-ease), border-color var(--fm-dur) var(--fm-ease),
              box-shadow var(--fm-dur) var(--fm-ease), transform var(--fm-dur) var(--fm-ease), color var(--fm-dur) var(--fm-ease);
}
.fm-btn:hover { background: var(--fm-surface-2); border-color: var(--fm-text-muted); text-decoration: none; }
.fm-btn:active { transform: translateY(1px); }
.fm-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.fm-btn-primary {
  background: var(--fm-brand-grad); border-color: transparent; color: #fff;
  box-shadow: 0 1px 1px rgba(16,40,32,.2), 0 6px 16px rgba(20,120,92,.28);
}
.fm-btn-primary:hover { background: var(--fm-brand-grad); filter: brightness(1.05); box-shadow: 0 2px 4px rgba(16,40,32,.22), 0 10px 24px rgba(20,120,92,.36); }
.fm-btn-primary:active { filter: brightness(.97); }
.fm-btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.fm-btn-ghost:hover { background: var(--fm-surface-2); border-color: transparent; }
.fm-btn-danger { color: var(--fm-danger); border-color: color-mix(in srgb, var(--fm-danger) 40%, var(--fm-line)); background: var(--fm-danger-bg); }
.fm-btn-danger:hover { background: var(--fm-danger-bg); filter: brightness(.98); }
.fm-btn-sm { padding: 6px 11px; font-size: var(--fm-fs-1); }
.fm-btn-lg { padding: 13px 24px; font-size: var(--fm-fs-3); border-radius: var(--fm-r-3); }

/* Surfaces */
.fm-card {
  background: var(--fm-surface); border: 1px solid var(--fm-line);
  border-radius: var(--fm-r-3); padding: var(--fm-s-6); box-shadow: var(--fm-shadow-1);
  transition: box-shadow var(--fm-dur) var(--fm-ease), border-color var(--fm-dur) var(--fm-ease), transform var(--fm-dur) var(--fm-ease);
}
.fm-eyebrow { font-size: var(--fm-fs-0); letter-spacing: 1.8px; text-transform: uppercase; font-weight: 680; color: var(--fm-green); }
.fm-muted { color: var(--fm-text-muted); }

/* Badges + pills */
.fm-badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: var(--fm-fs-0); font-weight: 650;
  padding: 3px 10px; border-radius: var(--fm-r-pill); background: var(--fm-surface-3); color: var(--fm-text-muted);
  letter-spacing: .2px;
}
.fm-badge-ok { background: var(--fm-ok-bg); color: var(--fm-ok); }
.fm-badge-warn { background: var(--fm-warn-bg); color: var(--fm-warn); }
.fm-badge-danger { background: var(--fm-danger-bg); color: var(--fm-danger); }
.fm-badge-info { background: var(--fm-info-bg); color: var(--fm-info); }

/* Tables */
.fm-table { width: 100%; border-collapse: collapse; font-size: var(--fm-fs-2); }
.fm-table th { text-align: left; font-size: var(--fm-fs-1); color: var(--fm-text-muted); font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--fm-line); }
.fm-table td { padding: 12px; border-bottom: 1px solid var(--fm-line-soft); }
.fm-table tr:hover td { background: var(--fm-surface-2); }

/* Dialog */
dialog {
  width: min(96vw, 640px); max-height: 92vh; padding: 0; color: inherit;
  background: var(--fm-surface); border: 1px solid var(--fm-line);
  border-radius: var(--fm-r-4); box-shadow: var(--fm-shadow-3);
}
dialog[open] { animation: fm-dialog-in var(--fm-dur-2) var(--fm-ease-out); }
@keyframes fm-dialog-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
dialog::backdrop { background: var(--fm-overlay); backdrop-filter: blur(4px); }
.fm-dialog-head { display: flex; align-items: center; justify-content: space-between; padding: var(--fm-s-5) var(--fm-s-6); border-bottom: 1px solid var(--fm-line); }
.fm-dialog-body { padding: var(--fm-s-6); overflow: auto; }
.fm-dialog-foot { display: flex; gap: var(--fm-s-3); justify-content: flex-end; padding: var(--fm-s-4) var(--fm-s-6); background: var(--fm-surface-2); border-top: 1px solid var(--fm-line); }

/* Brand mark */
.fm-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: var(--fm-fs-5); letter-spacing: -.8px; color: var(--fm-text); }
.fm-brand-mark {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  background: var(--fm-brand-grad); color: #fff; border-radius: 10px;
  font-family: Georgia, serif; font-size: 20px; line-height: 1; box-shadow: 0 2px 8px rgba(20,120,92,.35);
}

/* Status / toast region */
.fm-status { font-size: var(--fm-fs-1); color: var(--fm-text-muted); min-height: 20px; }
.fm-status.is-error { color: var(--fm-danger); }
.fm-status.is-ok { color: var(--fm-ok); }
.fm-toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; max-width: 360px; }
.fm-toast {
  background: var(--fm-surface); border: 1px solid var(--fm-line); border-left: 3px solid var(--fm-green);
  border-radius: var(--fm-r-2); box-shadow: var(--fm-shadow-2); padding: 12px 14px; font-size: var(--fm-fs-1);
  animation: fm-toast-in var(--fm-dur-2) var(--fm-ease-out);
}
@keyframes fm-toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.fm-toast.is-error { border-left-color: var(--fm-danger); }
.fm-toast.is-ok { border-left-color: var(--fm-ok); }

/* Sample-data banner: makes unauthenticated/demo content unmistakable and
   visually isolated from live, authenticated data (designing.md requirement). */
.fm-sample-banner {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  background: var(--fm-warn-bg); color: var(--fm-warn); border-bottom: 1px solid var(--fm-line);
  padding: 8px 16px; font-size: var(--fm-fs-1); font-weight: 650;
}

/* Loading + empty + error states */
.fm-skeleton { background: linear-gradient(90deg, var(--fm-surface-2), var(--fm-surface-3), var(--fm-surface-2)); background-size: 200% 100%; animation: fm-shimmer 1.3s ease-in-out infinite; border-radius: var(--fm-r-1); }
@keyframes fm-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.fm-empty, .fm-error-state { text-align: center; padding: var(--fm-s-8) var(--fm-s-5); color: var(--fm-text-muted); }
.fm-spinner { width: 20px; height: 20px; border: 2px solid var(--fm-line); border-top-color: var(--fm-green); border-radius: 50%; animation: fm-spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes fm-spin { to { transform: rotate(360deg); } }

/* Utility layout */
.fm-container { max-width: var(--fm-maxw); margin: 0 auto; padding: 0 var(--fm-gutter); }
.fm-row { display: flex; gap: var(--fm-s-3); align-items: center; }
.fm-col { display: flex; flex-direction: column; gap: var(--fm-s-3); }
.fm-grow { flex: 1; min-width: 0; }
.fm-wrap { flex-wrap: wrap; }
