/* Custom PnL: graphite glass, with color reserved for state and the user's samples. */
:root {
  color-scheme: dark;
  font: 13px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #1b1d1c;
  --surface: #272a28;
  --control: #303431;
  --hover: #3b403c;
  --well: #1b1e1c;
  --line: #ffffff12;
  --border: #ffffff24;
  --border-hover: #ffffff42;
  --text: #edf0ee;
  --muted: #afb7b1;
  --disabled: #7d847f;
  --accent: #8dd8b5;
  --accent-ink: #c7f1dc;
  --focus: #a0dfc0;
  --error: #ff9da6;
  --glass: linear-gradient(145deg, #ffffff06, #ffffff00 150px);
  --glint: inset 0 1px 0 #ffffff08;
  --ease: cubic-bezier(.2, 0, 0, 1);
  color: var(--text);
  background: radial-gradient(ellipse at 14% 0, #738b7910, transparent 290px), var(--bg);
}
* { box-sizing: border-box; }
body {
  width: 340px; max-height: 600px; overflow-y: auto; scrollbar-gutter: stable;
  margin: 0; padding: 20px 20px 0; -webkit-font-smoothing: antialiased;
  scrollbar-width: thin; scrollbar-color: #65726980 transparent;
}
.brand-header { text-align: center; padding: 0 0 12px; margin-bottom: 12px; }
.brand-title { display: flex; align-items: center; justify-content: center; gap: 8px; }
.brand-mark { display: block; width: 30px; height: 30px; flex: none; }
h1 { margin: 0; font-size: 21px; line-height: 1.3; font-weight: 650; letter-spacing: -.45px; }
.brand-header p { margin-top: 5px; font-size: 11px; line-height: 1.5; color: var(--muted); }
h2 { margin: 0; color: var(--text); font-size: 12px; font-weight: 600; line-height: 1.5; }
p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
main { padding: 0; }
label { cursor: pointer; }
input, button, select { font: inherit; }
.general-settings, .customize-section { border: 1px solid var(--border); background: var(--glass), var(--surface); box-shadow: var(--glint), 0 4px 12px #00000014; border-radius: 12px; }
.general-settings { padding: 5px 12px 7px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; min-height: 42px; gap: 12px; font-size: 13px; }
.setting-row + .setting-row { border-top: 1px solid var(--line); }
.debug-row { color: var(--muted); font-size: 12px; }
input[type=checkbox] { appearance: none; width: 34px; height: 20px; border: 1px solid #ffffff30; border-radius: 12px; background: #141a16; box-shadow: inset 0 1px 2px #0003; position: relative; cursor: pointer; margin: 0; flex: none; transition: background-color 160ms var(--ease), border-color 160ms var(--ease), box-shadow 160ms var(--ease); }
input[type=checkbox]::after { content: ""; position: absolute; left: 3px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #abb7ae; box-shadow: inset 0 1px 1px #ffffff30, 0 1px 2px #0003; transition: transform 160ms var(--ease), background-color 160ms var(--ease); }
input[type=checkbox]:checked { background: #39795b; border-color: #77c59b; }
input[type=checkbox]:checked::after { transform: translateX(14px); background: #effaf3; }
input[type=checkbox]:hover { box-shadow: 0 0 0 3px #ffffff08; }
input:focus-visible, button:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.display-setting { border: 0; padding: 0; margin: 14px 0 8px; min-width: 0; }
.display-setting legend { color: var(--muted); font-size: 11px; font-weight: 550; padding: 0; margin-bottom: 8px; }
.segments { display: flex; gap: 3px; padding: 4px; border: 1px solid var(--line); border-radius: 9px; background: #11171380; box-shadow: inset 0 1px 2px #0002; }
.segments label { position: relative; flex: 1; text-align: center; }
.segments input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segments span { display: block; padding: 8px 0; border-radius: 6px; color: var(--muted); font-size: 13px; font-weight: 500; line-height: 16px; box-shadow: inset 0 0 0 1px transparent; transition: background-color 160ms var(--ease), color 160ms var(--ease), box-shadow 160ms var(--ease); }
.segments label:hover span { background: #ffffff08; color: var(--text); }
.segments input:checked+span { color: var(--accent-ink); background: #355044; box-shadow: inset 0 0 0 1px #8dd8b526, inset 0 1px 0 #ffffff08, 0 1px 3px #0002; font-weight: 600; }
.segments input:focus-visible+span { outline: 2px solid var(--focus); outline-offset: 1px; }
button { font-size: 12px; font-weight: 550; line-height: 1.2; min-height: 32px; padding: 7px 10px; margin: 0; border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: linear-gradient(#ffffff04, #ffffff00), var(--control); box-shadow: var(--glint); cursor: pointer; transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease); }
button:hover:not(:disabled) { background-color: var(--hover); border-color: var(--border-hover); }
button:active:not(:disabled) { background-color: #222a25; }
button:disabled, select:disabled { color: var(--disabled); cursor: default; }
button:disabled { background: #ffffff02; border-color: var(--line); box-shadow: none; }
.small-button { min-height: 28px; padding: 5px 9px; font-size: 11px; }
.primary-button { color: var(--accent-ink); border-color: #8dd8b542; background-color: #304f3f; }
.primary-button:hover:not(:disabled) { background-color: #3a604c; border-color: #8dd8b57a; }
.primary-button:active:not(:disabled) { background-color: #294536; }
.customize-section { overflow: clip; margin: 14px 0 18px; }
.disclosure { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: 0; background: transparent; box-shadow: none; font-size: 13px; font-weight: 600; }
.disclosure:hover:not(:disabled) { background-color: #ffffff05; color: #fff; }
.disclosure:active:not(:disabled) { background-color: #ffffff08; }
.disclosure:focus-visible { outline-offset: -4px; border-radius: 11px; }
.disclosure svg { color: var(--muted); transition: transform 240ms var(--ease); }
.disclosure[aria-expanded=true] svg { transform: rotate(180deg); }
/* Paint containment also clears Chrome's old popup scroll range after collapse. */
.disclosure-panel { contain: paint; display: grid; grid-template-rows: 0fr; transition: grid-template-rows 240ms var(--ease); }
.disclosure-panel.expanded { grid-template-rows: 1fr; }
.disclosure-inner { overflow: hidden; min-height: 0; }
.customize-content { padding: 8px 12px 14px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
/* Equal insets preserve the compact, aligned previews. */
.label-preview, .frame-preview { display: grid; padding: 9px; margin: 11px 0 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--well); box-shadow: inset 0 1px 2px #0002; }
.label-preview { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.label-preview output { position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 18px; line-height: 18px; text-align: center; }
.label-preview output > span { flex: none; }
.label-preview output + output::before { content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: 1px; background: #ffffff0b; }
.color-row { display: flex; align-items: center; min-height: 42px; gap: 8px; font-size: 12px; }
.color-row>label { flex: 1; }
.hint { font-size: 11px; color: var(--muted); }
input[type=color] { appearance: none; -webkit-appearance: none; flex: none; width: 32px; height: 32px; padding: 5px; border: 1px solid var(--border); border-radius: 7px; background: var(--control); box-shadow: var(--glint); cursor: pointer; transition: border-color 150ms var(--ease), background-color 150ms var(--ease); }
input[type=color]:hover { border-color: var(--border-hover); background-color: var(--hover); }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 3px; }
.color-reset { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; min-height: 32px; padding: 0; color: var(--muted); }
.color-reset svg { display: block; }
.color-reset:hover:not(:disabled) { color: var(--text); }
.font-options { display: flex; gap: 24px; margin-top: 13px; padding: 15px 0; border-top: 1px solid var(--line); }
.font-options label { display: flex; align-items: center; justify-content: space-between; flex: 1; gap: 10px; min-height: 28px; font-size: 12px; }
.bold-label { font-weight: 650; }
.italic-label { font-style: italic; }
.frame-colors { padding: 15px 0; border-top: 1px solid var(--line); }
.preset-section { border-top: 1px solid var(--line); padding-top: 16px; }
.preset-section h2 { margin-bottom: 9px; }
select, input[type=text] { width: 100%; min-height: 36px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--well); color: var(--text); font-size: 12px; box-shadow: inset 0 1px 2px #0002; transition: border-color 150ms var(--ease); }
/* Native menus keep platform behavior; the closed arrow has a consistent inset. */
select { appearance: none; cursor: pointer; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23b8c6bd' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m2 4 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 12px 12px; }
select:hover:not(:disabled), input[type=text]:hover { border-color: var(--border-hover); }
select option { background-color: var(--surface); color: var(--text); }
input::placeholder { color: var(--muted); }
.preset-actions { display: flex; gap: 8px; margin-top: 9px; }
.preset-actions button { flex: 1; padding-inline: 5px; }
#preset-delete:hover:not(:disabled) { color: #ffabb2; border-color: #ff9da650; background-color: #492d32; }
.editor-actions { display: flex; gap: 8px; margin-top: 9px; }
#preset-editor { margin-top: 10px; }
#preset-editor[hidden], #preset-saved[hidden] { display: none; }
.preset-name-field { position: relative; }
.preset-name-field:has(#preset-saved:not([hidden])) input { padding-right: 40px; }
#preset-saved { position: absolute; top: 1px; right: 2px; bottom: 1px; width: 30px; min-height: 0; padding: 0; border: 0; border-radius: 5px; color: transparent; background-color: transparent; background-position: center; box-shadow: none; }
#preset-saved:hover:not(:disabled) { background-color: #ffffff08; }
#preset-saved:focus-visible { outline-offset: -2px; }
/* Keep this inset inside scrollable content, including expanded Customize. */
footer { padding: 15px 0 18px; border-top: 1px solid var(--line); }
footer>p:first-child { color: #c4cec7; font-size: 12px; font-weight: 500; }
footer>p:nth-child(2) { margin-top: 3px; font-size: 11px; color: var(--muted); }
#message { color: var(--error); margin-top: 8px; }
#message:empty, #connection-message:empty { display: none; }
#connection-message { margin-top: 10px; padding: 8px 10px; border: 1px solid #d7ba7826; border-radius: 7px; color: #decda6; background: #d7ba7808; font-size: 11px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Non-interactive samples retain the user's colors. */
.frame-preview { grid-template-columns: 1.2fr 1fr 1fr; gap: 7px; }
.order-sample { display: grid; grid-template-columns: 18px minmax(0, 1fr) 18px; align-items: stretch; min-width: 0; height: 26px; border: 1px solid currentColor; border-radius: 5px; overflow: hidden; background: color-mix(in srgb, currentColor 4%, #242424); font-size: 11px; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
.sample-qty, .sample-name, .sample-close { display: flex; align-items: center; justify-content: center; min-width: 0; }
.sample-qty { border-right: 1px solid color-mix(in srgb, currentColor 22%, transparent); }
.entry-sample .sample-qty { border-right: 0; }
.sample-name { padding: 0 2px; }
.sample-close { border-left: 1px solid color-mix(in srgb, currentColor 22%, transparent); }
.sample-close svg { display: block; width: 10px; height: 10px; flex: none; }
.order-sample .sample-name, .order-sample .sample-close,
.order-sample:not(.entry-sample) .sample-qty { background-color: var(--label-surface, transparent); }
#diagnostics-panel { margin-top: 12px; }
#diagnostics-message { margin-top: 6px; font-size: 11px; }
#diagnostics-output { width: 100%; min-height: 90px; resize: vertical; margin-top: 8px; padding: 8px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: var(--well); font: 11px/1.5 monospace; }

/* Shared color dialog: stable controls while changing palette/editor/format. */
#color-picker { width: 292px; max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); overflow-y: auto; scrollbar-width: thin; padding: 16px; border: 1px solid #ffffff30; border-radius: 14px; background: var(--glass), #292d2af5; color: var(--text); box-shadow: inset 0 1px 0 #ffffff0d, 0 16px 44px #0008, 0 2px 8px #0004; }
#color-picker::backdrop { background: #080c0a99; backdrop-filter: blur(3px); }
.picker-heading { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 14px; }
.picker-heading h2 { font-size: 13px; }
#picker-close { display: flex; align-items: center; justify-content: center; flex: none; padding: 0; width: 28px; min-height: 28px; background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
#picker-close:hover { background-color: #ffffff09; color: var(--text); }
#picker-close svg { width: 14px; height: 14px; }
#picker-title:focus { outline: none; }
.picker-stage { display: grid; min-height: 212px; }
#picker-palette, #picker-custom { grid-area: 1 / 1; align-self: start; }
#picker-palette { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 5px; }
.palette-color { position: relative; width: 100%; min-height: 0; aspect-ratio: 1; padding: 0; border: 0; border-radius: 3px; background: var(--swatch); box-shadow: none; outline: 2px solid transparent; outline-offset: 2px; transition: none; }
.palette-color:nth-child(n+11):nth-child(-n+20) { margin-bottom: 6px; }
.palette-color:hover:not(:disabled), .palette-color:active:not(:disabled) { background: var(--swatch); outline: 2px solid #eeeeee66; outline-offset: 2px; z-index: 1; }
#picker-palette .palette-color[aria-pressed=true] { outline: 2px solid #eee; outline-offset: 2px; z-index: 1; }
#picker-palette .palette-color:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
#picker-palette[hidden], #picker-custom[hidden], #picker-channels[hidden], #picker-hex-fields[hidden] { display: none; }
.picker-value-row { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 12px; }
#picker-hex-fields, #picker-channels { flex: 1; min-width: 0; }
#picker-hex { min-height: 34px; height: 34px; text-align: center; font-size: 14px; padding: 7px; font-variant-numeric: tabular-nums; }
#picker-format { width: 66px; min-height: 34px; height: 34px; flex: 0 0 66px; margin: 0; padding: 6px 27px 6px 8px; font-size: 11px; font-weight: 600; text-align: center; }
#picker-channels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
#picker-channels label { position: relative; min-width: 0; text-align: center; color: var(--muted); }
#picker-channels label span { position: absolute; top: 3px; left: 0; right: 0; font-size: 9px; line-height: 10px; pointer-events: none; }
#picker-channels input { width: 100%; min-width: 0; height: 34px; margin: 0; padding: 12px 2px 2px; border: 1px solid var(--border); border-radius: 7px; background: var(--well); color: var(--text); text-align: center; font: inherit; font-size: 11px; font-variant-numeric: tabular-nums; appearance: textfield; }
#picker-channels input::-webkit-inner-spin-button, #picker-channels input::-webkit-outer-spin-button { appearance: none; margin: 0; }
#picker-hex[aria-invalid=true], #picker-channels input[aria-invalid=true] { border-color: var(--error); }
.picker-custom-gradient { display: grid; grid-template-columns: minmax(0, 1fr) 12px; gap: 12px; align-items: stretch; }
#picker-plane { position: relative; height: 160px; border-radius: 5px; background-image: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent); touch-action: none; cursor: crosshair; }
#picker-plane:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
#picker-cursor { position: absolute; width: 12px; height: 12px; border: 2px solid white; border-radius: 50%; box-shadow: 0 0 2px 1px #0008; transform: translate(-50%, -50%); pointer-events: none; }
#picker-hue { appearance: none; writing-mode: vertical-lr; direction: rtl; width: 12px; height: 160px; min-width: 0; margin: 0; border-radius: 6px; background: linear-gradient(to top,red,#ff0,#0f0,#0ff,#00f,#f0f,red); cursor: pointer; }
#picker-hue::-webkit-slider-thumb { appearance: none; width: 18px; height: 8px; border: 2px solid #fff; border-radius: 2px; background: transparent; box-shadow: 0 0 2px #000; }
.picker-opacity-heading { display: flex; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.picker-tools { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; }
#picker-eyedropper, #picker-swatch { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 30px; width: 30px; height: 30px; min-height: 30px; padding: 0; }
#picker-eyedropper svg { display: block; flex: none; }
#picker-eyedropper[hidden] { display: none; }
#picker-swatch { padding: 4px; }
#picker-swatch[aria-expanded=true] { border-color: var(--accent); }
#picker-swatch-color { display: block; width: 20px; height: 20px; border-radius: 3px; background: var(--picked-color); }
#picker-opacity { appearance: none; min-width: 0; flex: 1; height: 10px; margin: 0; border-radius: 5px; background: linear-gradient(to right, transparent, var(--opacity-color, #fff)), repeating-conic-gradient(#59645d 0% 25%, #2a332d 0% 50%) 0 / 8px 8px; cursor: pointer; }
#picker-opacity::-webkit-slider-thumb { appearance: none; width: 16px; height: 16px; border: 2px solid #edf2ee; border-radius: 50%; background: #3a443d; box-shadow: 0 1px 3px #0008; }
.opacity-value { display: flex; align-items: center; justify-content: center; gap: 1px; flex: 0 0 49px; min-width: 0; height: 30px; padding: 0 5px; border: 1px solid var(--border); border-radius: 7px; background: var(--well); color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.opacity-value:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
#picker-opacity-value { width: 3ch; min-width: 0; height: 100%; margin: 0; padding: 0; border: 0; color: var(--text); background: transparent; text-align: right; font: inherit; appearance: textfield; }
#picker-opacity-value:focus-visible { outline: none; }
#picker-opacity-value::-webkit-inner-spin-button, #picker-opacity-value::-webkit-outer-spin-button { appearance: none; margin: 0; }
#picker-error { color: var(--error); font-size: 11px; margin-top: 8px; }
#picker-error:empty { display: none; }
/* Short fades only: no expensive animated blur or moving controls. */
@keyframes reveal-content { from { opacity: 0; } to { opacity: 1; } }
#picker-palette:not([hidden]), #picker-custom:not([hidden]), #preset-editor:not([hidden]) { animation: reveal-content 140ms var(--ease); }
/* Progressive enhancement: older supported Chrome retains native dialog behavior. */
@supports (transition-behavior: allow-discrete) {
  #color-picker { opacity: 0; transform: translateY(4px); transition: opacity 140ms var(--ease), transform 140ms var(--ease), display 140ms allow-discrete, overlay 140ms allow-discrete; }
  #color-picker[open] { opacity: 1; transform: translateY(0); }
  #color-picker::backdrop { opacity: 0; transition: opacity 140ms var(--ease), display 140ms allow-discrete, overlay 140ms allow-discrete; }
  #color-picker[open]::backdrop { opacity: 1; }
  @starting-style {
    #color-picker[open] { opacity: 0; transform: translateY(4px); }
    #color-picker[open]::backdrop { opacity: 0; }
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, *::backdrop { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  :root, .general-settings, .customize-section, #color-picker { background: Canvas; }
  button, select, input { box-shadow: none; }
  select { appearance: auto; background-image: none; }
  #preset-saved { color: ButtonText; }
  input[type=checkbox] { appearance: auto; }
  input[type=checkbox]::after { display: none; }
  .segments input { position: static; opacity: 1; width: auto; height: auto; }
  .segments input:checked+span { outline: 1px solid Highlight; }
  #color-picker::backdrop { backdrop-filter: none; }
}
