:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --ink: #1c1c1a;
  --muted: #6b6b66;
  --line: #dedcd6;
  --accent: #2f6f4e;
  --accent-ink: #ffffff;
  --hit: #2f6f4e;
  --warn: #a5401f;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --panel: #1f2126;
    --ink: #e9e8e4;
    --muted: #9a9a94;
    --line: #33363d;
    --accent: #63b98a;
    --accent-ink: #10231a;
    --hit: #63b98a;
    --warn: #e08b6b;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  -webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--warn); }
a { color: var(--accent); }

/* ---- ログイン ---- */
.login { display: grid; place-items: center; min-height: 100dvh; padding: 20px; }
.login-card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  display: grid;
  gap: 12px;
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input[type=email], input[type=password], input[type=text], input[type=search], select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 8px 12px;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; padding: 11px; }
button.ghost { background: transparent; }
button.danger { background: var(--warn); color: #fff; border-color: transparent; font-weight: 600; padding: 11px; }
button:disabled { opacity: .5; cursor: default; }

/* ---- 上部バー ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 8px; align-items: center;
  padding: 8px 10px calc(8px);
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.searchwrap { flex: 1; }
.iconbtn {
  border: none; background: transparent; font-size: 19px; line-height: 1;
  padding: 8px; border-radius: 8px;
}
.iconbtn:hover { background: var(--bg); }

main { padding: 12px; padding-bottom: 40vh; max-width: 900px; margin: 0 auto; }

/* ---- 間取り ---- */
.mapwrap { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mapwrap img { display: block; width: 100%; height: auto; }
.mapwrap svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.room { fill: color-mix(in srgb, var(--hit) 18%, transparent); stroke: var(--hit); stroke-width: 2; cursor: pointer; }
.room:hover { fill: color-mix(in srgb, var(--hit) 34%, transparent); }
.room.flash { animation: flash 1.1s ease-in-out 3; }
@keyframes flash { 50% { fill: color-mix(in srgb, var(--warn) 55%, transparent); } }
.room-label { fill: var(--ink); font-size: 13px; font-weight: 600; text-anchor: middle; pointer-events: none; paint-order: stroke; stroke: var(--panel); stroke-width: 3px; }
.draft { fill: color-mix(in srgb, var(--warn) 22%, transparent); stroke: var(--warn); stroke-width: 2; stroke-dasharray: 5 4; }
.handle { fill: var(--warn); }

/* ---- リスト ---- */
.list { display: grid; gap: 8px; margin-top: 12px; }
.row {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; text-align: left; width: 100%;
}
.row:hover { border-color: var(--accent); }
.row .thumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--bg); flex: none; }
.row .body { flex: 1; min-width: 0; }
.row .name { font-weight: 600; }
.row .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .count { font-size: 12px; color: var(--muted); flex: none; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }

.crumb { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.crumb button { border: none; background: none; padding: 0; color: var(--accent); font-size: 13px; }
.section-title { margin: 18px 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.empty { color: var(--muted); padding: 24px 4px; text-align: center; }

/* ---- 下から出るシート ---- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-height: 72dvh; display: flex; flex-direction: column;
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,.18);
}
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.sheet-head .crumb { flex: 1; }
.sheet-body { overflow: auto; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }

/* ---- モーダル(QR表示など) ---- */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(0,0,0,.5); padding: 16px; }
.modal-card { position: relative; background: var(--panel); border-radius: var(--radius); padding: 20px; width: min(420px, 100%); max-height: 88dvh; overflow: auto; }
.modal-x { position: absolute; top: 6px; right: 6px; }
.qr { display: block; width: 220px; height: 220px; margin: 12px auto; background: #fff; border-radius: 8px; padding: 8px; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.urlbox { display: flex; gap: 6px; }
.urlbox input { font-size: 12px; font-family: ui-monospace, monospace; }

/* ---- 編集画面 ---- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar .grow { flex: 1; }
.hint { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px 12px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 999px;
  font-size: 13px; z-index: 50;
}
