:root {
  --teal: #0d9488;
  --teal-d: #0f766e;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --ok: #16a34a;
  --warn: #dc2626;
  --plan: #2563eb;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.5;
  font-size: 16px;
}
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* ---- generic ---- */
button { font: inherit; cursor: pointer; }
.btn {
  background: var(--teal); color: #fff; border: 0; border-radius: 10px;
  padding: 12px 16px; font-weight: 600; width: 100%;
}
.btn:active { background: var(--teal-d); }
.btn.sec { background: #fff; color: var(--teal); border: 1.5px solid var(--teal); }
.btn.ghost { background: transparent; color: var(--muted); border: 0; width: auto; padding: 8px; }
.btn.danger { background: var(--warn); }
.btn.sm { width: auto; padding: 8px 12px; font-size: 14px; border-radius: 8px; }
input, textarea, select {
  font: inherit; width: 100%; padding: 12px; border: 1.5px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--teal); }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }
.field { margin-bottom: 4px; }

/* ---- centered auth screens ---- */
.center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
  padding: 28px 22px; width: 100%; max-width: 380px;
}
.brand { text-align: center; margin-bottom: 18px; }
.brand .logo { font-size: 30px; }
.brand h1 { font-size: 20px; margin: 6px 0 2px; }
.brand p { color: var(--muted); font-size: 13px; margin: 0; }
.err { color: var(--warn); font-size: 13px; margin-top: 10px; min-height: 18px; text-align: center; }

/* member pick */
.member-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.member-tile {
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 16px 10px; text-align: center; font-weight: 600;
}
.member-tile .av {
  width: 44px; height: 44px; border-radius: 50%; background: var(--teal); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 18px; margin: 0 auto 8px;
}
.member-tile.admin .av { background: #b45309; }
.member-tile .tag { font-size: 11px; color: #b45309; display: block; }

/* ---- header + nav ---- */
header {
  background: var(--teal); color: #fff; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
header .who { font-weight: 700; font-size: 15px; }
header .who small { font-weight: 400; opacity: .85; display: block; font-size: 11px; }
header .hbtn { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 8px; padding: 8px 10px; font-size: 13px; }

main { flex: 1; padding: 14px 14px 90px; }

nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 720px; margin: 0 auto;
  background: #fff; border-top: 1px solid var(--line); display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button {
  flex: 1; background: none; border: 0; padding: 10px 4px; color: var(--muted);
  font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
nav.tabs button .ic { font-size: 20px; }
nav.tabs button.active { color: var(--teal); font-weight: 700; }

/* ---- calendar ---- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h2 { font-size: 18px; margin: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; font-weight: 600; }
.cal-dow.sun { color: #dc2626; } .cal-dow.sat { color: #2563eb; }
.cal-cell {
  background: #fff; border: 1px solid var(--line); border-radius: 8px; min-height: 56px;
  padding: 4px; position: relative; text-align: left; color: var(--ink);
}
.cal-cell.empty { background: transparent; border: 0; }
.cal-cell.today { border-color: var(--teal); border-width: 2px; }
.cal-cell .d { font-size: 13px; font-weight: 600; }
.cal-cell.sun .d { color: #dc2626; } .cal-cell.sat .d { color: #2563eb; }
.cal-cell .cnt {
  position: absolute; bottom: 4px; right: 4px; background: var(--teal); color: #fff;
  border-radius: 10px; font-size: 11px; padding: 1px 6px; font-weight: 700;
}
.cal-cell .dots { display: flex; gap: 2px; flex-wrap: wrap; margin-top: 2px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--plan); }
.dot.done { background: var(--ok); } .dot.cancel { background: var(--warn); }

/* ---- cards / lists ---- */
.card { background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 14px; margin-bottom: 10px; }
.job-card { border-left: 4px solid var(--plan); }
.job-card.done { border-left-color: var(--ok); }
.job-card.cancel { border-left-color: var(--warn); opacity: .75; }
.job-card h3 { margin: 0 0 4px; font-size: 16px; }
.job-card .meta { font-size: 13px; color: var(--muted); }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge.plan { background: #dbeafe; color: var(--plan); }
.badge.done { background: #dcfce7; color: var(--ok); }
.badge.cancel { background: #fee2e2; color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: #f1f5f9; border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.section-title { font-size: 13px; color: var(--muted); font-weight: 700; margin: 16px 0 8px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.empty-note { text-align: center; color: var(--muted); padding: 30px 10px; font-size: 14px; }

/* ---- chat ---- */
.chat-wrap { display: flex; flex-direction: column; }
.msg { margin-bottom: 12px; max-width: 84%; }
.msg.me { margin-left: auto; }
.msg .bubble { background: #fff; border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); }
.msg.me .bubble { background: #d1fae5; }
.msg .name { font-size: 12px; color: var(--muted); margin-bottom: 2px; font-weight: 600; }
.msg.me .name { text-align: right; }
.msg .time { font-size: 11px; color: var(--muted); margin-top: 3px; }
.msg .att { margin-top: 6px; }
.msg .att img { max-width: 100%; border-radius: 8px; display: block; }
.msg .att a { font-size: 13px; color: var(--teal); text-decoration: none; display: inline-flex; gap: 6px; align-items: center; padding: 6px 0; }
.composer {
  position: fixed; bottom: 56px; left: 0; right: 0; max-width: 720px; margin: 0 auto;
  background: #fff; border-top: 1px solid var(--line); padding: 8px;
  display: flex; gap: 8px; align-items: flex-end; padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.composer textarea { resize: none; max-height: 100px; min-height: 42px; border-radius: 18px; padding: 10px 14px; }
.composer .iconbtn {
  background: #f1f5f9; border: 0; border-radius: 50%; width: 42px; height: 42px; font-size: 20px; flex: 0 0 auto;
}
.composer .send { background: var(--teal); color: #fff; }
.attach-preview { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 8px 6px; }
.attach-preview .pv { font-size: 12px; background: #e2e8f0; border-radius: 6px; padding: 4px 8px; }

/* ---- modal ---- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal {
  background: #fff; border-radius: 16px 16px 0 0; width: 100%; max-width: 720px;
  padding: 18px; max-height: 92vh; overflow-y: auto;
}
@media (min-width: 600px) { .modal-bg { align-items: center; } .modal { border-radius: 16px; max-width: 480px; } }
.modal h2 { margin: 0 0 10px; font-size: 18px; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.pin-input { letter-spacing: 8px; text-align: center; font-size: 22px; }
.muted { color: var(--muted); font-size: 13px; }
.list-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.spin { text-align: center; color: var(--muted); padding: 24px; }
