/* =====================================================================
   STAKER COLLINS · FLIP OS V5 — base layer
   All-new design language: deep-violet rail, warm paper canvas,
   shadow-floated cards, editorial type + mono data labels.
   ===================================================================== */

:root {
  /* canvas + ink */
  --paper: #f3f3f8;
  --card: #ffffff;
  --ink: #17141f;
  --ink2: #4b4754;
  --mut: #837e8d;
  --mut2: #b5b1bd;
  --hair: rgba(23, 20, 31, .08);
  --hair2: rgba(23, 20, 31, .055);

  /* brand — soft lavender */
  --brand: #6e5ef2;
  --brand-deep: #5b4ce0;
  --brand-ink: #5a4ad6;
  --brand-soft: #ecebfd;
  --brand-ring: rgba(110, 94, 242, .20);

  /* rail — high-contrast dark sidebar */
  --rail-bg: #18142a;
  --rail-ink: rgba(255, 255, 255, .92);
  --rail-hi: #ffffff;
  --rail-line: rgba(255, 255, 255, .10);
  --rail-active: rgba(129, 116, 244, .30);
  --rail-hover: rgba(255, 255, 255, .08);
  --rail-icon: rgba(255, 255, 255, .6);
  --rail-dim: rgba(255, 255, 255, .5);
  --rail-on: #bcb2fb;

  /* status */
  --ok: #0e7a4e;     --ok-soft: #e0f4ea;
  --warn: #cf5409;   --warn-soft: #ffeedd;
  --bad: #d23730;    --bad-soft: #fdeae7;
  --info: #2563c4;   --info-soft: #e9f0fb;

  /* geometry */
  --rs: 11px;          /* controls */
  --rc: 22px;          /* cards — rounder + airier */
  --rm: 24px;          /* modal */
  --rail-w: 76px;      /* collapsed icon rail (v5 behavior) */
  --rail-x: 266px;     /* expanded on hover */

  --lift: 0 1px 2px rgba(25, 20, 45, .035), 0 6px 18px -12px rgba(25, 20, 45, .11);
  --lift-lg: 0 2px 6px rgba(25, 20, 45, .05), 0 24px 52px -22px rgba(25, 20, 45, .22);

  --f-ui: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(.23, .7, .25, 1);
}

:root[data-night="on"] {
  --paper: #15131c;
  --card: #1f1c29;
  --ink: #f1eff6;
  --ink2: #c8c4d2;
  --mut: #918c9e;
  --mut2: #5d5969;
  --hair: rgba(255, 255, 255, .1);
  --hair2: rgba(255, 255, 255, .065);

  --brand: #8174f4;
  --brand-deep: #9286f6;
  --brand-ink: #b3a9f9;
  --brand-soft: rgba(129, 116, 244, .18);
  --brand-ring: rgba(129, 116, 244, .35);

  --rail-bg: #1b1827;
  --rail-ink: #9b94b3;
  --rail-hi: #f1eff6;
  --rail-line: rgba(255, 255, 255, .08);
  --rail-active: rgba(129, 116, 244, .20);
  --rail-hover: rgba(255, 255, 255, .06);
  --rail-icon: rgba(255, 255, 255, .55);
  --rail-dim: rgba(255, 255, 255, .45);
  --rail-on: #b3a9f9;

  --ok: #4cc591;     --ok-soft: rgba(76, 197, 145, .14);
  --warn: #f59d59;   --warn-soft: rgba(245, 157, 89, .14);
  --bad: #f0796f;    --bad-soft: rgba(240, 121, 111, .14);
  --info: #82aef0;   --info-soft: rgba(130, 174, 240, .13);

  --lift: 0 1px 2px rgba(0, 0, 0, .35), 0 12px 32px -14px rgba(0, 0, 0, .55);
  --lift-lg: 0 4px 10px rgba(0, 0, 0, .4), 0 30px 70px -18px rgba(0, 0, 0, .7);
}

/* ============================ base ============================ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.5 var(--f-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
::selection { background: var(--brand-ring); }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* micro data label — V5 signature */
.lab {
  font: 600 10.5px/1.3 var(--f-mono);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--mut);
}

/* mobile/desktop-only helpers */
@media (min-width: 741px) { .m-only { display: none !important; } }
@media (max-width: 740px) { .d-only { display: none !important; } }

.ava { border-radius: 99px; display: grid; place-items: center; color: #fff; background: #3c3650;
  font: 700 12px/1 var(--f-ui); width: 32px; height: 32px; overflow: hidden; flex: none; }
.ava img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }

/* ============================ buttons ============================ */
.b {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 17px; border-radius: var(--rs);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  background: var(--card); color: var(--ink); border: 1px solid var(--hair);
  box-shadow: var(--lift); transition: all .15s var(--ease);
}
.b .i { width: 16px; height: 16px; }
.b:hover { border-color: var(--mut2); }
.b.pri { background: var(--brand); border-color: transparent; color: #fff; box-shadow: 0 8px 20px -8px var(--brand-ring), var(--lift); }
.b.pri:hover { background: var(--brand-deep); }
.b.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink2); }
.b.ghost:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
:root[data-night="on"] .b.ghost:hover { background: rgba(255, 255, 255, .08); }
.b.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; box-shadow: none; }
.b.sm { min-height: 33px; padding: 0 13px; font-size: 13px; border-radius: 9px; }
.b.ic { width: 40px; padding: 0; }
.b.ic.sm { width: 33px; }
.b.full { width: 100%; }

/* ============================ forms ============================ */
.fld { display: flex; flex-direction: column; gap: 7px; }
.fld > .lab { color: var(--ink2); }
.fld input, .fld select, .fld textarea, .tin {
  width: 100%; border: 1px solid var(--hair); background: var(--card); border-radius: var(--rs);
  padding: 10px 13px; font-size: 14.5px; outline: 0;
  transition: border-color .15s, box-shadow .15s;
}
:root[data-night="on"] .fld input, :root[data-night="on"] .fld select,
:root[data-night="on"] .fld textarea, :root[data-night="on"] .tin { background: rgba(255,255,255,.05); }
.fld textarea { resize: vertical; min-height: 78px; }
.fld input:focus, .fld select:focus, .fld textarea:focus, .tin:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3.5px var(--brand-ring); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
/* compact time column · roomy notes column (appointment form) */
.grid2.grid-time { grid-template-columns: minmax(168px, max-content) 1fr; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 13px; }

/* ============================ responsive shell ============================ */
.veil { position: fixed; inset: 0; z-index: 85; background: rgba(13, 10, 25, .5);
  opacity: 0; pointer-events: none; transition: opacity .2s; }
.shell.rail-open .veil { opacity: 1; pointer-events: auto; }
.dock { display: none; }

@media (max-width: 880px) {
  .shell { padding-left: 0; }
  .rail { transform: translateX(-100%); width: var(--rail-x); transition: transform .26s var(--ease); }
  .shell.rail-open .rail { transform: none; }
  .rail .r-lab, .rail .r-num, .rail .r-cap, .rail .rf-t, .rail .r-name { opacity: 1 !important; }
  .head { min-height: 60px; padding: 10px 12px; gap: 9px; flex-wrap: nowrap; }
  .head .h-burger { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; color: var(--ink2); flex: none; }
  .head .h-burger:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
  .head .h-t { flex: 0 1 auto; min-width: 0; }
  .head .h-acts { display: flex; gap: 8px; flex: 1 1 auto; min-width: 0; }
  /* New property collapses to an icon — the dock + page buttons carry the label */
  .head .h-acts > .b.pri { width: 42px; padding: 0; flex: none; }
  .head .h-acts > .b.pri span { display: none; }
  .head .h-acts > .b.pri .i { width: 19px; height: 19px; }
  /* search bar sits inline in the middle, growing to fill the row */
  .head .h-search { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; color: var(--ink2); flex: none; }
  .head #mSearch { display: none; }
  .head .h-search:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
  .head .finder { display: block; order: -1; flex: 1 1 auto; min-width: 90px; }
  .head .finder .f-box { min-width: 0; width: 100%; }
  .finder kbd { display: none; }
  .f-pop { left: 0; right: 0; width: auto; max-height: 50vh; }
  .head .h-t h1 { font-size: 17px; }
  .page { padding: 16px 14px calc(110px + env(safe-area-inset-bottom)); }
  .grid2 { grid-template-columns: 1fr; }
  .grid2.grid-time { grid-template-columns: 1fr; }
  .grid2.keep2 { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .rowflex.spread { flex-wrap: wrap; }
  /* 16px inputs — stops iOS zoom-on-focus */
  .fld input, .fld select, .fld textarea, .tin, .finder input, .amtbox input { font-size: 16px; }

  /* bottom dock */
  .dock {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--card) 90%, transparent);
    backdrop-filter: blur(16px) saturate(1.3);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);
    border-top: 1px solid var(--hair2);
  }
  .dock button { display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: var(--mut); font-size: 10.5px; font-weight: 600; padding: 6px 2px; border-radius: 12px; min-height: 48px; }
  .dock button .i { width: 22px; height: 22px; }
  .dock button.on { color: var(--brand-ink); }
  .dock .dk-add { margin-top: -22px; }
  .dock .dk-add span.ring { width: 52px; height: 52px; border-radius: 99px; display: grid; place-items: center;
    background: var(--brand); color: #fff; box-shadow: 0 10px 24px -8px var(--brand-ring); }
  .dock .dk-add .i { width: 24px; height: 24px; }
}
@media (min-width: 881px) { .veil { display: none; } }

/* ============================ native-app feel ============================ */
html { -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: none; }
* { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
/* UI chrome shouldn't be text-selectable (inputs and page content stay selectable) */
button, .dock, .rail, .tabbar, .segm, .vswitch, .chip, .lab, .pick { -webkit-user-select: none; user-select: none; }
/* tactile press feedback on touch screens */
@media (hover: none) {
  .b:active, .dock button:active, .dk-add:active .ring, .tabu:active, .r-item:active, .r-flip:active,
  .chip:active, .lrow:active, .cg-i:active, .vswitch:active { transform: scale(.96); transition: transform .08s var(--ease); }
}
/* installed (home-screen) mode: content sits under the status bar — pad it out */
@media (display-mode: standalone) {
  .head { padding-top: calc(10px + env(safe-area-inset-top)); }
  .rail { padding-top: calc(14px + env(safe-area-inset-top)); }
  .gate { padding-top: env(safe-area-inset-top); }
}
/* roomier touch targets on phones */
@media (max-width: 620px) {
  .lrow { min-height: 56px; }
  .task-row { padding-top: 13px; padding-bottom: 13px; }
  .tbl tbody tr { padding: 14px 18px 15px; }
  .b.sm { min-height: 38px; }
  .chip { min-height: 28px; }
}

/* swipe-to-dismiss support */
@media (max-width: 880px) {
  .rail { touch-action: pan-y; }
  .veil { touch-action: none; }
}
