/* Favoria — iPhone-first salon photo manager. Warm, clean salon aesthetic. */

:root {
  --rose: #b76e79;
  --rose-dark: #99535e;
  --bg: #faf7f5;
  --card: #ffffff;
  --ink: #2b2426;
  --muted: #8a7f82;
  --line: #efe7e4;
  --danger: #d2453f;
  --shadow: 0 1px 3px rgba(60, 40, 45, .08), 0 6px 18px rgba(60, 40, 45, .06);
  --radius: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--muted); }

#app { max-width: 640px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(96px + var(--safe-b)); }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: calc(10px + var(--safe-t)) 12px 10px;
  background: rgba(250, 247, 245, .85);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 20px; letter-spacing: .3px; color: var(--rose-dark); }
.brand-name { color: var(--ink); font-size: 18px; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 40px; height: 40px; border: none; background: transparent;
  font-size: 22px; color: var(--rose-dark); border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: rgba(183, 110, 121, .12); }

/* Search */
.search-wrap { padding: 12px 14px 4px; }
.search {
  width: 100%; border: 1px solid var(--line); background: var(--card);
  border-radius: 14px; padding: 13px 14px; font-size: 16px; color: var(--ink);
  box-shadow: var(--shadow);
}
.search:focus { outline: 2px solid rgba(183, 110, 121, .35); border-color: transparent; }

/* List */
.list { padding: 8px 14px; display: flex; flex-direction: column; gap: 10px; }
.card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border-radius: var(--radius); padding: 12px 14px;
  box-shadow: var(--shadow);
}
.card:active { transform: scale(.99); }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--rose), #d49aa3);
  color: #fff; font-weight: 700; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.card-main { flex: 1; min-width: 0; }
.card-title { font-weight: 600; font-size: 17px; }
.card-sub { font-size: 13px; margin-top: 2px; }
.chev { color: #cbbdc0; font-size: 24px; }

/* Memo / meta on detail */
.memo { margin: 12px 14px 0; background: #fff7f4; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; font-size: 14px; white-space: pre-wrap; }
.meta-row { padding: 10px 16px 0; font-size: 15px; }
.meta-row a { color: var(--rose-dark); font-weight: 600; }

/* Visits */
.visits { padding: 6px 14px; display: flex; flex-direction: column; gap: 18px; margin-top: 8px; }
.visit { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.visit-head { display: flex; align-items: center; justify-content: space-between; }
.visit-date { font-weight: 700; font-size: 16px; }
.visit-memo { font-size: 13px; margin-top: 4px; white-space: pre-wrap; }
.link-btn { border: none; background: transparent; color: var(--muted); font-size: 22px; padding: 0 6px; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.thumb {
  position: relative; aspect-ratio: 1 / 1; border: none; padding: 0;
  border-radius: 12px; overflow: hidden; background: #f0e9e7;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:active { opacity: .85; }
.thumb-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--rose); border: 2px dashed #e3cdd0; background: #fffafa;
}
.thumb-add span { font-size: 28px; line-height: 1; }
.thumb-add small { font-size: 11px; color: var(--muted); }

/* Empty states */
.empty { text-align: center; padding: 64px 24px; color: var(--muted); }
.empty-emoji { font-size: 44px; margin-bottom: 12px; }
.empty p { margin: 4px 0; }

/* FAB */
.fab {
  position: fixed; right: max(18px, env(safe-area-inset-right));
  bottom: calc(20px + var(--safe-b)); z-index: 30;
  border: none; background: linear-gradient(135deg, var(--rose), var(--rose-dark));
  color: #fff; border-radius: 999px; height: 56px; padding: 0 22px;
  font-size: 17px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(153, 83, 94, .4);
  display: inline-flex; align-items: center; gap: 6px;
}
.fab:active { transform: translateY(1px) scale(.98); }
/* Single ＋ FAB on home is round */
#addCustomer { padding: 0; width: 56px; font-size: 28px; justify-content: center; }

/* Buttons */
.btn { border: none; border-radius: 12px; padding: 13px 18px; font-size: 16px; font-weight: 600; }
.btn-primary { background: var(--rose); color: #fff; }
.btn-primary:active { background: var(--rose-dark); }
.btn-ghost { background: #f1eae8; color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn.block { display: block; width: 100%; text-align: center; }

/* Bottom sheet */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(30, 20, 22, .35);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .18s ease;
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  width: 100%; max-width: 640px; background: var(--bg);
  border-radius: 22px 22px 0 0; padding: 10px 18px calc(22px + var(--safe-b));
  transform: translateY(100%); transition: transform .2s ease;
  max-height: 90vh; overflow-y: auto;
}
.sheet-backdrop.open .sheet { transform: translateY(0); }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: #d9cccd; margin: 4px auto 10px; }
.sheet-title { font-size: 18px; margin: 4px 2px 14px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; font-size: 16px; background: #fff; color: var(--ink);
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid rgba(183, 110, 121, .35); border-color: transparent; }
.sheet-actions { display: flex; gap: 10px; margin-top: 6px; }
.sheet-actions .btn { flex: 1; }

/* Action sheet */
.action-sheet {
  width: 100%; max-width: 640px; margin: 0 auto 0;
  align-self: flex-end; padding: 8px 12px calc(12px + var(--safe-b));
  display: flex; flex-direction: column; gap: 8px;
  transform: translateY(100%); transition: transform .18s ease;
}
.sheet-backdrop.open .action-sheet { transform: translateY(0); }
.action {
  background: #fff; border: none; border-radius: 14px; padding: 16px; font-size: 17px;
  color: var(--rose-dark); font-weight: 600; box-shadow: var(--shadow);
}
.action.danger { color: var(--danger); }
.action.cancel { color: var(--ink); margin-top: 4px; }

/* Confirm dialog */
.dialog {
  background: #fff; border-radius: 18px; padding: 22px; margin: auto 20px;
  align-self: center; max-width: 360px; width: 100%; box-shadow: var(--shadow);
}
.sheet-backdrop:has(.dialog) { align-items: center; }
.dialog-msg { margin: 0 0 18px; font-size: 15px; line-height: 1.6; }
.dialog-actions { display: flex; gap: 10px; }
.dialog-actions .btn { flex: 1; }

/* Photo viewer */
.viewer {
  position: fixed; inset: 0; z-index: 60; background: #1a1416;
  display: flex; flex-direction: column;
}
.viewer-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + var(--safe-t)) 8px 8px; color: #fff;
}
.viewer-count { color: #fff; font-size: 14px; font-variant-numeric: tabular-nums; }
.icon-btn.light { color: #fff; }
.viewer-stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.12); color: #fff; border: none;
  width: 44px; height: 64px; font-size: 30px;
}
.viewer-nav.prev { left: 0; border-radius: 0 12px 12px 0; }
.viewer-nav.next { right: 0; border-radius: 12px 0 0 12px; }

/* Settings */
.settings { padding: 16px 14px; display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 8px; font-size: 16px; }
.panel p { font-size: 13px; line-height: 1.6; margin: 0 0 14px; }
.panel .btn:last-child { margin-bottom: 0; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: rgba(43, 36, 38, .94); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80;
  max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
