:root {
  --bg: #f6f3ee;
  --ink: #1f1a17;
  --muted: #6f675f;
  --line: #e6dfd6;
  --card: #fffdf9;
  --accent: #9a3412;
  --accent-soft: #fff4ec;
  --header: #3f2a22;
  color: var(--ink);
  font-family: "Yu Gothic UI", Meiryo, sans-serif;
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 20px;
  background: var(--header);
  color: #f8f1e8;
}
.brand { display: flex; gap: 10px; align-items: baseline; }
.brand span { opacity: .8; }
.top nav { display: flex; gap: 12px; align-items: center; }
.top a { color: #f8f1e8; }
.top button, .filters button, .toolbar button, .buttons button {
  border: 1px solid transparent;
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 12px;
}
.top button { background: transparent; color: #f8f1e8; border-color: rgba(255,255,255,.35); }
.primary { background: var(--accent) !important; color: #fff !important; }
.danger { background: #fff !important; color: #b91c1c !important; border-color: #fecaca !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

.filters, .toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 20px 0; flex-wrap: wrap; }
.toolbar { padding-top: 10px; }
.nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 4px 10px;
}
.chip.on { color: #fff; border-color: transparent; }
#add-staff { display: flex; gap: 6px; }
#add-staff input, .grid input, .grid select, .grid textarea {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 7px 8px;
}
.switch { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.switch button { border: 0; border-radius: 0; background: transparent; }
.switch button.on { background: var(--header); color: #fff; }

.banner {
  margin: 12px 20px 0;
  padding: 8px 12px;
  background: var(--accent-soft);
  border-radius: 8px;
}
#calendar, #day { margin: 12px 20px 20px; }
.week-wrap { overflow-x: auto; }
.week { display: grid; grid-template-columns: repeat(7, minmax(140px, 1fr)); gap: 8px; min-width: 980px; }
.col, .cell {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 180px;
}
.col.selected, .cell.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.col-head, .cell {
  width: 100%;
  text-align: left;
}
.col-head {
  display: flex;
  justify-content: space-between;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  font-weight: 700;
}
.sat, .dow.sat { color: #1d4ed8; }
.sun, .dow.sun { color: #b91c1c; }
.today .num, .col.today .col-head { color: var(--accent); }
.card, .item {
  display: block;
  width: calc(100% - 12px);
  margin: 0 6px 6px;
  padding: 6px 8px;
  border: 0;
  border-left: 4px solid var(--c, var(--accent));
  border-radius: 8px;
  background: #fff;
  text-align: left;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
}
.card .time, .item .time { font-size: 12px; color: var(--muted); }
.card.cancel, .item.cancel { opacity: .55; }
.card.cancel .what, .item.cancel .what { text-decoration: line-through; }
.badge { font-size: 12px; border-radius: 999px; padding: 1px 6px; background: #ecfdf5; color: #047857; }
.badge.cancel { background: #f5f5f4; color: var(--muted); }

.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dow { text-align: center; font-size: 12px; color: var(--muted); }
.cell { min-height: 92px; padding: 4px; background: var(--card); }
.cell .num { font-weight: 700; }
.cell.out { opacity: .45; }
.cell .card { width: 100%; margin: 4px 0 0; padding: 2px 4px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#day { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 16px; }
#day h2 { margin: 0 0 8px; font-size: 18px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.item { width: 100%; margin: 0 0 8px; }
.item .sub { color: var(--muted); font-size: 13px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  display: grid;
  gap: 12px;
}
.login h1 { margin: 0; font-size: 22px; }
.login label { display: grid; gap: 4px; }
.login input, .login select { border: 1px solid var(--line); border-radius: 8px; padding: 8px; }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(640px, calc(100% - 24px)); background: var(--card); }
dialog::backdrop { background: rgba(40, 28, 22, .45); }
#visit-form { padding: 18px; }
#visit-form h2 { margin: 0 0 12px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid label { display: grid; gap: 4px; font-size: 13px; }
.wide { grid-column: 1 / -1; }
.buttons { display: flex; gap: 8px; margin-top: 12px; }
#toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--header);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
}

@media (max-width: 720px) {
  .top, .filters, .toolbar { padding-left: 12px; padding-right: 12px; }
  #calendar, #day, .banner { margin-left: 12px; margin-right: 12px; }
  .grid { grid-template-columns: 1fr; }
  .week { min-width: 840px; }
  .cell { min-height: 64px; }
}
