:root {
  color-scheme: light;
  font-family: Inter, system-ui, sans-serif;
  --sidebar: #efeeec;
  --surface: #f7f7f7;
  --card: #fff;
  --subtle: #ecebe9;
  --line: #e4e2df;
  --ink: #171717;
  --muted: #595652;
  --primary: #171717;
  --on-primary: #fff;
  --primary-hover: #383635;
  --danger-bg: #f9dfe0;
  --danger: #913b43;
  --warning-bg: #f8e8db;
  --warning: #82441e;
  --success-bg: #def2e2;
  --success: #2e6140;
  --accent-bg: #eae0f5;
  --accent: #644286;
  --shadow: 0 16px 45px #3b302218;
  --radius: 12px;
  color: var(--ink);
  background: var(--surface);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --sidebar: #1b1a1c;
  --surface: #222124;
  --card: #2a282c;
  --subtle: #343137;
  --line: #45414a;
  --ink: #f2eff3;
  --muted: #c3bdc6;
  --primary: #ede8f0;
  --on-primary: #211e23;
  --primary-hover: #d7cedd;
  --danger-bg: #482b31;
  --danger: #ffb8c0;
  --warning-bg: #473325;
  --warning: #ffc799;
  --success-bg: #233d30;
  --success: #a4e1b6;
  --accent-bg: #3e3050;
  --accent: #d8b9f6;
  --shadow: 0 16px 45px #0007;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 14px; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[data-icon] { display: inline-flex; flex: none; align-items: center; }
[data-icon] svg { width: 18px; height: 18px; }
[data-icon] .filled,
:is([aria-current="page"], [aria-pressed="true"], [aria-expanded="true"]) [data-icon] .unfilled { display: none; }
:is([aria-current="page"], [aria-pressed="true"], [aria-expanded="true"]) [data-icon] .filled { display: block; }
.workspace {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  height: 100dvh;
  grid-template-rows: minmax(0, 1fr);
  background: var(--surface);
}
.sidebar { display: flex; flex-direction: column; overflow: auto; background: var(--sidebar); border-right: 1px solid var(--line); padding: 16px 12px; }
.workspace > main { min-width: 0; overflow: auto; background: var(--sidebar); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 4px; margin-bottom: 14px; font-weight: 750; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; flex: none; background: #000; border: 1px solid var(--line); border-radius: 11px; }
.brand img { object-fit: contain; }
small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; margin-top: 3px; }
nav p { margin: 20px 8px 8px; color: var(--muted); font-size: 11px; }
nav a, .sidebar-actions button, .chat-tools button { display: flex; align-items: center; gap: 8px; min-height: 38px; border-radius: 8px; padding: 7px 9px; color: var(--ink); }
nav a:hover, nav a[aria-current="page"], .sidebar-actions button:hover { background: var(--card); }
nav a[aria-current="page"] { font-weight: 700; box-shadow: 0 1px 3px #1717170a; }
#workspace-nav a { white-space: nowrap; }
.sidebar .sidebar-search input { width: 100%; min-width: 0; }
.menu-empty { padding: 10px 8px; color: var(--muted); font-size: 12px; }
.sidebar-footer { margin-top: auto; padding-top: 12px; }
.sidebar-actions { display: flex; flex-direction: column; gap: 2px; }
.sidebar-actions hr { margin: 4px 9px; border: 0; border-top: 1px solid var(--line); }
.sidebar-actions button { border: 0; background: transparent; text-align: left; font-size: 13px; }
.sidebar-actions svg { width: 18px; height: 18px; flex: none; }
.profile-card { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 240px; height: 35px; padding: 0 7px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 12px; }
.profile-avatar { display: grid; place-items: center; width: 24px; height: 24px; flex: none; overflow: hidden; border-radius: 6px; background: var(--accent-bg); color: var(--accent); font-weight: 700; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; line-height: 1.25; font-weight: 650; }
.account-email { margin: 3px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.account-email:empty { display: none; }
.topbar { min-height: 60px; padding: 8px 21px; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--sidebar); border-bottom: 1px solid var(--line); }
.breadcrumb, .top-actions { display: flex; align-items: center; gap: 9px; }
.top-actions { min-width: 0; margin-inline-start: auto; }
.topbar { position: sticky; top: 0; z-index: 1; }
.breadcrumb { color: var(--muted); font-size: 12px; }
.breadcrumb strong { color: var(--ink); }
.button, .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 35px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; font-weight: 650; color: var(--ink); background: var(--card); white-space: nowrap; }
.icon-button { min-width: 35px; position: relative; padding: 5px; }
.button.secondary:hover, .icon-button:hover { background: var(--subtle); }
.button.primary { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
.button.primary:hover { background: var(--primary-hover); }
.icon-button i, .reorder-dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.content { min-height: calc(100% - 68px); margin: 4px; padding: 27px 26px 32px; border-radius: 8px; background: var(--surface); }
.page-heading { margin: 0 0 19px; }
h1 { font-size: clamp(22px, 3vw, 29px); letter-spacing: -.045em; }
h2 { font-size: 17px; letter-spacing: -.025em; }
.page-heading p, .section-heading p, .chat-header p { margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.notice { display: flex; align-items: center; gap: 10px; padding: 7px; border-radius: 9px; background: var(--subtle); margin-bottom: 14px; }
.notice p { flex: 1; color: var(--muted); font-size: 12px; line-height: 1.5; }
.notice strong { color: var(--ink); }
.notice-icon, .metric-icon, .training-icon { width: 32px; height: 32px; display: inline-grid; place-items: center; flex: none; border-radius: 8px; background: var(--accent-bg); color: var(--accent); }
.notice-icon { background: var(--danger-bg); color: var(--danger); }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 19px; }
.metrics a { display: grid; gap: 4px; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--surface); }
.metrics a:hover { background: var(--card); }
.metric-icon { color: var(--on-primary); background: var(--primary); margin-bottom: 4px; }
.metric-icon.danger { color: var(--danger); background: var(--danger-bg); }
.metrics strong { font-size: 22px; line-height: 1; }
.metrics a > span:last-child { color: var(--muted); font-size: 12px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 14px; }
.table-scroll { overflow-x: auto; }
.stock-row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
th, td { padding: 10px 13px; border-top: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; color: var(--muted); background: var(--surface); white-space: nowrap; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td:first-child { min-width: 132px; }
td:last-child { text-align: right; }
.pill { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 20px; white-space: nowrap; font-size: 11px; font-weight: 650; }
.pill.out { color: var(--danger); background: var(--danger-bg); }
.pill.low { color: var(--warning); background: var(--warning-bg); }
.pill.ready { color: var(--success); background: var(--success-bg); }
.training-preview { margin-top: 17px; }
.training-preview .section-heading { padding-inline: 0; }
.training-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.training-card { display: grid; gap: 8px; justify-items: start; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.training-card h3 { font-size: 14px; }
.training-card p { color: var(--muted); font-size: 12px; line-height: 1.45; }
.training-card button { margin-top: 2px; align-self: end; }
.search { display: flex; align-items: center; gap: 6px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--card); }
.search:focus-within { outline: 2px solid var(--accent); }
.search input { width: 180px; max-width: 100%; padding: 8px 0; color: var(--ink); border: 0; background: transparent; outline: none; font-size: 12px; }
.training-search { width: fit-content; margin-bottom: 12px; }
.segments { display: grid; grid-template-columns: repeat(4, 1fr); width: max-content; max-width: 100%; gap: 3px; padding: 3px; border-radius: 8px; background: var(--subtle); }
.segments button { min-height: 32px; padding: 5px 13px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; }
.segments button[aria-pressed="true"] { background: var(--card); color: var(--ink); }
.segments button[data-stock="reorder"] { position: relative; }
.table-note, .empty { padding: 13px; color: var(--muted); font-size: 12px; }
.table-note { border-top: 1px solid var(--line); }
.chat-layout { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 12px; align-items: start; }
.chat-tools { padding: 10px; }
.chat-tools h2 { margin: 4px 8px 7px; }
.chat-tools button { width: 100%; border: 0; background: transparent; text-align: left; font-size: 12px; }
.chat-tools button:hover, .chat-tools button[aria-pressed="true"] { background: var(--subtle); }
.chat-tools button[aria-pressed="true"] { font-weight: 700; }
.chat-tool-label { display: grid; white-space: nowrap; }
.chat-tool-label > * { grid-area: 1 / 1; }
/* Reserve the bold label width even when the button is inactive. */
.chat-tool-label strong { visibility: hidden; font-weight: 700; }
.chat-header { display: flex; align-items: center; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); }
.chat-header .notice-icon { background: var(--accent-bg); color: var(--accent); }
.messages { display: flex; flex-direction: column; gap: 10px; min-height: 245px; max-height: 380px; overflow: auto; padding: 14px; }
.message { max-width: min(90%, 540px); padding: 9px 12px; border-radius: 10px; background: var(--subtle); font-size: 13px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user { align-self: end; background: var(--accent-bg); }
.chat-form { border-top: 1px solid var(--line); padding: 12px; }
.chat-form textarea, .price-form input { display: block; width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px; color: var(--ink); background: var(--surface); }
.chat-form textarea { resize: vertical; }
.composer-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }
.upload { cursor: pointer; position: relative; }
.upload:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.attachment { display: flex; align-items: center; gap: 5px; margin-bottom: 7px; overflow-wrap: anywhere; }
.form-error { color: var(--danger); font-size: 12px; }
.form-error:not(:empty) { margin-top: 7px; }
dialog { width: min(520px, calc(100% - 28px)); max-height: calc(100dvh - 28px); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; color: var(--ink); background: var(--card); box-shadow: var(--shadow); }
dialog::backdrop { background: #17171765; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
#dialog-body { padding: 16px; line-height: 1.55; }
#dialog-body li + li { margin-top: 7px; }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.breadcrumb a { display: inline; min-height: 0; padding: 0; font: inherit; text-decoration: none; }
.workspace > main:has([data-page="training-detail"]:not([hidden])) {
  display: flex;
  flex-direction: column;
}
.workspace > main:has([data-page="training-detail"]:not([hidden])) > .topbar { flex: none; }
.content:has([data-page="training-detail"]:not([hidden])) {
  flex: 1 0 auto;
  min-height: 0;
  display: grid;
}
[data-page="training-detail"] {
  display: grid;
  grid-template-columns: minmax(0, 800px) minmax(220px, 300px);
  gap: 16px;
}
.training-article { min-width: 0; padding: clamp(16px, 3vw, 32px); line-height: 1.6; }
.training-related { align-self: start; padding: 16px; }
.training-related ul { list-style: none; padding: 0; margin-top: 10px; }
.training-related li + li { border-top: 1px solid var(--line); }
.training-related a { display: block; padding: 10px 6px; border-radius: 6px; }
.training-related a:hover { background: var(--surface); text-decoration: underline; }
@media (max-width: 960px) {
  [data-page="training-detail"] { grid-template-columns: minmax(0, 800px); grid-template-rows: 1fr auto; }
}
.training-article section + section { margin-top: 24px; }
.training-article h2 { margin-bottom: 6px; }
.training-article ol { padding-inline-start: 24px; }
.training-article li + li { margin-top: 8px; }
.training-article a { text-decoration: underline; text-underline-offset: 2px; }
.auth-body { padding: 16px; }
#rename-form label { display: block; margin: 10px 0 4px; font-weight: 600; }
#rename-form input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--card); }
#auth-dialog {
  width: min(384px, calc(100% - 32px));
  padding: clamp(20px, 6vw, 32px);
  border-radius: calc(2 * var(--radius));
}
#auth-dialog::backdrop { background: linear-gradient(145deg, var(--surface), var(--sidebar)); }
.auth-header .brand-mark { margin-bottom: 16px; }
.auth-header img { object-fit: contain; }
.auth-header h2 { font-size: 24px; line-height: 1.25; }
.auth-header p { margin-top: 6px; color: var(--muted); line-height: 1.5; }
#auth-form { display: grid; gap: 16px; margin-top: 24px; }
.auth-field { display: grid; gap: 6px; min-width: 0; }
.auth-field label { font-weight: 600; }
.auth-field input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  font-size: 16px;
}
.auth-field input:is(:autofill, :-webkit-autofill) {
  /* Cover the browser's autofill background with the active theme surface. */
  box-shadow: inset 0 0 0 100px var(--surface);
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
}
.auth-field input::selection {
  color: var(--ink);
  background: var(--accent-bg);
}
.auth-field input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
#auth-submit:focus-visible { outline-color: var(--primary); }
#auth-submit { width: 100%; min-height: 44px; border-radius: var(--radius); font-size: 15px; }
#auth-error { margin: 0; }
#auth-error:empty { display: none; }
#auth-status {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.5;
}
.account-hint { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.auth-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
#auth-form button:disabled, #rename-form button:disabled, #sign-out:disabled { opacity: .65; cursor: default; }
.price-form { display: grid; gap: 11px; }
.price-form input { margin-top: 4px; }
.price-form button { justify-self: start; }
.catalog-toolbar .search input { width: 218px; }
.catalog-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; padding: 0 14px 14px; }
.catalog-filters label { display: grid; gap: 4px; min-width: 0; color: var(--muted); font-size: 12px; }
.catalog-filters select {
  min-height: 35px; max-width: 100%; padding: 6px 8px; border: 1px solid var(--line);
  border-radius: 8px; color: var(--ink); background: var(--card); font: inherit;
}
.catalog-item { display: flex; align-items: center; gap: 10px; }
.catalog-thumb {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 48px; height: 48px; padding: 0; border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; color: var(--muted); background: var(--surface);
}
.catalog-thumb img { width: 100%; height: 100%; object-fit: cover; }
.catalog-thumb[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.catalog-thumb > span:not([data-icon]) {
  position: absolute; inset: auto 3px 3px; padding: 1px 3px;
  border-radius: 4px; color: var(--on-primary); background: var(--primary); font-size: 10px;
}
.catalog-dialog { width: min(780px, calc(100% - 28px)); }
.catalog-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.catalog-gallery, .catalog-fields { min-width: 0; }
.catalog-preview {
  display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; aspect-ratio: 4 / 3;
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--surface);
}
.catalog-preview img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.catalog-placeholder { display: grid; justify-items: center; gap: 6px; padding: 12px; text-align: center; color: var(--muted); }
.catalog-placeholder [data-icon] { width: 28px; height: 28px; }
.catalog-thumbs, .catalog-media-actions, .catalog-footer { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.catalog-thumbs:not(:empty), .catalog-media-actions, .catalog-upload { margin-top: 9px; }
.catalog-media-actions button:disabled, .catalog-footer button:disabled { opacity: .55; cursor: default; }
.catalog-upload { display: block; }
#catalog-url { flex: 1 1 150px; width: auto; min-width: 0; margin-top: 0; font-size: 12px; }
.catalog-fields { display: grid; align-content: start; gap: 8px; }
.catalog-meta, .catalog-footer p { color: var(--muted); font-size: 12px; }
.catalog-prices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.catalog-fields textarea {
  width: 100%; padding: 9px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); background: var(--surface); font: inherit; resize: vertical;
}
.catalog-footer { justify-content: flex-end; padding-top: 10px; border-top: 1px solid var(--line); }
.catalog-footer p { margin-right: auto; }
@media (max-width: 580px) {
  .catalog-detail { grid-template-columns: minmax(0, 1fr); }
  .catalog-preview { max-height: 280px; }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 1050px) {
  .content { padding-inline: 18px; }
}
@media (max-width: 760px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { max-height: 50dvh; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin-bottom: 7px; }
  nav { display: flex; flex-wrap: wrap; gap: 2px; }
  nav a { min-height: 36px; padding: 5px 6px; font-size: 12px; }
  nav p { display: none; }
  .sidebar-footer { padding-top: 4px; }
  .topbar { padding-inline: 10px; }
  .content { padding-inline: 14px; }
  .metrics, .training-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .chat-tools { overflow-x: auto; }
  .chat-tools button { min-width: max-content; }
}
@media (max-width: 420px) {
  .segments { grid-template-columns: repeat(2, 1fr); }
  .training-grid { grid-template-columns: minmax(0, 1fr); }
  .notice { flex-wrap: wrap; }
  .notice .button { margin-left: 42px; }
}

#settings-dialog[open] { display: grid; grid-template-rows: auto auto minmax(0, 1fr); height: 450px; overflow: hidden; }
.settings-tabs { display: flex; gap: 4px; padding-inline: 12px; border-bottom: 1px solid var(--line); }
.settings-tabs button { min-height: 42px; padding: 8px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 13px; font-weight: 650; }
.settings-tabs button:hover { color: var(--ink); background: var(--subtle); }
.settings-tabs button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--ink); }
.settings-body { padding: 16px; overflow: auto; }
.settings-account { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settings-preferences { display: grid; gap: 12px; }
.settings-preferences :is(label, .settings-theme) { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 600; }
.settings-preferences label { min-width: 0; }
.settings-body :is(select, textarea) {
  width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; color: var(--ink); background: var(--surface); font: inherit;
}
.settings-preferences :is(select, .theme-switch) { flex: none; width: 144px; }
.theme-switch {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px;
  padding: 3px; border: 1px solid var(--line);
  border-radius: 8px; color: var(--muted); background: var(--surface);
}
.theme-option {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 30px;
  padding: 4px; border-radius: 5px; white-space: nowrap; font-size: 12px;
}
.theme-switch svg {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.theme-switch[aria-checked="false"] .theme-option:first-child,
.theme-switch[aria-checked="true"] .theme-option:last-child { color: var(--on-primary); background: var(--primary); }
@media (max-width: 400px) {
  .settings-preferences :is(label, .settings-theme) { gap: 8px; font-size: 12px; }
}
#feedback-form { display: grid; gap: 8px; }
#feedback-form label { font-weight: 600; margin-top: 3px; }
#feedback-form textarea { resize: vertical; }
#feedback-form p { color: var(--muted); font-size: 13px; line-height: 1.45; }
.feedback-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.feedback-status:empty { display: none; }
