/* Artstore Works: shared visual language.
   Loaded after the legacy styles; page refinements and composer follow this file. */
:root {
  --bg: #f8f8f8;
  --bg-elev: #ffffff;
  --bg-sunken: #f3f3f3;
  --bg-hover: #ededed;
  --bg-active: #e7e7e7;
  --line: #e3e3e3;
  --line-strong: #c7c7c7;
  --text: #202020;
  --text-2: #505050;
  --text-3: #686868;
  --text-4: #7a7a7a;
  --accent: #c35413;
  --accent-text: #a53d08;
  --accent-soft: #eeb18c;
  --accent-tint: #fff0e6;
  --orange: #b75112;
  --orange-tint: #fff0e6;
  --red: #bc3037;
  --red-tint: #fff0f1;
  --green: #19763d;
  --green-tint: #eaf6ee;
  --blue: #2566bd;
  --blue-tint: #edf3ff;
  --yellow: #866011;
  --yellow-tint: #fff5dc;
  --teal: #157667;
  --teal-tint: #e8f6f2;
  --purple: #7850b0;
  --purple-tint: #f4efff;
  --btn-dark-bg: #252525;
  --btn-dark-text: #ffffff;
  --shadow: 0 1px 2px rgb(0 0 0 / 3%);
  --shadow-lg: 0 16px 56px rgb(0 0 0 / 14%), 0 2px 8px rgb(0 0 0 / 5%);
  --radius: 14px;
  --sidebar-w: 232px;
  --page-gutter: clamp(20px, 2.6vw, 40px);
}
html[data-theme="dark"] {
  --bg: #191919;
  --bg-elev: #222222;
  --bg-sunken: #1d1d1d;
  --bg-hover: #2c2c2c;
  --bg-active: #343434;
  --line: #353535;
  --line-strong: #505050;
  --text: #f0f0f0;
  --text-2: #c4c4c4;
  --text-3: #a1a1a1;
  --text-4: #919191;
  --accent: #ed893f;
  --accent-text: #ffa466;
  --accent-soft: #794a2a;
  --accent-tint: #39291f;
  --orange: #f5a05e;
  --orange-tint: #392b20;
  --red: #ff9298;
  --red-tint: #40262a;
  --green: #80ce99;
  --green-tint: #22352a;
  --blue: #92bfff;
  --blue-tint: #233249;
  --yellow: #e7c277;
  --yellow-tint: #3b3320;
  --teal: #73cdbb;
  --teal-tint: #203730;
  --purple: #c6a7f7;
  --purple-tint: #33283e;
  --btn-dark-bg: #ededed;
  --btn-dark-text: #202020;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%);
  --shadow-lg: 0 20px 64px rgb(0 0 0 / 40%), 0 0 0 1px rgb(255 255 255 / 3%);
  --tooltip-bg: #efefef;
  --tooltip-text: #202020;
}
body { font-size: 14px; line-height: 1.55; }
button, input, select, textarea { letter-spacing: inherit; }
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; }
.small { font-size: 12px; line-height: 1.55; }
.link { text-underline-offset: 3px; }
.link:hover { text-decoration: underline; }

/* Quiet, persistent navigation. Selected destinations carry the strongest ink. */
.sidebar { padding: 14px 12px; background: var(--bg-sunken); border-color: var(--line); }
.ws { padding: 8px; margin-bottom: 12px; }
.ws-name { font-size: 14px; letter-spacing: -.025em; }
.ws-sub { font-size: 11px; }
.nav { gap: 3px; }
.nav-label { font-size: 11px; letter-spacing: .015em; padding: 20px 10px 8px; text-transform: none; }
.nav-item { min-height: 38px; padding: 8px 10px; font-size: 13px; font-weight: 400; border-radius: 8px; }
.nav-item.active { background: var(--bg-active); font-weight: 600; }
.nav-item svg { color: var(--text-2); }
.nav-item.active svg { color: var(--text); }
.sidebar-bottom { padding-top: 20px; }
.topbar { --topbar-pad: 10px; --topbar-inline: var(--page-gutter); min-height: 60px; padding: var(--topbar-pad) var(--topbar-inline); background: var(--bg); }
.topbar > .search { max-width: 360px; background: transparent; border-color: transparent; padding-left: 10px; border-radius: 8px; }
.topbar > .search:hover, .topbar > .search:focus-within { background: var(--bg-elev); border-color: var(--line); }
.topbar-right { gap: 8px; }
.search { border-radius: 9px; height: 38px; }
.search input { font-size: 13px; }
.search.sm { height: 36px; }

/* Shared page rhythm. Content begins at the same inset as its heading. */
.page-title-row { padding: 28px var(--page-gutter) 0; gap: 12px 20px; align-items: center; }
.page-title { font-size: 24px; line-height: 1.3; letter-spacing: -.035em; font-weight: 600; gap: 10px; }
.page-sub { margin-top: 7px; font-size: 13px; line-height: 1.65; color: var(--text-3); max-width: 80ch; }
.pagehead { padding-inline: var(--page-gutter); }
.content, .page .content { padding: 24px var(--page-gutter) 40px; gap: 20px; }
.tabs { padding: 18px var(--page-gutter) 0; gap: 10px; }
.tab { padding: 10px 5px 13px; font-size: 13px; color: var(--text-2); }
.tab.active::after { background: var(--text); }
.tab-ink { background: var(--text); }
.tabs.inner { margin-inline: 0; }
.toolbar { gap: 10px; margin-bottom: 18px; }

/* Controls: neutral by default; one primary action receives filled contrast. */
.btn { min-height: 36px; height: auto; padding: 7px 12px; border-radius: 8px; font-size: 13px; line-height: 1.35; box-shadow: none; justify-content: center; }
.btn.sm { min-height: 32px; height: auto; padding: 6px 10px; font-size: 12px; }
.btn.xs { min-height: 28px; height: auto; padding: 5px 8px; font-size: 11px; }
.btn-primary { color: var(--btn-dark-text); background: var(--btn-dark-bg); border-color: transparent; }
.btn-primary:hover { color: var(--btn-dark-text); background: var(--btn-dark-bg); filter: brightness(.94); }
.btn-dark:hover { filter: brightness(.94); }
.btn-primary svg { color: inherit; }
.btn-danger { background: #bf343b; color: #fff; }
.btn-danger:hover { background: #a92931; }
.btn-ghost { margin-top: 0; }
.btn-danger-ghost { color: var(--red); }
.btn:disabled, .icon-btn:disabled { opacity: .48; cursor: not-allowed; }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0; }
.icon-btn.xs { width: 28px; height: 28px; }
.pill { font-size: 11px; font-weight: 500; border-radius: 6px; line-height: 1.5; }
.pill.sm { font-size: 11px; }

/* Section surfaces stay still and use borders sparingly. */
.card { padding: 20px; box-shadow: none; animation: none; transition: border-color .15s; }
.card:hover { border-color: var(--line); }
.card.clickable:hover { transform: none; border-color: var(--line-strong); box-shadow: none; background: var(--bg-hover); }
.card-head { margin-bottom: 18px; gap: 12px; }
.card-title { font-size: 13px; line-height: 1.5; letter-spacing: -.01em; text-transform: none; color: var(--text); font-weight: 600; }
.card-actions { flex-wrap: wrap; justify-content: flex-end; }
.card-title .ico { border: 0; background: transparent; width: 18px; height: 18px; }
.card-title .ico svg { width: 16px; height: 16px; }
.kpi-value { font-size: 30px; font-weight: 600; letter-spacing: -.04em; }
.kpi-sub { font-size: 12px; }
.kpi-foot { font-size: 12px; }
.table-wrap { margin-inline: -20px; padding-inline: 20px; }
.table { font-size: 13px; }
.table th { font-size: 11px; color: var(--text-2); letter-spacing: .01em; background: var(--bg-sunken); font-weight: 500; }
.table td { padding-block: 13px; }
.table .date, .table .num { font-size: 12px; }
.empty-state { border-style: solid; border-color: var(--line); background: var(--bg-sunken); padding: 40px 24px; gap: 9px; font-size: 13px; }
.empty-state b { font-size: 16px; font-weight: 600; }
.empty-state svg { color: var(--text-3); }
.card > .empty-state { border: 0; background: transparent; }

/* Forms and layers: readable labels, visible focus, calm footer. */
.form { gap: 18px; }
.form-row { gap: 16px; }
.form label { gap: 7px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.form label > span.hint { font-size: 12px; line-height: 1.5; }
.input, .select, .textarea { min-height: 40px; height: 40px; font-size: 14px; border-color: var(--line-strong); background-color: var(--bg-elev); border-radius: 8px; }
.textarea { height: auto; padding: 10px 12px; line-height: 1.65; }
.select { background-position: calc(100% - 14px) 17px, calc(100% - 9px) 17px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 14%, transparent); }
.input:read-only, .textarea:read-only { background-color: var(--bg-sunken); color: var(--text-2); }
.input:disabled, .select:disabled, .textarea:disabled { color: var(--text-3); background-color: var(--bg-sunken); cursor: not-allowed; }
.modal-wrap { background: rgb(0 0 0 / 48%); backdrop-filter: blur(4px); }
.modal { border-radius: 18px; border-color: var(--line-strong); }
.modal-head { padding: 16px 24px; font-size: 16px; border-bottom-color: var(--line); }
.modal-body, .drawer-body { padding: 24px; }
.modal-foot { padding: 16px 24px; background: var(--bg-elev); border-radius: 0 0 18px 18px; }
.modal-foot .btn { min-width: 76px; }
.drawer { border-color: var(--line-strong); }
.menu, .popover { border-radius: 12px; border-color: var(--line-strong); padding: 6px; }
.menu li, .popover-item { font-size: 13px; min-height: 36px; border-radius: 7px; line-height: 1.45; }
.menu li[aria-selected="true"], .popover-item.active { background: var(--bg-hover); }
.login-card { border-radius: 20px; box-shadow: var(--shadow); gap: 16px; }
.login-card label { font-size: 13px; gap: 7px; }

@media (max-width: 1024px), (pointer: coarse) {
  .btn, .btn.sm, .btn.xs, .icon-btn, .icon-btn.xs, .menu li, .popover-item { min-height: 44px; }
  .icon-btn, .icon-btn.xs { width: 44px; height: 44px; }
  .input, .select { height: 44px; }
  .select { background-position: calc(100% - 14px) 19px, calc(100% - 9px) 19px; }
}
@media (max-width: 960px) {
  :root { --page-gutter: 24px; }
  .topbar { --topbar-inline: 16px; padding-inline: var(--topbar-inline); }
  .sidebar { background: var(--bg-elev); }
}
@media (max-width: 640px) {
  :root { --page-gutter: 16px; }
  .topbar { --topbar-pad: 8px; --topbar-inline: 12px; min-height: 60px; padding: var(--topbar-pad) var(--topbar-inline); gap: 4px; }
  .topbar-right { gap: 2px; }
  .page-title-row { padding-top: 22px; gap: 14px; }
  .page-title { font-size: 22px; line-height: 1.35; }
  .page-title-row .pagehead-right { width: auto; flex: 0 1 auto; margin-left: 0; gap: 8px; }
  .page-sub { font-size: 13px; }
  .content, .page .content { padding-top: 20px; gap: 16px; }
  .tabs { padding-top: 16px; gap: 12px; }
  .tab { padding-inline: 2px; }
  .toolbar { gap: 8px; overflow: visible; }
  .toolbar .btn { flex: 0 1 auto; }
  .toolbar .search { flex: 1 1 100%; }
  .card { padding: 16px; border-radius: 12px; }
  .card-head { margin-bottom: 14px; }
  .card-title { font-size: 13px; }
  .table-wrap { margin-inline: -16px; padding-inline: 16px; }
  .modal-head { padding: 14px 16px; }
  .modal-body, .drawer-body { padding: 20px 16px; }
  .modal-foot { padding: 14px 16px; }
  .modal-foot > .btn { flex: 0 1 auto; }
  .form { gap: 16px; }
  .form-row { gap: 16px; }
  .empty-state { padding: 32px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .sidebar, .topbar, .btn, .modal, .drawer { transition: none; }
}
/* Keep native controls and scrollbar tracks in the selected app theme. */
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
:where(.sidebar, .table-wrap, .notes-list, .modal-body, .drawer-body, .file-tree, .kanban) {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
@media (max-width: 640px) {
  .pagehead-right .btn { flex: 0 1 auto; }
}
/* Small metadata still needs readable contrast on both sunken and active surfaces. */
:root { --text-4: #686868; }
html[data-theme="dark"] { --text-4: #a1a1a1; }
.nav-badge { background: #bc3037; color: #fff; }
.pill.codex { --c: #18755d; --t: #e8f6f0; }
.pill.claude { --c: #a34f20; --t: #fff0e6; }
html[data-theme="dark"] .pill.codex { --c: #79cfb7; --t: #22382f; }
html[data-theme="dark"] .pill.claude { --c: #efaa77; --t: #392b20; }

/* The PWA status bar overlays the page. Keep this after all padding shorthands. */
@media (display-mode: standalone) {
  .topbar {
    padding-top: calc(var(--topbar-pad) + env(safe-area-inset-top, 0px));
    padding-left: max(var(--topbar-inline), env(safe-area-inset-left, 0px));
    padding-right: max(var(--topbar-inline), env(safe-area-inset-right, 0px));
  }
  .sidebar { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
}
