/* Crate, styled to match the other realign.nz apps (Lists, Plans). */
:root {
  --paper: #F2F4EF;
  --card: #FFFFFF;
  --ink: #262E27;
  --ink-soft: #697065;
  --blue: #4C5FD5;
  --coral: #FF6F61;
  --amber: #B7791F;
  --line: rgba(105, 112, 101, 0.18);
  --radius: 16px;
  --disc: #1E211F;
  color-scheme: light;
}
* { box-sizing: border-box; min-width: 0; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  overflow-x: clip;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1, h2, h3 { margin: 0; }
.app {
  max-width: 560px; margin: 0 auto;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* ---------- top bar ---------- */
.top-bar { display: flex; align-items: center; gap: 4px; padding: 12px 8px 6px 20px; min-height: 64px; }
.title-wrap { flex: 1; min-width: 0; }
.top-bar h1 { font-size: 22px; font-weight: 700; }
.top-bar .status { display: flex; gap: 6px; font-size: 12px; color: var(--ink-soft); margin-top: 1px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.top-bar .status span:empty { display: none; }
.top-bar #userName::before { content: "\00b7"; margin-right: 6px; }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; flex: none; color: var(--ink-soft); }
.icon-btn:hover { background: rgba(38, 46, 39, 0.06); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- home ---------- */
.home { padding: 8px 16px calc(100px + env(safe-area-inset-bottom)); flex: 1; }
.srch { position: relative; display: block; margin-bottom: 10px; }
.srch svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--ink-soft); pointer-events: none; }
.srch input {
  width: 100%; height: 50px; border: 1.5px solid transparent; border-radius: 12px;
  background: var(--card); padding: 0 14px 0 44px; font-size: 16px; outline: none;
}
.srch input:focus { border-color: var(--blue); }
#tools > .btn { margin-bottom: 16px; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; font-size: 13px; color: var(--ink-soft); }
.seg { display: flex; gap: 6px; }
.seg button { height: 34px; padding: 0 14px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink-soft); background: rgba(38, 46, 39, 0.06); }
.seg button[aria-pressed=true] { background: var(--blue); color: #fff; }

/* record grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 14px; }
.card { display: grid; gap: 8px; text-align: left; padding: 0; }
.sw { position: relative; padding-right: 8%; }
.disc {
  position: absolute; right: 0; top: 4%; height: 92%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, var(--coral) 0 15%, var(--disc) 16% 52%, #2A2E2B 53% 54%, var(--disc) 55% 100%);
  transition: transform 0.3s ease;
}
.card:hover .disc, .card:focus-visible .disc { transform: translateX(6%); }
.sl { position: relative; display: block; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--card); box-shadow: 0 2px 8px rgba(38, 46, 39, 0.16); }
.sl img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph { display: grid; place-items: center; height: 100%; font-size: 28px; font-weight: 700; color: var(--ink-soft); background: var(--card); }
.meta b { display: block; font-size: 15px; font-weight: 600; line-height: 1.25; }
.meta > span { display: block; font-size: 13px; color: var(--ink-soft); }
.hit {
  display: block; width: fit-content; max-width: 100%; margin-top: 4px; padding: 2px 8px; border-radius: 999px;
  background: rgba(76, 95, 213, 0.12); color: var(--blue); font-size: 12px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.empty { display: grid; justify-items: center; text-align: center; gap: 12px; padding: 32px 8px; color: var(--ink-soft); font-size: 14px; line-height: 1.45; }
.empty h2 { font-size: 20px; font-weight: 700; color: var(--ink); }
.empty p { margin: 0; max-width: 320px; }
.empty svg { width: min(200px, 60vw); }
.empty .btn { max-width: 280px; }
.credit { font-size: 12px; color: var(--ink-soft); text-align: center; margin: 28px 0 0; }
.credit a { color: inherit; }
.note { font-size: 13px; color: var(--ink-soft); }
.note a { color: var(--blue); }

/* floating add button */
.fab {
  position: fixed; z-index: 5;
  right: max(20px, calc(50vw - 280px + 20px));
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--coral); color: #fff; display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(38, 46, 39, 0.22);
}
.fab svg { width: 24px; height: 24px; }

/* ---------- buttons and fields ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 50px; padding: 0 16px; border-radius: 12px; font-weight: 600; font-size: 15px;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.outline { border: 1.5px solid var(--line); color: var(--blue); background: transparent; }
.btn.outline.ink { color: var(--ink); }
.btn.outline.danger { color: var(--coral); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.link-btn { padding: 10px 12px; border-radius: 10px; font-weight: 600; font-size: 13px; color: var(--ink-soft); }
.link-btn:hover { background: rgba(38, 46, 39, 0.06); }
.lnk { color: var(--blue); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.field, .f input, .f textarea {
  display: block; width: 100%; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--card); padding: 12px 14px; font-size: 16px; outline: none;
}
.field:focus, .f input:focus, .f textarea:focus { border-color: var(--blue); }
.f { display: grid; gap: 6px; margin-bottom: 12px; }
.f label { font-size: 11px; font-weight: 700; color: var(--ink-soft); letter-spacing: 0.02em; }
.f textarea { min-height: 150px; resize: vertical; line-height: 1.45; }
.row2 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 420px) { .row2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

/* ---------- sign in ---------- */
.signin { min-height: 70vh; display: grid; place-items: center; text-align: center; }
.signin .box { display: grid; gap: 16px; justify-items: center; width: 100%; max-width: 360px; }
.signin .box > div { display: grid; gap: 12px; justify-items: center; width: 100%; }
.signin img { border-radius: 18px; }
.signin h2 { font-size: 26px; font-weight: 700; }
.signin p { margin: 0 0 8px; color: var(--ink-soft); font-size: 14px; line-height: 1.45; }
.signin p b { color: var(--ink); overflow-wrap: anywhere; }
.signin .or { font-size: 13px; color: var(--ink-soft); }
.email-form { display: grid; gap: 10px; width: 100%; }
.signin .msg { font-size: 13px; color: var(--ink-soft); max-width: 340px; }
.signin .msg.error { color: var(--coral); }
.signin .msg:empty { display: none; }

/* ---------- sheets ---------- */
.veil {
  position: fixed; inset: 0; z-index: 10; background: rgba(20, 24, 21, 0.38);
  display: none; align-items: flex-end; justify-content: center;
}
.veil.on { display: flex; animation: fade 0.15s ease-out; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0.6; } }
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; max-height: 88dvh; overflow-y: auto;
  background: var(--paper); border-radius: 22px 22px 0 0;
  padding: 14px 20px calc(28px + env(safe-area-inset-bottom));
  animation: rise 0.18s ease-out;
}
@media (min-width: 640px) { .veil { align-items: center; padding: 20px; } .sheet { border-radius: 22px; } }
.sh { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 4px 0 14px; }
.sh h2 { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.x { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; flex: none; font-size: 24px; line-height: 1; color: var(--ink-soft); margin: -6px -8px 0 0; }
.x:hover { background: rgba(38, 46, 39, 0.06); }
.ed { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 18px; }
@media (max-width: 600px) { .ed { grid-template-columns: minmax(0, 1fr); } .ed .pics { max-width: 220px; } }
.pics { display: grid; gap: 8px; align-content: start; }
.pics .sl { box-shadow: 0 2px 10px rgba(38, 46, 39, 0.18); }
.pics .btn { height: 44px; font-size: 14px; }
@media (max-width: 600px) {
  .pics.mini { grid-template-columns: 100px minmax(0, 1fr); max-width: none !important; align-items: start; }
  .pics.mini .sl { grid-row: span 3; }
}
.thumbs { display: flex; gap: 8px; }
.thumbs button { width: 52px; height: 52px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: var(--card); }
.thumbs button[aria-pressed=true] { border-color: var(--blue); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sheet .status { display: flex; align-items: center; gap: 10px; min-height: 22px; margin-bottom: 12px; font-size: 14px; color: var(--ink-soft); line-height: 1.45; }
.spin { width: 20px; height: 20px; flex: none; border-radius: 50%; border: 2.5px solid rgba(76, 95, 213, 0.2); border-top-color: var(--blue); animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } .disc { transition: none; } .veil.on, .sheet { animation: none; } }
.foot { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 8px; }
.foot .btn { width: auto; flex: 1 1 140px; }
.foot .sp { display: none; }

/* find step */
.find { display: grid; gap: 12px; }
.find .row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.find .row .f { flex: 1 1 150px; margin: 0; }
.find .row .btn { width: auto; flex: none; padding: 0 20px; }
.res { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.res button { width: 100%; display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px; align-items: center; text-align: left; background: var(--card); border-radius: 14px; padding: 8px; }
.res button:hover { box-shadow: 0 0 0 1.5px var(--blue) inset; }
.res .cv { width: 52px; height: 52px; border-radius: 6px; background: var(--paper); overflow: hidden; }
.res .cv img { width: 100%; height: 100%; object-fit: cover; display: block; }
.res b { display: block; font-size: 15px; font-weight: 600; line-height: 1.25; }
.res small { display: block; font-size: 12px; color: var(--ink-soft); margin-top: 1px; }
.own { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--coral); color: #fff; font-size: 11px; font-weight: 700; vertical-align: 2px; }
.alt { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }

/* alerts */
.warn { display: flex; gap: 12px; align-items: center; padding: 12px 14px; margin-bottom: 14px; border-radius: 14px; background: rgba(255, 111, 97, 0.14); font-size: 14px; line-height: 1.4; }
.warn img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; flex: none; }
.ovl { padding: 12px 14px; margin-bottom: 14px; border-radius: 14px; background: var(--card); border: 1.5px solid rgba(232, 162, 61, 0.55); font-size: 14px; }
.ovl.heavy { background: rgba(232, 162, 61, 0.16); }
.ovl ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.ovl li { display: grid; grid-template-columns: 2.6em minmax(0, 1fr); gap: 8px; }
.ovl li > span { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.ovl small, .tl small { display: block; font-size: 12px; color: var(--ink-soft); }
.ovl i { font-style: normal; font-size: 11px; font-weight: 700; color: var(--amber); margin-left: 4px; }
.ovl summary { cursor: pointer; margin-top: 8px; font-weight: 600; color: var(--blue); }

/* check verdict */
.verdict { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.verdict.yes { color: var(--coral); }
.verdict.no { color: var(--blue); }
.verdict.part { color: var(--amber); }
.sheet p { margin: 0 0 14px; font-size: 15px; line-height: 1.45; }
.sheet > .card { max-width: 200px; margin-bottom: 14px; }

/* detail */
.sheet h3 { font-size: 18px; font-weight: 700; }
.dl { color: var(--ink-soft); font-size: 13px; margin: 4px 0 12px !important; }
.tl { list-style: none; margin: 0 0 8px; padding: 0; background: var(--card); border-radius: 14px; overflow: hidden; }
.tl li { display: grid; grid-template-columns: 2.8em minmax(0, 1fr); gap: 8px; padding: 10px 14px; font-size: 15px; }
.tl li + li { border-top: 1px solid var(--line); }
.tl li > span { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.tl li.m { background: rgba(76, 95, 213, 0.1); }
.tl small.also { color: var(--blue); }

/* snackbar */
.toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 20;
  width: calc(100% - 32px); max-width: 528px;
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: #313733; color: #fff; font-size: 14px;
  padding: 14px 16px; border-radius: 10px; transition: all 0.2s ease;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
