:root {
  color-scheme: light;
  --bg: #f7f8f7;
  --surface: #ffffff;
  --surface-strong: #f0f3f1;
  --text: #222525;
  --muted: #66716f;
  --line: #d9dfdc;
  --line-strong: #bcc8c4;
  --teal: #2b6f6d;
  --teal-dark: #205756;
  --teal-soft: #e1f0ed;
  --blue: #445fb8;
  --blue-soft: #e7ebfb;
  --rust: #b85231;
  --rust-soft: #f7e7df;
  --yellow: #c18a1b;
  --yellow-soft: #fff3cf;
  --danger: #b42318;
  --danger-soft: #ffe6e2;
  --shadow: 0 18px 50px rgba(26, 35, 33, 0.1);
  --radius: 8px;
  --timeline-height: 1440px;
  font-family:
    "Inter", "Noto Sans JP", "Yu Gothic UI", "Hiragino Kaku Gothic ProN",
    Meiryo, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

[hidden] {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(43, 111, 109, 0.08), transparent 42%),
    var(--bg);
}

.login-panel {
  width: min(100%, 430px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-mark,
.brand-icon {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--teal-soft);
  color: var(--teal);
}

.brand-mark {
  margin-bottom: 18px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 22px;
  font-size: clamp(1.45rem, 4vw, 2rem);
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
  line-height: 1.3;
}

h3 {
  margin-bottom: 0;
  font-size: 0.95rem;
}

.login-form,
.reservation-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 9px 11px;
  outline: none;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(43, 111, 109, 0.16);
}

.password-row,
.form-row {
  display: grid;
  gap: 10px;
}

.password-row {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.form-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 7px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.primary-button {
  background: var(--teal);
  color: #fff;
  padding: 0 16px;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.secondary-button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0 14px;
}

.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-strong);
}

.ghost-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0 12px;
}

.ghost-button.compact {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.8rem;
}

.icon-button {
  width: 42px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.wide {
  width: 100%;
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 74px;
  padding: 14px 24px;
  background: rgba(247, 248, 247, 0.93);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand,
.topbar-actions,
.date-controls,
.month-controls,
.list-heading {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
}

.topbar-actions {
  gap: 10px;
}

.storage-badge,
.count-pill,
.mini-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.storage-badge {
  padding: 0 12px;
  background: var(--yellow-soft);
  color: #6e4c08;
}

.storage-badge.is-shared {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.workspace {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px 24px 32px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.date-controls {
  gap: 8px;
}

.selected-date {
  margin-left: 8px;
  display: grid;
  gap: 1px;
}

.selected-date span {
  font-size: 1.05rem;
  font-weight: 900;
}

.selected-date small {
  color: var(--muted);
  font-weight: 700;
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segment {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 900;
}

.segment.is-active {
  color: #fff;
  background: var(--teal);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(310px, 0.85fr) minmax(420px, 1.35fr) minmax(320px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.tool-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(26, 35, 33, 0.05);
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.calendar-panel .panel-header {
  display: grid;
  grid-template-columns: 1fr;
}

.calendar-panel .month-controls {
  width: 100%;
  justify-content: space-between;
}

.month-controls {
  gap: 6px;
}

.month-controls .icon-button {
  width: 34px;
  min-height: 34px;
}

.month-label {
  min-width: 112px;
  text-align: center;
  font-weight: 900;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.calendar-grid {
  gap: 6px;
}

.calendar-day {
  position: relative;
  display: grid;
  align-content: start;
  gap: 5px;
  min-height: 78px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.calendar-day:hover {
  border-color: var(--teal);
}

.calendar-day.is-outside {
  color: #9aa4a1;
  background: #f4f6f5;
}

.calendar-day.is-selected {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(43, 111, 109, 0.16);
}

.calendar-day.is-today::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rust);
}

.day-number {
  font-size: 0.9rem;
  font-weight: 900;
}

.day-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.room-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 900;
}

.room-badge.room-a {
  background: var(--blue-soft);
  color: var(--blue);
}

.room-badge.room-b {
  background: var(--rust-soft);
  color: var(--rust);
}

.count-pill {
  min-width: 48px;
  padding: 0 12px;
  background: var(--surface-strong);
  color: var(--muted);
}

.timeline {
  overflow-x: auto;
  padding-bottom: 4px;
}

.timeline-shell {
  display: grid;
  grid-template-columns: 56px repeat(2, minmax(160px, 1fr));
  min-width: 470px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.time-axis,
.room-lane {
  min-height: calc(var(--timeline-height) + 42px);
}

.time-axis {
  border-right: 1px solid var(--line);
  background: #fbfcfb;
}

.axis-head,
.lane-head {
  display: grid;
  place-items: center;
  height: 42px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.axis-body,
.lane-body {
  position: relative;
  height: var(--timeline-height);
}

.time-label {
  position: absolute;
  right: 8px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.hidden-label {
  display: none;
}

.hour-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--line);
}

.axis-body .hour-line {
  display: none;
}

.room-lane + .room-lane {
  border-left: 1px solid var(--line);
}

.lane-head {
  color: var(--text);
  background: #fbfcfb;
}

.room-lane[data-room="A"] .lane-head {
  border-top: 3px solid var(--blue);
}

.room-lane[data-room="B"] .lane-head {
  border-top: 3px solid var(--rust);
}

.reservation-block {
  position: absolute;
  left: 8px;
  right: 8px;
  display: grid;
  align-content: start;
  gap: 3px;
  min-height: 42px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  text-align: left;
  overflow: hidden;
}

.reservation-block.is-short {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 8px;
}

.reservation-block.room-a {
  background: var(--blue-soft);
  border-color: rgba(68, 95, 184, 0.25);
  color: #253877;
}

.reservation-block.room-b {
  background: var(--rust-soft);
  border-color: rgba(184, 82, 49, 0.25);
  color: #74341f;
}

.reservation-block:hover {
  filter: saturate(1.08);
}

.block-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 900;
}

.block-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.72rem;
  font-weight: 800;
  opacity: 0.86;
}

.reservation-block.is-short .block-title {
  flex: 1 1 auto;
  font-size: 0.78rem;
}

.reservation-block.is-short .block-meta {
  flex: 0 1 auto;
  max-width: 54%;
  font-size: 0.7rem;
}

.reservation-panel {
  position: sticky;
  top: 92px;
}

.day-list-wrap {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.list-heading {
  justify-content: space-between;
  margin-bottom: 10px;
}

.mini-count {
  min-width: 28px;
  background: var(--surface-strong);
  color: var(--muted);
}

.day-list {
  display: grid;
  gap: 8px;
}

.reservation-item {
  display: grid;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.reservation-item.is-editing {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(43, 111, 109, 0.14);
}

.item-top,
.item-actions,
.item-meta {
  display: flex;
  align-items: center;
}

.item-top {
  justify-content: space-between;
  gap: 8px;
}

.item-title {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 900;
}

.item-actions {
  gap: 6px;
}

.item-action {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
}

.item-action:hover {
  background: var(--surface-strong);
}

.item-action.danger {
  color: var(--danger);
}

.item-meta {
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.item-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 84px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 7px;
  background: #222525;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1160px) {
  .content-grid {
    grid-template-columns: minmax(320px, 0.9fr) minmax(430px, 1.1fr);
  }

  .reservation-panel {
    position: static;
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .date-controls {
    justify-content: space-between;
  }

  .workspace,
  .topbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .segmented-control {
    width: 100%;
  }
}

@media (max-width: 560px) {
  :root {
    --timeline-height: 1400px;
  }

  .login-panel,
  .tool-panel {
    padding: 14px;
  }

  .password-row,
  .form-row {
    grid-template-columns: 1fr;
  }

  .calendar-day {
    min-height: 62px;
    padding: 6px;
  }

  .room-badge {
    min-height: 18px;
    padding: 0 5px;
    font-size: 0.68rem;
  }

  .brand h1 {
    font-size: 1.1rem;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .ghost-button {
    flex: 1 1 auto;
  }
}
