/* style.css — the whole visual system, transcribed from the design prototype.
   Every colour, radius, size and easing here is taken from the design file. */

:root {
  --bg: #F4ECDD;
  --card: #FBF6EC;
  --card-alt: #F8F1E4;
  --logo-bg: #FFFDF9;
  --line: #EADFCB;
  --line-soft: #EFE3D0;
  --line-mid: #EDE3D0;
  --divider: #E1D4BF;
  --outline: #D8CDB8;

  --ink: #2A2520;
  --ink-2: #5c5347;
  --muted: #7C7266;
  --muted-2: #8a7f6f;
  --muted-3: #9a8f7f;
  --muted-4: #a1957f;

  --accent: #B85C38;
  --accent-deep: #A04E2E;
  --accent-soft: #F1DDCF;
  --accent-line: #E3CCBD;

  --green: #6E7F5B;
  --green-soft: #E7EAD9;
  --green-text: #5f7a53;

  --cover-bg: #F6E4D8;
  --cover-border: #ECCDBB;
  --pending-bg: #F6E9D6;
  --pending-text: #9a6a2e;
  --pending-border: #ECD9C0;
  --wait-bg: #EFE6D5;
  --wait-text: #7a715f;

  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --sans: 'Hanken Grotesk', -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;

  /* The design reserves 58px at the top for the status bar. On a real device
     the notch may be deeper, so take whichever is larger. viewport-fit=cover
     in index.html is what makes env() non-zero at all. */
  --safe-top: max(58px, env(safe-area-inset-top));
  --safe-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;             /* stop rubber-band scroll bleed */
}

body { min-height: 100dvh; }                  /* not 100vh — iOS standalone gets it wrong */

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes sheetUp { from { transform: translateY(100%) } to { transform: translateY(0) } }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px) }
  to { opacity: 1; transform: translateY(0) }
}
@keyframes spin { to { transform: rotate(360deg) } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- shell ------------------------------------------------------- */

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--bg);
  max-width: 520px;                           /* phone-shaped even on a laptop */
  margin: 0 auto;
  overflow: hidden;
}

.head { flex: none; padding: var(--safe-top) 20px 0; background: var(--bg); }

.brand { display: flex; align-items: center; gap: 11px; }

.logo {
  width: 46px; height: 46px; flex: none;
  border-radius: 12px;
  background: var(--logo-bg);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  padding: 3px;
  box-shadow: 0 1px 2px rgba(80, 60, 30, .05);
}
.logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; }

.wordmark {
  font-size: 11.5px; letter-spacing: .09em; color: var(--muted-2); font-weight: 600;
  line-height: 1.35;
}

.brand-spacer { flex: 1; }

.manage {
  border: 1px solid var(--line); background: transparent; color: var(--ink-2);
  font-size: 12px; font-weight: 700; padding: 7px 12px; border-radius: 9px;
}

.title {
  font-family: var(--serif); font-weight: 500; font-size: 30px; color: var(--ink);
  margin: 16px 0 3px; letter-spacing: -.01em;
}

.subtitle { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.subtitle b { color: var(--green); font-weight: 700; }

/* ---------- segmented control ------------------------------------------- */

.tabs {
  position: relative; display: flex;
  background: #E9DDC8; border-radius: 12px; padding: 4px;
}
.tabs-pill {
  position: absolute; top: 4px; bottom: 4px; left: 4px;
  width: calc(33.333% - 2.667px);
  border-radius: 9px; background: var(--card);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .09);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}
.tabs button {
  position: relative; z-index: 1; flex: 1;
  border: none; background: transparent; padding: 9px;
  font-size: 13px; font-weight: 700; color: var(--ink);
}

.scroll { flex: 1; overflow: auto; background: var(--bg); padding: 6px 20px 40px; }
.scroll.pad-bottom { padding-bottom: calc(40px + var(--safe-bottom)); }

/* ---------- day groups + shift cards ------------------------------------ */

.group { margin-top: 20px; }
.group-head { display: flex; align-items: center; gap: 12px; margin-bottom: 11px; }
.group-rule { flex: 1; height: 1px; background: var(--divider); }

.section-label {
  font-family: var(--serif); font-style: italic; font-size: 16px; color: var(--muted-2);
}
.section-label.spaced { margin: 22px 0 11px; }

.stack { display: flex; flex-direction: column; gap: 10px; }

.card {
  width: 100%; text-align: left;
  border: 1px solid var(--line); background: var(--card);
  border-radius: 16px; padding: 14px 15px;
  display: flex; flex-direction: column; gap: 9px;
  box-shadow: 0 1px 2px rgba(80, 60, 30, .04);
}
.card.mine-card { gap: 11px; }
.card.pending { border-color: var(--pending-border); }
.card.waiting { border: 1px dashed var(--outline); background: var(--card-alt); box-shadow: none; }

.card-top {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.card-titles { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.card-name {
  font-family: var(--serif); font-size: 18px; font-weight: 500; color: var(--ink);
  line-height: 1.15;
}
.card-time { font-size: 13px; color: var(--muted); }

.dur {
  flex-shrink: 0; background: var(--accent-soft); color: var(--accent-deep);
  font-weight: 700; font-size: 12.5px; padding: 6px 10px; border-radius: 9px;
  white-space: nowrap;
}
.dur.lg { font-size: 14px; padding: 8px 13px; border-radius: 11px; }

.tags { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.tag .dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.tag-cover { color: var(--accent); font-weight: 700; }
.tag-cover .dot { background: var(--accent); }
.tag-spots { color: var(--green-text); font-weight: 600; }
.tag-spots .dot { background: var(--green); }
.tag-mine { color: var(--green-text); font-weight: 700; }
.tag-mine .dot { background: var(--green); }
.tag-full { font-size: 12.5px; color: var(--muted-4); font-weight: 600; }
.tag-note { font-size: 12px; color: var(--muted-3); }
.tag-weekly { font-size: 11.5px; color: var(--muted-4); gap: 4px; }

.repeat-badge {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 5px;
  background: var(--green-soft); color: var(--green-text);
  font-size: 11.5px; font-weight: 700; padding: 4px 9px; border-radius: 7px;
}

.card-actions {
  display: flex; gap: 8px; padding-top: 3px; border-top: 1px solid var(--line-soft);
}
.btn-ghost {
  flex: 1; border: 1px solid var(--outline); background: transparent; color: var(--ink-2);
  font-weight: 600; font-size: 13px; padding: 9px; border-radius: 10px;
}
.btn-ghost.danger { border-color: var(--accent-line); color: var(--accent-deep); }
.btn-ghost.inline { flex: none; padding: 8px 14px; }
.btn-ghost.small { flex: none; font-size: 12.5px; padding: 7px 13px; border-radius: 9px; }

.callout {
  background: var(--pending-bg); border-radius: 10px; padding: 10px 12px;
  font-size: 12.5px; color: var(--pending-text); line-height: 1.4;
  display: flex; gap: 8px; align-items: flex-start;
}

.wait-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.wait-pos {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--wait-text); font-weight: 600;
}
.wait-pos.open { color: var(--accent-deep); font-weight: 700; }

/* ---------- Mine summary ------------------------------------------------ */

.summary {
  background: var(--green); color: var(--bg); border-radius: 18px; padding: 17px 19px;
  display: flex; justify-content: space-between; align-items: center; margin: 16px 0 4px;
}
.summary-label { font-family: var(--serif); font-size: 16px; }
.summary-sub { font-size: 12.5px; opacity: .8; margin-top: 2px; }
.summary-hours {
  font-family: var(--serif); font-size: 32px; font-weight: 600; line-height: 1;
}
.summary-unit { font-size: 11px; opacity: .8; letter-spacing: .04em; }

/* ---------- empty state ------------------------------------------------- */

.empty { text-align: center; padding: 64px 30px; }
.empty-badge {
  width: 52px; height: 52px; border-radius: 50%; background: var(--line);
  margin: 0 auto 16px; display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 24px; color: var(--accent);
}
.empty-title {
  font-family: var(--serif); font-size: 19px; color: var(--ink); margin-bottom: 6px;
}
.empty p { font-size: 13.5px; color: var(--muted-2); line-height: 1.5; margin: 0; }

/* ---------- month grid -------------------------------------------------- */

.month { margin-top: 18px; }
.month-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.month-nav {
  width: 32px; height: 32px; flex: none; border: none; background: var(--wait-bg);
  border-radius: 9px; font-size: 16px; color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
}
.month-label {
  font-family: var(--serif); font-size: 18px; color: var(--ink); font-weight: 600;
}

.dow, .cells { display: grid; grid-template-columns: repeat(7, 1fr); }
.dow { margin-bottom: 2px; }
.dow span {
  text-align: center; font-size: 11px; font-weight: 700; color: var(--muted-4); padding: 4px 0;
}

.cell {
  position: relative; border: none; background: transparent; padding: 2px 0 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 4px;
}
.cell-num {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 500; color: var(--ink); background: transparent;
}
.cell.out { opacity: .35; }
.cell.today .cell-num { background: var(--line); font-weight: 700; }
.cell.selected .cell-num { background: var(--ink); color: var(--bg); font-weight: 700; }
.cell-mark { display: flex; height: 14px; align-items: center; justify-content: center; }
.cell-mark span {
  width: 14px; height: 14px; border-radius: 50%; color: var(--card);
  font-weight: 800; display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.mark-attention { background: var(--accent); font-size: 10px; }
.mark-good { background: var(--green); font-size: 9px; }

.month-none { text-align: center; padding: 36px 20px; color: var(--muted-4); font-size: 13.5px; }

/* ---------- bottom sheet ------------------------------------------------ */

.sheet-root { position: absolute; inset: 0; z-index: 80; }
.scrim {
  position: absolute; inset: 0; background: rgba(42, 37, 32, .42);
  animation: fadeIn .2s ease; border: none; width: 100%; padding: 0;
}
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--card); border-radius: 26px 26px 0 0;
  padding: 10px 22px calc(30px + var(--safe-bottom));
  box-shadow: 0 -12px 44px rgba(0, 0, 0, .24);
  animation: sheetUp .34s cubic-bezier(.16, 1, .3, 1);
  max-height: 88%; overflow: auto;
}
.grabber {
  width: 40px; height: 5px; border-radius: 3px; background: #E0D4BF; margin: 0 auto 20px;
}

.sheet-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
}
.sheet-title {
  font-family: var(--serif); font-weight: 500; font-size: 25px; color: var(--ink);
  margin: 0; line-height: 1.1;
}
.sheet-day { font-size: 13.5px; color: var(--muted-2); margin-top: 5px; }

.defs { display: flex; flex-direction: column; margin: 18px 0 4px; }
.def {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 11px 0; border-bottom: 1px solid var(--line-mid);
}
.def-k { font-size: 13.5px; color: var(--muted-3); }
.def-v { font-size: 14px; color: var(--ink); font-weight: 600; text-align: right; }
.def-v.green { color: var(--green-text); }

.cover-box {
  margin-top: 14px; background: var(--cover-bg); border: 1px solid var(--cover-border);
  border-radius: 12px; padding: 12px 14px;
}
.cover-box-title { font-size: 13px; font-weight: 700; color: var(--accent-deep); margin-bottom: 3px; }
.cover-box-body { font-size: 13px; color: #7a5a44; line-height: 1.45; }

.note { font-size: 14px; line-height: 1.55; color: var(--ink-2); margin: 14px 0 0; }

.recur-choice { margin-top: 18px; }
.recur-hint { font-size: 12.5px; color: var(--muted-3); margin-bottom: 8px; }
.seg { position: relative; display: flex; background: var(--wait-bg); border-radius: 11px; padding: 4px; }
.seg-pill {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px);
  border-radius: 8px; background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  transition: transform .25s;
}
.seg button {
  position: relative; z-index: 1; flex: 1; border: none; background: transparent;
  padding: 10px; font-size: 13px; font-weight: 600; color: var(--ink);
}

.cta {
  margin-top: 20px; width: 100%; background: var(--accent); color: var(--card);
  border: none; border-radius: 15px; padding: 16px; font-size: 16px; font-weight: 700;
  box-shadow: 0 8px 20px rgba(184, 92, 56, .28);
}
.cta[disabled] { opacity: .6; }

.wait-box {
  margin-top: 18px; background: var(--wait-bg); border-radius: 12px; padding: 13px 15px;
  font-size: 13px; color: var(--wait-text); line-height: 1.5;
}
.wait-box b { color: var(--ink-2); }
.cta-outline {
  margin-top: 12px; width: 100%; background: transparent; color: var(--accent);
  border: 1.5px solid #D9A98F; border-radius: 15px; padding: 15px;
  font-weight: 700; font-size: 15px;
}

.scope-title {
  font-family: var(--serif); font-weight: 500; font-size: 23px; color: var(--ink);
  margin: 0 0 6px; line-height: 1.15;
}
.scope-sub { font-size: 13.5px; color: var(--muted-2); line-height: 1.5; margin: 0; }
.scope-options { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.scope-option {
  text-align: left; border: 1px solid var(--line); background: var(--card-alt);
  border-radius: 14px; padding: 15px 16px;
}
.scope-option-label { font-size: 15px; font-weight: 700; color: var(--ink); }
.scope-option-label.danger { color: var(--accent-deep); }
.scope-option-sub { font-size: 12.5px; color: var(--muted-2); margin-top: 3px; }
.never-mind {
  margin-top: 16px; width: 100%; background: transparent; border: none;
  color: var(--muted-2); font-weight: 600; font-size: 14px; padding: 8px;
}

/* ---------- toast ------------------------------------------------------- */

.toast {
  position: fixed; left: 16px; right: 16px; z-index: 90;
  bottom: calc(44px + var(--safe-bottom));
  max-width: 488px; margin: 0 auto;
  display: flex; align-items: center; gap: 11px;
  background: var(--ink); color: var(--bg);
  padding: 14px 16px; border-radius: 14px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .32);
  animation: toastIn .32s cubic-bezier(.16, 1, .3, 1);
  font-size: 14px; font-weight: 500;
}
.toast-badge {
  flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--green);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px;
}
.toast-badge.warn { background: var(--accent); }
.toast button {
  margin-left: auto; background: transparent; border: none; color: var(--bg);
  font-weight: 700; font-size: 13px; padding: 0; text-decoration: underline;
}

/* ---------- auth screens ------------------------------------------------ */

.auth { padding: var(--safe-top) 22px calc(40px + var(--safe-bottom)); }
.auth-head {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  margin-bottom: 24px;
}
.logo.lg { width: 50px; height: 50px; border-radius: 14px; margin-bottom: 14px; }
.logo.lg img { border-radius: 10px; }
.auth h1 {
  font-family: var(--serif); font-weight: 500; font-size: 27px; color: var(--ink);
  margin: 0 0 6px; letter-spacing: -.01em;
}
.auth-sub {
  font-size: 13.5px; color: var(--muted); margin: 0; line-height: 1.5; max-width: 280px;
}

.fields { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--muted-2); }
.field input {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  padding: 13px 14px; font-size: 14.5px; color: var(--ink); outline: none; width: 100%;
}
.field input:focus { border-color: var(--muted-4); }
.field.invalid input { border-color: var(--accent-deep); }
.field-error { font-size: 12px; color: var(--accent-deep); }

.auth-footer { text-align: center; font-size: 13px; color: var(--muted-2); margin: 20px 0 0; }
.linkbtn {
  border: none; background: transparent; color: var(--accent);
  font-weight: 700; font-size: 13px; padding: 0;
}

/* ---------- install hint + misc ----------------------------------------- */

.install-card {
  margin: 14px 0 0; border: 1px solid var(--line); background: var(--card);
  border-radius: 14px; padding: 13px 15px; display: flex; gap: 12px; align-items: flex-start;
}
.install-card p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.install-card b { color: var(--ink); }

.offline-banner {
  background: var(--pending-bg); color: var(--pending-text);
  font-size: 12.5px; font-weight: 600; text-align: center; padding: 8px 16px;
}

/* ---------- admin ------------------------------------------------------- */

.admin-form { padding-top: 4px; }
.app-tools, .contact-actions { display:flex; flex-wrap:wrap; gap:12px; margin:12px 0; }
.community-post { text-align:left; width:100%; }
.post-body { white-space:pre-wrap; overflow-wrap:anywhere; line-height:1.5; }
.community-post .repeat-help { overflow-wrap:anywhere; }
.scroll.fields > button, .scroll.fields > a, .scroll.fields > article, .scroll.fields > form { flex: 0 0 auto; }

.field select, .field textarea {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  padding: 13px 14px; font-family: inherit; font-size: 14.5px; color: var(--ink);
  outline: none; width: 100%; resize: vertical;
}
.field select:focus, .field textarea:focus { border-color: var(--muted-4); }

.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; }
.field input, .field select, .field textarea { box-sizing: border-box; min-width: 0; max-width: 100%; }
.field input[type="date"], .field input[type="time"] { appearance: none; -webkit-appearance: none; min-height: 48px; }
.field input::-webkit-date-and-time-value { text-align: left; min-width: 0; }
.repeat-options { border: 0; padding: 0; margin: 0; min-width: 0; }
.repeat-options legend { margin-bottom: 10px; }
.repeat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.repeat-grid .checkbox { min-height: 36px; }
.repeat-help { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted-2); }
.admin-form .field-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.admin-form .field-row .field { width: 100%; min-width: 0; }
.admin-form input[type="date"], .admin-form input[type="time"] { display: block; width: 100%; height: 52px; font-size: 16px; }

.field.checkbox {
  flex-direction: row; align-items: center; gap: 10px;
  font-size: 13.5px; color: var(--ink-2);
}
.field.checkbox input { width: 18px; height: 18px; accent-color: var(--green); flex: none; }

/* ---------- misc -------------------------------------------------------- */

.loading { padding: 80px 20px; text-align: center; color: var(--muted-2); font-size: 14px; }
.spinner {
  width: 22px; height: 22px; margin: 0 auto 14px;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite;
}
