/* Palette: "retain" (warm neutrals, graphite primary, amber accent).
   Light values follow the source theme; dark mode is derived from its sidebar tones. */
:root {
  --bg: #efe9e4;                        /* background.default */
  --surface: #ffffff;                   /* surface.card */
  --surface-alt: #f0e9e3;               /* surface.secondary */
  --text: #303030;                      /* text.primary */
  --muted: #66625e;                     /* text.secondary, darkened for 4.5:1 on --bg */
  --border: rgba(172, 167, 159, 0.3);   /* divider */
  --primary: #303030;                   /* primary.main */
  --primary-hover: #050505;             /* primary.dark */
  --primary-text: #efe9e4;              /* primary.contrastText */
  --link: #303030;
  --brand-accent: #df9760;              /* accent.main (decorative only) */
  --brand-accent-text: rgba(0, 0, 0, 0.87);
  --success: #677e24;                   /* success.dark: readable as text */
  --success-bg: rgba(139, 167, 60, 0.12);
  --danger: #bf3b2f;                    /* error.dark: readable as text */
  --danger-bg: rgba(218, 78, 66, 0.08);
  --input-bg: rgba(172, 167, 159, 0.08);
  --focus: rgba(223, 151, 96, 0.55);
  --topbar-bg: #303030;                 /* sidebar.background */
  --topbar-text: #f0e9e3;               /* sidebar.text */
  --topbar-muted: rgba(240, 233, 227, 0.62);
  --topbar-hover: rgba(240, 233, 227, 0.16);
  --radius: 6px;
  --radius-input: 4px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #252525;
    --surface: #303030;
    --surface-alt: #3a3a3a;
    --text: #f0e9e3;
    --muted: #aca79f;                   /* secondary.main */
    --border: rgba(172, 167, 159, 0.24);
    --primary: #f0e9e3;
    --primary-hover: #d5d3cf;           /* secondary.light */
    --primary-text: #303030;
    --link: #f0e9e3;
    --success: #acc85d;                 /* success.light */
    --success-bg: rgba(139, 167, 60, 0.16);
    --danger: #f77165;                  /* error.light */
    --danger-bg: rgba(218, 78, 66, 0.14);
    --input-bg: rgba(172, 167, 159, 0.1);
    --topbar-bg: #1c1c1c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter Tight", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--link); text-decoration-color: var(--brand-accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.container { max-width: 960px; margin: 0 auto; padding: 0 16px; }

.topbar { background: var(--topbar-bg); color: var(--topbar-text); }
.topbar-inner {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between; padding: 12px 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 1.15rem; color: var(--topbar-text); text-decoration: none;
}
.brand-mark { display: block; width: 28px; height: 28px; flex: none; }
.brand-tagline { font-weight: 400; font-size: .85rem; color: var(--topbar-muted); margin-inline-start: 2px; }
.nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.nav a, .nav .link-button {
  color: var(--topbar-text); text-decoration: none;
  padding: 4px 8px; border-radius: var(--radius-input);
}
.nav a:hover, .nav .link-button:hover { background: var(--topbar-hover); }
.nav .button {
  background: var(--brand-accent); border-color: var(--brand-accent); color: var(--brand-accent-text);
}
.nav .button:hover { background: #d37d3b; border-color: #d37d3b; }
.lang { display: inline-flex; gap: 2px; font-size: .85rem; color: var(--topbar-muted); }
.lang strong { padding: 4px 8px; color: var(--topbar-text); }
.lang a { color: var(--topbar-muted); }

main { padding-block: 24px calc(24px + var(--footer-height) + env(safe-area-inset-bottom)); }

h1 { font-size: 1.6rem; margin: 0 0 8px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.narrow { max-width: 440px; margin-inline: auto; }
.center { text-align: center; }
.muted { color: var(--muted); }

.hero { padding: 32px 0 16px; }
.lead { font-size: 1.1rem; max-width: 640px; color: var(--muted); }
.features { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.step {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-accent); color: var(--brand-accent-text); font-weight: 700;
}

.page-head {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: flex-start; justify-content: space-between; margin-bottom: 16px;
}

.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat { display: flex; flex-direction: column; border-top: 3px solid var(--brand-accent); }
.stat-value { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-link { color: inherit; text-decoration: none; }
.stat-link:hover { background: var(--surface-alt); }
.filters { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin: 0 0 16px; }

.button, .link-button { font: inherit; cursor: pointer; }
.button {
  display: inline-block; padding: 9px 16px; border-radius: var(--radius);
  border: 1px solid var(--primary); background: var(--primary); color: var(--primary-text);
  text-decoration: none; font-weight: 600;
}
.button:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.button.secondary { background: transparent; color: var(--text); border-color: var(--border); }
.button.secondary:hover { background: var(--input-bg); }
.button.small { padding: 5px 12px; }
.link-button { background: none; border: 0; padding: 0; color: var(--link); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.inline { display: inline; margin: 0; }

.form { display: grid; gap: 14px; margin: 16px 0; }
.form label { display: grid; gap: 4px; font-weight: 600; }
.form input, .form select {
  font: inherit; padding: 9px 10px; border-radius: var(--radius-input);
  border: 1px solid var(--border); background: var(--input-bg); color: var(--text);
}
.form input:focus, .form select:focus { border-color: var(--brand-accent); outline: none; box-shadow: 0 0 0 3px var(--focus); }

/* Selects: project chevron instead of the native arrow, themed option list. */
.form select {
  appearance: none; cursor: pointer;
  padding-inline-end: 34px;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
}
[dir="rtl"] .form select { background-position: left 12px center; }
.form select:hover { border-color: var(--muted); }
.form select:focus { border-color: var(--brand-accent); }
.form select option { background: var(--surface); color: var(--text); }
.form select option:checked { background: var(--surface-alt); }
.form select option[value=""] { color: var(--muted); }
:root { --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23303030' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
@media (prefers-color-scheme: dark) {
  :root { --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23f0e9e3' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
}

/* Browsers with customizable selects (Chromium 135+): fully themed picker. */
@supports (appearance: base-select) {
  .form select, .form select::picker(select) { appearance: base-select; }
  .form select { background-image: none; padding-inline-end: 10px; }
  .form select::picker-icon {
    content: ""; width: 12px; height: 8px;
    background: var(--select-chevron) no-repeat center / contain;
    transition: rotate .15s ease;
  }
  .form select:open::picker-icon { rotate: 180deg; }
  .form select::picker(select) {
    margin-block: 4px; padding: 4px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-input);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  }
  .form select option {
    padding: 8px 10px; border-radius: var(--radius-input);
    background: transparent; font-weight: 400;
  }
  .form select option:hover, .form select option:focus-visible { background: var(--input-bg); outline: none; }
  .form select option:checked { background: var(--surface-alt); font-weight: 600; }
  .form select option::checkmark { color: var(--brand-accent); }
}
.form small { font-weight: 400; }
.editor { max-width: 840px; margin-inline: auto; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.form-grid > label { min-width: 0; align-content: start; }
.form input, .form select { min-width: 0; width: 100%; }
.form .checkline { display: flex; flex-direction: row; align-items: center; gap: 10px; }
.checkline input { width: auto; }
.form fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; }
.field-error { color: var(--text); font-weight: 600; }
.form [aria-invalid="true"] { border-color: #bd3d36; }
.button:disabled { opacity: .55; cursor: not-allowed; }
.form input:disabled { opacity: .6; }
.button.danger { background: #ad302b; border-color: #ad302b; color: #fff; }
.part-description { display: block; color: var(--muted); font-weight: 400; }
.constraint-list { padding-inline-start: 18px; margin: 0; font-size: .9rem; }
.material-group + .material-group { border-top: 1px solid var(--border); margin-block-start: 24px; padding-block-start: 12px; }
.material-group h3, #material-info { overflow-wrap: anywhere; }
.offer-filters { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); align-items: end; }

.form-errors {
  color: var(--danger); background: var(--danger-bg); border: 1px solid var(--danger);
  border-radius: var(--radius-input); padding: 10px 10px 10px 28px; margin: 12px 0;
}
.flash {
  padding: 10px 14px; border-radius: var(--radius-input);
  border: 1px solid var(--border); background: var(--surface);
}
.flash-success { border-color: var(--success); color: var(--success); background: var(--success-bg); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: .9rem; }
tbody tr:hover { background: var(--input-bg); }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: var(--surface-alt); border: 1px solid var(--border); font-size: .8rem; color: var(--muted);
}
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.status-code { font-size: 3rem; color: var(--brand-accent); }
/* Footer: dark bar fixed to the bottom edge of the viewport, same tones as the
   top bar. main reserves its height so content is never hidden behind it. */
:root { --footer-height: 56px; }
.footer {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 10;
  height: calc(var(--footer-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; align-items: center;
  background: var(--topbar-bg); color: var(--topbar-muted); font-size: .9rem;
}
.footer-inner {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.footer-links {
  display: flex; align-items: center; gap: 20px; min-width: 0;
  overflow-x: auto; white-space: nowrap; scrollbar-width: none;
}
.footer-links::-webkit-scrollbar { display: none; }
.footer-copy { color: var(--topbar-text); }
.footer-links a { color: var(--topbar-muted); text-decoration: none; }
.footer-links a:hover { color: var(--topbar-text); }
.footer-brand {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  color: var(--topbar-text); text-decoration: none; font-weight: 700; font-size: 1.1rem;
}
.footer-brand img { display: block; }

/* Narrow screens: links stay on one row and scroll sideways; the wordmark folds
   to the icon so the bar keeps its height. */
@media (max-width: 640px) {
  .footer-links { gap: 16px; }
  .footer-brand span { display: none; }
}
