:root {
  --ink: #25211d;
  --muted: #746e66;
  --line: #ded8cf;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --wash: #f1eee7;
  --teal: #14756f;
  --teal-dark: #0f5f5a;
  --coral: #bf4d3e;
  --amber: #a66a12;
  --green: #3f7a3d;
  --shadow: 0 18px 55px rgba(56, 45, 31, 0.16);
  font-family:
    "Inter",
    "Noto Sans JP",
    "Yu Gothic",
    "Meiryo",
    system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(20, 117, 111, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(191, 77, 62, 0.08), transparent 32%),
    var(--paper);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(20px);
  overscroll-behavior: contain;
}

.brand,
.topbar,
.section-heading,
.account-panel,
.composer-actions,
.field-row,
.event-dialog header,
.event-dialog footer,
.footer-actions,
.toolbar,
.filters {
  display: flex;
  align-items: center;
}

.brand,
.topbar,
.section-heading,
.event-dialog header,
.event-dialog footer {
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.45rem;
}

h2 {
  font-size: 1.05rem;
}

.account-panel {
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.account-avatar {
  display: grid;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  background: #dcefe9;
  color: var(--teal-dark);
  font-weight: 800;
}

.account-meta {
  display: grid;
  min-width: 0;
  flex: 1;
}

.account-meta strong,
.account-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-meta span,
.empty-state,
.upcoming-item small,
.month-title p {
  color: var(--muted);
  font-size: 0.82rem;
}

.composer,
.upcoming,
.members-panel,
.setup-panel {
  display: grid;
  gap: 12px;
}

.setup-panel,
.filters label:has(input[data-filter="deadline"]) {
  display: none !important;
}

.composer textarea,
.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.composer textarea {
  min-height: 170px;
  padding: 13px;
  resize: vertical;
  line-height: 1.55;
}

.composer textarea:focus,
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20, 117, 111, 0.14);
}

.composer-actions {
  justify-content: flex-end;
  gap: 10px;
}

.icon-button,
.text-button,
.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  white-space: nowrap;
}

.icon-button {
  width: 40px;
  padding: 0;
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

.text-button,
.secondary-button {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

.text-button {
  padding: 0 14px;
}

.primary-button,
.secondary-button,
.danger-button {
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  background: var(--teal);
  color: white;
}

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

.secondary-button:hover,
.icon-button:hover,
.text-button:hover {
  background: var(--wash);
}

.icon-button.is-enabled {
  border-color: rgba(20, 117, 111, 0.28);
  background: #e9f4ef;
  color: var(--teal-dark);
}

.danger-button {
  border-color: rgba(191, 77, 62, 0.3);
  background: #fff4f1;
  color: var(--coral);
}

.wide {
  width: 100%;
}

.icon-button svg,
.primary-button svg,
.secondary-button svg,
.danger-button svg {
  width: 18px;
  height: 18px;
}

.role-badge {
  padding: 5px 10px;
  border-radius: 999px;
  background: #e9f4ef;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.status-pill {
  padding: 4px 9px;
  border-radius: 999px;
  background: #fff4df;
  color: var(--amber);
  font-size: 0.74rem;
  font-weight: 900;
}

.status-pill.is-ok {
  background: #e9f4ef;
  color: var(--teal-dark);
}

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

.setup-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.setup-item svg {
  width: 18px;
  height: 18px;
  color: var(--amber);
}

.setup-item.is-ok svg {
  color: var(--teal);
}

.setup-item div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.setup-item strong,
.setup-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setup-item strong {
  font-size: 0.84rem;
}

.setup-item span {
  color: var(--muted);
  font-size: 0.76rem;
}

.event-list {
  display: grid;
  gap: 8px;
  overflow: auto;
}

.upcoming-item {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
}

.upcoming-item time {
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
}

.upcoming-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.member-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 108px 40px;
  gap: 8px;
}

.member-form input,
.member-form select {
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

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

.member-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 40px;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.member-item div {
  display: grid;
  min-width: 0;
}

.member-item strong,
.member-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-item span {
  color: var(--muted);
  font-size: 0.78rem;
}

.member-item small {
  padding: 4px 8px;
  border-radius: 999px;
  background: #e9f4ef;
  color: var(--teal-dark);
  font-size: 0.72rem;
  font-weight: 900;
}

.member-item .icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.calendar-pane {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 16px;
  min-width: 0;
  padding: 22px;
}

.topbar {
  min-height: 58px;
}

.month-title {
  min-width: 0;
}

.month-title h2 {
  font-size: 1.8rem;
}

.month-title p {
  margin: 0 0 3px;
}

.toolbar {
  gap: 8px;
}

.filters {
  flex-wrap: wrap;
  gap: 8px;
}

.filters label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-weight: 800;
}

.search-filter {
  min-width: min(260px, 100%);
}

.search-filter svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.search-filter input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  outline: none;
}

.filters input {
  accent-color: var(--teal);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(94px, 1fr));
  grid-auto-rows: minmax(118px, 1fr);
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  gap: 1px;
}

.day-cell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  padding: 10px;
  background: rgba(255, 255, 255, 0.92);
}

.day-cell header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.day-cell header span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  font-weight: 900;
}

.day-cell header small {
  color: var(--muted);
  font-weight: 800;
}

.day-cell.is-outside {
  background: rgba(248, 245, 238, 0.88);
  color: #9a938b;
}

.day-cell.is-today header span {
  background: var(--teal);
  color: white;
}

.day-events {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
}

.event-chip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px;
  min-height: 28px;
  padding: 5px 8px;
  border: 0;
  border-left: 4px solid var(--teal);
  border-radius: 6px;
  background: #eaf6f2;
  color: var(--ink);
  text-align: left;
}

.event-chip.private {
  border-left-color: var(--amber);
  background: #fff4df;
}

.event-chip.deadline {
  border-left-color: var(--coral);
  background: #fff0ed;
}

.event-chip.meeting {
  border-left-color: var(--green);
  background: #eef7eb;
}

.event-chip span {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 900;
}

.event-chip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}

.more-chip {
  width: max-content;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.auth-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(20, 117, 111, 0.12), transparent 45%),
    linear-gradient(315deg, rgba(191, 77, 62, 0.12), transparent 38%),
    var(--paper);
}

.auth-screen[hidden],
.app-shell[hidden],
.toast[hidden] {
  display: none;
}

.auth-box {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.auth-box p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.7;
}

.event-dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: min(860px, calc(100vh - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.event-dialog::backdrop {
  background: rgba(37, 33, 29, 0.34);
  backdrop-filter: blur(4px);
}

.event-dialog form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.event-dialog form.is-readonly .field input,
.event-dialog form.is-readonly .field textarea,
.event-dialog form.is-readonly .field select {
  background: #f7f5ef;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.field input,
.field textarea,
.field select {
  min-height: 42px;
  padding: 9px 11px;
}

.field textarea {
  resize: vertical;
  line-height: 1.55;
}

.field-row {
  gap: 12px;
}

.field-row .field {
  flex: 1;
}

.compact-field {
  flex: 0 0 88px;
}

.compact-field input {
  width: 42px;
  accent-color: var(--teal);
}

.is-muted {
  opacity: 0.48;
}

.footer-actions {
  gap: 10px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}

.desktop-hidden,
.mobile-only {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    width: min(380px, 92vw);
    transform: translateX(-104%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  .app-shell.panel-open .sidebar {
    transform: translateX(0);
  }

  .desktop-hidden,
  .mobile-only {
    display: inline-flex;
  }

  .calendar-pane {
    padding: 16px;
  }

  .calendar-grid {
    grid-template-columns: repeat(7, minmax(84px, 1fr));
    grid-auto-rows: minmax(112px, 1fr);
  }
}

@media (max-width: 700px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .month-title h2 {
    font-size: 1.35rem;
  }

  .calendar-grid {
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-height: none;
    overflow: visible;
  }

  .day-cell {
    min-height: 104px;
  }

  .day-cell.is-outside {
    display: none;
  }

  .field-row,
  .event-dialog footer {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-field {
    flex: 1;
  }

  .footer-actions {
    justify-content: flex-end;
  }
}
