@media screen {
  /* Sapphire accents keep the previous lightness with 70% of the original saturation. */
  :root[data-theme="sapphire"] {
    color-scheme: dark;
    --ink: #e7ecf3;
    --muted: #b5bdc9;
    --green: #8fa7d1;
    --line: #3a4153;
    --paper: #161a25;
    --field: #131722;
    --raised: #1f2534;
    --hover: #2a3549;
    --danger: #ffc0b7;
    --warm-text: #f2d5a4;
    --selection-row: #26354d;
    background: #0d1019;
  }

  [data-theme="sapphire"] :focus-visible { outline-color: #8ea7d1; }
  [data-theme="sapphire"] .topbar { background: #13192b; border-bottom: 1px solid #303850; }
  [data-theme="sapphire"] .brand small { color: #d4dade; }
  [data-theme="sapphire"] .button.subtle { border-color: #606875; }
  [data-theme="sapphire"] .button:not(.subtle, .centre, .primary, .betula, .minimal) { background: var(--raised); }
  [data-theme="sapphire"] .button:is(.subtle, .centre):hover,
  [data-theme="sapphire"] .button:not(.primary, .betula):hover:enabled { border-color: #4f5e7d; background: var(--hover); }
  [data-theme="sapphire"] .button.primary { border-color: #43557e; background: #23305c; }
  [data-theme="sapphire"] .button.primary:hover:enabled { background: #283867; }
  [data-theme="sapphire"] .button.danger,
  [data-theme="sapphire"] .status.error { color: var(--danger); }
  [data-theme="sapphire"] .button.danger:hover:enabled { border-color: #a66765; background: #512e30; }
  [data-theme="sapphire"] .button[aria-pressed="true"] { border-color: #62739d; background: #232c45; color: #e7ecf3; }

  [data-theme="sapphire"] :is(.field input, .field select) { border-color: #464f5f; background: var(--field); }
  [data-theme="sapphire"] input::placeholder { color: #979ea7; opacity: 1; }
  [data-theme="sapphire"] :is(.material-set, .material-tab[role="tab"]) {
    --material-pastel: hsl(var(--material-hue, 151) 48% 91%);
    --material-pastel-active: hsl(var(--material-hue, 151) 62% 83%);
    --material-border: hsl(var(--material-hue, 151) 31% 55%);
  }
  [data-theme="sapphire"] .material-tab[role="tab"] { color: #1c212b; }
  [data-theme="sapphire"] .material-tab.add-set-tab { background: var(--raised); }
  [data-theme="sapphire"] .material-tab.add-set-tab:hover { background: var(--hover); }
  [data-theme="sapphire"] .material-set { background: var(--paper); }
  [data-theme="sapphire"] .material-form {
    border-inline-start: 3px solid var(--material-pastel-active);
    background: var(--raised);
  }
  [data-theme="sapphire"] .parts-heading { background: var(--raised); }
  [data-theme="sapphire"] .part-row { border-color: var(--line); }
  [data-theme="sapphire"] .part-row:nth-child(even):not([data-unplaced]) { background: #1d2332; }
  [data-theme="sapphire"] .part-row:focus-within:not([data-unplaced]) { background: var(--raised); }
  [data-theme="sapphire"] .part-row[data-unplaced] { background: #4b292e; box-shadow: inset 3px 0 #f09184; }
  [data-theme="sapphire"] .part-row[data-unplaced]:focus-within { background: #5a3136; }
  [data-theme="sapphire"] .part-row[data-unplaced] input:not([type="checkbox"]) { border-color: #996662; background: #2f2224; }
  [data-theme="sapphire"] .part-edge input[type="checkbox"] { accent-color: #d6a467; }
  [data-theme="sapphire"] .pcv-options { border-color: var(--line); box-shadow: 0 4px 16px #0006; }
  [data-theme="sapphire"] .pcv-options :is([role="option"]:hover, [aria-selected="true"]) { background: var(--hover); }

  [data-theme="sapphire"] :is(.summary div, .floating-summary-header, .floating-summary-stats tfoot th, .floating-summary-stats tfoot td, .gallery-preview) { background: var(--raised); }
  [data-theme="sapphire"] .floating-summary { border-color: var(--line); box-shadow: 0 5px 16px #0006; }
  [data-theme="sapphire"] :is(.floating-summary-close:hover, .floating-summary-stats tbody tr:nth-child(odd)) { background: #202737; }
  [data-theme="sapphire"] :is(.unplaced, .tape-summary) { border-color: #7c6240; background: #312a20; color: var(--warm-text); }
  [data-theme="sapphire"] :is(.tape-summary p, .row-tape) { color: var(--warm-text); }
  [data-theme="sapphire"] .banded-dimension { text-decoration-color: #e6b778; }
  [data-theme="sapphire"] .sheet-table button[aria-pressed="true"] { color: #c5e3ff; }
  [data-theme="sapphire"] #move-status { color: var(--muted); }
  [data-theme="sapphire"] .result-panel:has(#sheets.dragging) #move-status { background: var(--raised); color: var(--ink); }
  [data-theme="sapphire"] dialog { background: var(--paper); }
  [data-theme="sapphire"] dialog::backdrop { background: #06080eaa; }

  [data-theme="sapphire"] .diagram { background: #0f131e; }
  [data-theme="sapphire"] .diagram .stock { fill: #242a39; stroke: #7d8598; }
  [data-theme="sapphire"] .diagram .inside { fill: #161a27; stroke: #787f91; }
  [data-theme="sapphire"] .diagram .offcut { fill: #212634; stroke: #7d8594; }
  [data-theme="sapphire"] .diagram .offcut-dimensions { fill: #c1c8d5; }
  [data-theme="sapphire"] .diagram .cuts { stroke: #dca87e; }
}
