:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef3ef;
  --text: #17201b;
  --muted: #607067;
  --line: #d8ded8;
  --green: #146c43;
  --green-dark: #0d4f32;
  --blue: #255f85;
  --orange: #c56b1d;
  --red: #a13d3d;
  --shadow: 0 18px 50px rgba(23, 32, 27, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 244, 0.92);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-size: 0.82rem;
}

.mode {
  color: var(--muted);
  font-size: 0.94rem;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 56px;
}

.workspace {
  display: grid;
  gap: 18px;
  align-items: start;
}

.create-layout,
.chat-layout {
  grid-template-columns: minmax(0, 1fr) 340px;
}

.host-layout {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.login-layout {
  min-height: calc(100vh - 150px);
  place-items: center;
}

.panel,
.participant-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: clamp(18px, 3vw, 28px);
}

.compact-panel,
.result-panel {
  position: sticky;
  top: 86px;
}

.section-title {
  margin-bottom: 22px;
}

.title-with-action,
.access-note {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.access-note {
  align-items: center;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.8rem, 2.7vw, 2.45rem);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.1rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 4px;
  font-size: 1rem;
}

.section-title p,
.muted {
  color: var(--muted);
}

form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
}

label span,
.label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 12px 13px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 95, 133, 0.14);
}

.field-grid,
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 15px;
  font-weight: 750;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.small-button {
  min-height: 34px;
  white-space: nowrap;
  padding: 7px 10px;
  font-size: 0.88rem;
}

.primary {
  background: var(--green);
  color: #fff;
}

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

.secondary {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.error {
  min-height: 20px;
  color: var(--red);
  font-weight: 650;
}

.check-list,
.slot-list,
.mini-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-list {
  display: grid;
  gap: 10px;
}

.check-list li::before {
  content: "+";
  margin-right: 8px;
  color: var(--green);
  font-weight: 800;
}

.slot-list {
  display: grid;
  gap: 10px;
}

.slot-list li {
  border-left: 4px solid var(--green);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 10px 12px;
  font-weight: 700;
}

.calendar-section {
  display: grid;
  gap: 12px;
  margin: 22px 0;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-dot.available {
  background: var(--green);
}

.legend-dot.busy {
  background: var(--red);
}

.legend-dot.unmentioned {
  background: var(--orange);
}

.calendar-month {
  display: grid;
  gap: 8px;
}

.calendar-title {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: capitalize;
}

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

.calendar-weekdays span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.calendar-day,
.calendar-blank {
  aspect-ratio: 1;
  min-width: 0;
}

.calendar-day {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  color: #fff;
  font-size: 0.86rem;
  font-weight: 850;
  padding: 0;
}

.calendar-day.available {
  background: var(--green);
}

.calendar-day.busy {
  background: var(--red);
}

.calendar-day.unmentioned {
  background: var(--orange);
}

button.calendar-day {
  cursor: pointer;
}

button.calendar-day:hover,
.calendar-day.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(23, 32, 27, 0.12);
}

.own-marker {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 8px;
  height: 8px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: currentColor;
}

.calendar-day.mine-available .own-marker {
  color: var(--green-dark);
}

.calendar-day.mine-busy .own-marker {
  color: #701d1d;
}

.calendar-hint {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.day-editor {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
}

.day-editor h3 {
  margin-bottom: 4px;
  text-transform: capitalize;
}

.day-editor p {
  margin-bottom: 0;
  color: var(--muted);
}

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

.danger {
  color: var(--red);
}

.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 7px;
}

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

.panel-heading h2 {
  margin-bottom: 0;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  min-height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 0;
  font-size: 1.05rem;
}

.participant-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.participant-card {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.card-actions {
  display: grid;
}

.pin-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px 12px;
}

.pin-box span {
  color: var(--muted);
  font-weight: 700;
}

.pin-box strong {
  font-size: 1.25rem;
  letter-spacing: 0;
}

.mini-list {
  display: grid;
  gap: 9px;
  font-size: 0.92rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-right: 7px;
  border-radius: 999px;
  padding: 3px 8px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}

.pill.available {
  background: var(--green);
}

.pill.busy {
  background: var(--red);
}

.login-panel {
  width: min(420px, 100%);
}

.chat-panel {
  min-height: 620px;
}

.messages {
  display: flex;
  min-height: 390px;
  max-height: 52vh;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 14px;
}

.message {
  width: fit-content;
  max-width: min(78%, 680px);
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.42;
}

.message.user {
  align-self: flex-end;
  background: var(--green);
  color: #fff;
}

.message.assistant {
  align-self: flex-start;
  background: var(--surface-2);
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 840px) {
  .create-layout,
  .chat-layout,
  .host-layout,
  .field-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .compact-panel,
  .result-panel {
    position: static;
  }

  .chat-panel {
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .title-with-action,
  .access-note {
    align-items: stretch;
    flex-direction: column;
  }

  .app {
    width: min(100% - 22px, 1180px);
    padding-top: 18px;
  }

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

  .messages {
    min-height: 320px;
  }

  .message {
    max-width: 92%;
  }
}
