/* ============================================================================
   Meridian Cloud — Frontend styling
   ============================================================================
   Design language ported from local Meridian's index.html — warm earthy
   palette, forest green accent (#1A6B4A), Inter typeface, paper texture
   overlay, full light/dark mode support via :root + html.dark token swap.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
  /* Light mode tokens — warm, paper-like */
  --bg:           #FAF9F6;
  --surface:      #FFFFFF;
  --surface2:     #F4F2EE;
  --border:       #E8E4DC;
  --accent:       #1A6B4A;
  --accent-hover: #145839;
  --accent-dim:   #E6F4EE;
  --success:      #1A6B4A;
  --warning:      #B45309;
  --error:        #B91C1C;
  --text:         #1A1A1A;
  --text-dim:     #6B6560;
  --text-faint:   #A8A29E;

  --radius:       10px;
  --radius-sm:    6px;
  --radius-lg:    14px;
  --shadow:       0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg:    0 4px 6px rgba(0,0,0,0.06), 0 10px 30px rgba(0,0,0,0.08);

  --font:         'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:    'SF Mono', Menlo, Monaco, Consolas, "Courier New", monospace;
  --texture-opacity: 0.035;

  /* Spacing scale — multiples of 4px */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
}

html.dark {
  /* Dark mode tokens — deep blue-black, deeper forest accent */
  --bg:           #141821;
  --surface:      #1C2132;
  --surface2:     #242B3D;
  --border:       #2D3650;
  --accent:       #2D8F65;        /* brighter green pops on dark */
  --accent-hover: #268055;
  --accent-dim:   #162A20;
  --success:      #2D8F65;
  --warning:      #D97706;
  --error:        #EF4444;
  --text:         #E8E6E1;
  --text-dim:     #9CA3AF;
  --text-faint:   #4B5563;
  --shadow:       0 1px 3px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.3);
  --shadow-lg:    0 4px 6px rgba(0,0,0,0.4), 0 10px 30px rgba(0,0,0,0.35);
  --texture-opacity: 0.04;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  transition: background 0.2s, color 0.2s;
  -webkit-font-smoothing: antialiased;
}

/* Paper-texture noise overlay — sits above content but pointer-events: none
   so clicks pass through. Intentionally very subtle (3.5% opacity) — gives
   the warmth of a printed estimate without distracting from content. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: var(--texture-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
}

/* Critical: HTML hidden attribute must beat element display rules.
   Without this, display:flex on .loading-screen / .centered overrides
   the UA [hidden] { display: none } and elements stay visible. */
[hidden] { display: none !important; }


/* === Headings === */

h1, h2, h3, h4 {
  margin: 0 0 var(--sp-3);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text);
}
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; font-weight: 600; }

p { margin: 0 0 var(--sp-3); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }


/* === Utility === */

.muted    { color: var(--text-dim); }
.subtle   { color: var(--text-faint); }
.small    { font-size: 12px; }
.required { color: var(--error); }
.hint {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: var(--sp-1);
}
.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
}


/* === Loading screen + spinner === */

.loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  background: var(--bg);
  z-index: 100;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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


/* === Sign-in card === */

.signin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}
.signin-card h1 {
  margin-bottom: var(--sp-2);
  letter-spacing: -0.02em;
}
.signin-card .subtitle {
  color: var(--text-dim);
  margin-bottom: var(--sp-6);
  font-size: 13px;
}
.signin-card .btn-primary {
  width: 100%;
  margin-bottom: var(--sp-4);
}


/* === App header === */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  cursor: pointer;
  display: flex;
  align-items: center;
}
.brand-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  position: relative;   /* anchor for the popup */
}

.gear-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, transform 0.15s, background 0.2s;
}
.gear-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: rotate(30deg);
}
.gear-button:active { transform: rotate(60deg); }

.user-menu-popup {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 100;
  animation: popup-in 0.12s ease;
}
@keyframes popup-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.user-menu-email {
  padding: 8px 12px 6px;
  font-size: 12px;
  color: var(--text-dim);
  word-break: break-all;
}

.user-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.user-menu-item:hover {
  background: var(--surface2);
  color: var(--accent);
}
.user-menu-item-icon {
  font-size: 14px;
  line-height: 1;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.user-menu-item-label {
  flex: 1;
}

.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-5);
}


/* === View headers === */

.view-header {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.view-header h2 { margin: 0; flex: 1; }

.job-title-block { flex: 1; }
.job-title-block h2 { margin: 0; }
.job-title-block p { margin: 0; }


/* === Buttons === */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.2px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s,
              transform 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 6px rgba(26,107,74,0.18);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26,107,74,0.28);
}
html.dark .btn-primary {
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface2);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface2);
  color: var(--text);
}

.btn-danger {
  background: var(--surface);
  color: var(--error);
  border-color: var(--border);
}
.btn-danger:hover:not(:disabled) {
  background: var(--error);
  color: white;
  border-color: var(--error);
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}


/* === Card grid (job list) === */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-4);
}

.job-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  box-shadow: var(--shadow);
}
.job-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
html.dark .job-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 12px 32px rgba(0,0,0,0.4);
}

.job-card h3 {
  margin-bottom: var(--sp-2);
  font-size: 15px;
}
.job-card .job-card-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: var(--sp-3);
}

/* "Completed" pill in the lower-right of the card. Subtle; doesn't compete
   with the job name. Only appears when completed_at is set. */
.job-card .job-card-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 999px;
}

/* Soft-deleted cards in the Deleted tier — visually muted */
.job-card.job-card-deleted {
  opacity: 0.7;
}

/* X delete button on the corner of an active job card. Click stops
   propagation so it doesn't navigate into the job. */
.job-card { position: relative; }
.job-card-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;        /* hidden until card hover — keeps the card clean */
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.job-card:hover .job-card-delete {
  opacity: 1;
}
.job-card-delete:hover {
  background: var(--error);
  color: white;
}


/* === Tier cards (dashboard filters) === */

.tier-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.tier-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.tier-card:hover {
  border-color: var(--text-faint);
  box-shadow: var(--shadow);
}
.tier-card.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: var(--shadow);
}
.tier-card.selected .tier-label {
  color: var(--accent);
}

.tier-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tier-count {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
/* Color the completed count green to match the visual language Anthony's
   competitor uses — but tied to our forest-green accent, not their blue. */
.tier-count-completed { color: var(--accent); }
/* Deleted count stays muted — deletions aren't an "achievement" to count up */
.tier-count-deleted   { color: var(--text-faint); }

@media (max-width: 600px) {
  .tier-cards { grid-template-columns: 1fr; }
  .tier-card { flex-direction: row; justify-content: space-between; padding: 12px 16px; }
}


/* === Room include checkbox === */

.room-include-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: var(--sp-3);
  cursor: pointer;
  user-select: none;
  color: var(--text-dim);
  font-size: 12px;
}
.room-include-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}
.room-include-label {
  font-weight: 500;
}


/* === Sketch uploaded indicator === */

.sketch-uploaded {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 14px 16px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
}
.sketch-uploaded-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.sketch-uploaded-text { flex: 1; }
.sketch-uploaded-remove {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 16px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.sketch-uploaded-remove:hover {
  background: var(--accent);
  color: white;
}


/* === Empty-notes pre-flight error panel === */

.generate-error {
  background: #FEF3C7;
  border: 1px solid #FBBF24;
  border-radius: var(--radius);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
  color: #92400E;
}
html.dark .generate-error {
  background: #292219;
  border-color: #B45309;
  color: #FBBF24;
}
.generate-error strong { display: block; margin-bottom: 4px; }
.generate-error p { margin: 0 0 var(--sp-2); }
.generate-error ul {
  margin: 0;
  padding-left: var(--sp-5);
}
.generate-error a {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
}


/* === Confirm modal === */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: modal-fade 0.15s ease;
}
@keyframes modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-5);
  max-width: 440px;
  width: calc(100% - 32px);
  animation: modal-pop 0.18s ease;
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-card h3 { margin-bottom: var(--sp-2); }
.modal-card p { margin-bottom: var(--sp-4); }
.modal-actions {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
}


/* === Forms === */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-6);
  max-width: 640px;
  box-shadow: var(--shadow);
}

.form-card label {
  display: block;
  margin-bottom: var(--sp-4);
}
.form-card label > span:first-child {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.form-card input[type="text"],
.form-card input[type="number"],
.form-card input[type="email"],
.form-card select,
.form-card textarea {
  width: 100%;
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s;
}
.form-card input:focus,
.form-card select:focus,
.form-card textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.form-card textarea {
  resize: vertical;
  min-height: 120px;
  font-family: var(--font);
  line-height: 1.5;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
}
.form-row label { margin-bottom: var(--sp-4); }

.form-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}


/* === Job detail sections === */

.job-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
  box-shadow: var(--shadow);
}

.job-section h3 { margin-bottom: var(--sp-3); }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}
.section-header h3 { margin: 0; }


/* === Room cards === */

.room-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
  background: var(--surface);
  transition: box-shadow 0.2s;
}
.room-card:hover {
  box-shadow: var(--shadow);
}

.room-card-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.room-card-header .room-actions {
  display: flex;
  gap: var(--sp-2);
  margin-left: auto;
}

/* Editable room name. Styled to look like a heading by default; gets a
   subtle border + bg on focus so the user knows it's an input. flex: 1
   lets it stretch between the include checkbox and the action buttons. */
.room-name-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin: -4px -8px;          /* nudge so non-focus state aligns with sibling text */
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.005em;
  transition: background 0.15s, border-color 0.15s;
}
.room-name-input:hover {
  background: var(--surface2);
}
.room-name-input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
}

/* Inline ceiling-height field. Compact, sits in its own row above notes. */
.room-inline-fields {
  display: flex;
  gap: var(--sp-4);
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
}
.room-height-inline {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 12px;
  color: var(--text-dim);
}
.room-height-inline > span:first-child {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}
.room-height-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  transition: border-color 0.15s, background 0.15s;
}
.room-height-input-wrap:focus-within {
  border-color: var(--accent);
  background: var(--surface);
}
.room-height-input-wrap input {
  width: 60px;
  background: transparent;
  border: none;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  padding: 0;
}
.room-height-input-wrap input:focus { outline: none; }
.room-height-unit {
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 500;
}

/* Inline notes textarea — the heavy-touch field. Large, comfortable,
   has the same warm-input styling as the room form's notes box. The mic
   button is positioned absolutely inside via .textarea-with-mic which
   attachMicButton() wraps it in. */
.room-notes-inline {
  margin-bottom: var(--sp-3);
}
.room-notes-inline textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  padding: 10px 12px;
  padding-right: 100px;       /* space for the dictate button */
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s;
}
.room-notes-inline textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}
.room-notes-inline textarea::placeholder {
  color: var(--text-faint);
}

.room-card .room-photos {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}


/* === Drop zones === */

.drop-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--surface2);
  transition: border-color 0.2s, background 0.2s;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.drop-zone .drop-icon {
  font-size: 22px;
  margin-bottom: 4px;
  opacity: 0.5;
}
.drop-zone .drop-label {
  font-size: 12px;
  color: var(--text-dim);
}
.drop-zone .drop-label strong {
  color: var(--text);
}

/* Sketch detection progress bar — shown briefly when a sketch is dropped.
   The wrapper is a thin track; the inner bar runs a 0→100% width animation
   over 1.2s as a visual stimulant. JS shows/hides the wrapper around the
   API call; if the actual API time differs from the animation duration,
   that's fine — the bar fades on response either way.
   Adding `.running` after a forced reflow restarts the animation cleanly
   when the user drops a second sketch right after the first finishes. */
.sketch-progress {
  position: relative;
  height: 3px;
  margin: var(--sp-3) 0 0;
  border-radius: 2px;
  overflow: hidden;
  background: var(--surface2);
}
.sketch-progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(26,107,74,0.45);
}
.sketch-progress.running .sketch-progress-bar {
  animation: sketch-fill 1.2s ease-out forwards;
}
@keyframes sketch-fill {
  0%   { width: 0; }
  60%  { width: 80%; }
  100% { width: 100%; }
}


/* === Photo thumbnails === */

.thumb-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

.thumb {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb-remove:hover { background: var(--error); }

.thumb-empty {
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
}


/* === Generation progress === */

.generate-block {
  text-align: center;
  padding: var(--sp-3);
}
.generate-block .btn-lg { min-width: 240px; }
.generate-block p {
  margin-top: var(--sp-3);
  margin-bottom: 0;
  font-size: 12px;
}

.progress-block {
  text-align: center;
  padding: var(--sp-5);
}
.progress-block .spinner {
  margin: 0 auto var(--sp-3);
}


/* === Voice dictation === */

.textarea-with-mic { position: relative; }

.mic-button {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  z-index: 1;
}
.mic-button:hover:not(:disabled) {
  background: var(--surface2);
  color: var(--accent);
  border-color: var(--accent);
}
.mic-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.mic-button svg { flex-shrink: 0; }
.mic-button.recording {
  color: white;
  background: var(--error);
  border-color: var(--error);
  animation: mic-pulse 1.4s ease-in-out infinite;
}
.mic-button.recording:hover {
  background: var(--error);
  color: white;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(185,28,28,0.45); }
  50%      { box-shadow: 0 0 0 6px rgba(185,28,28,0); }
}

.textarea-with-mic textarea {
  padding-right: 100px;
}


/* === Empty states === */

.empty-state {
  text-align: center;
  padding: var(--sp-7) var(--sp-4);
  color: var(--text-dim);
  font-size: 13px;
}


/* === Scope display === */

.scope-list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.15s;
}
.scope-list-item:hover {
  border-color: var(--accent);
}
.scope-list-item .scope-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.scope-list-item .scope-cost {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.scope-list-item .scope-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.scope-meta-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--sp-4);
  box-shadow: var(--shadow);
}
.scope-meta-card .meta-item {
  display: flex;
  flex-direction: column;
}
.scope-meta-card .meta-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.scope-meta-card .meta-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}

.scope-flags {
  background: #FEF3C7;
  border: 1px solid #FBBF24;
  border-radius: var(--radius);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
}
html.dark .scope-flags {
  background: #292219;
  border-color: #B45309;
}
.scope-flags h3 {
  color: #92400E;
  margin-bottom: var(--sp-3);
}
html.dark .scope-flags h3 { color: #FBBF24; }
.scope-flags ul { margin: 0; padding-left: var(--sp-5); }
.scope-flags li {
  font-size: 12px;
  color: #92400E;
  margin-bottom: var(--sp-1);
}
html.dark .scope-flags li { color: #FBBF24; }

.scope-rooms { margin-top: var(--sp-4); }

.scope-room-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--sp-4);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.scope-room-section .room-header {
  background: var(--surface2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.scope-room-section .room-header h4 {
  margin: 0;
  font-size: 14px;
}
.scope-room-section .room-header .room-stats {
  font-size: 12px;
  color: var(--text-dim);
}

.line-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.line-items-table th,
.line-items-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.line-items-table th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  background: var(--surface2);
}
.line-items-table tbody tr:hover { background: var(--surface2); }
.line-items-table .code-cell {
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
  font-weight: 600;
}
.line-items-table .act-cell,
.line-items-table .calc-cell {
  font-family: var(--font-mono);
  text-align: center;
  white-space: nowrap;
  font-size: 12px;
}
.line-items-table .note-cell {
  color: var(--text-dim);
  font-size: 12px;
}


/* === Toast notifications === */

.toast {
  position: fixed;
  bottom: var(--sp-5);
  right: var(--sp-5);
  background: var(--text);
  color: var(--bg);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  z-index: 1000;
  max-width: 400px;
  animation: toast-in 0.2s ease;
}
.toast.toast-success { background: var(--success); color: white; }
.toast.toast-error   { background: var(--error);   color: white; }
.toast.toast-warning { background: var(--warning); color: white; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* === Responsive === */

@media (max-width: 600px) {
  .app-main { padding: var(--sp-4) var(--sp-3); }
  .form-card { padding: var(--sp-4); }
  .form-row { grid-template-columns: 1fr 1fr; }
  .scope-meta-card { grid-template-columns: 1fr 1fr; }
  .view-header { flex-wrap: wrap; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
}


/* === Phase 29 — Dashboard footer === */

/* Subtle footer for the dashboard view only. Sits below the job list with
   a light separator. Social links + brand wordmark. Not pinned to viewport
   bottom — flows naturally below content. Empty-state and short job lists
   leave it close to the visible viewport; long lists push it down. */
.dashboard-footer {
  margin-top: 64px;
  padding: 24px 0 8px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-4);
}

.footer-socials {
  display: flex;
  gap: 18px;
}
.footer-socials a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--text-faint);
  transition: color 0.15s, transform 0.15s;
}
.footer-socials a:hover {
  color: var(--accent);
  transform: translateY(-1px);
}
.footer-socials svg {
  width: 20px;
  height: 20px;
  display: block;
}

.footer-brand {
  text-align: right;
}
.footer-brand-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: -0.01em;
}
.footer-brand-sub {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}

/* Stacked layout on narrow screens — socials on top, wordmark below. */
@media (max-width: 600px) {
  .dashboard-footer {
    flex-direction: column-reverse;
    gap: var(--sp-3);
    align-items: center;
  }
  .footer-brand {
    text-align: center;
  }
}
