:root {
  color-scheme: light;
  --bg: var(--tg-theme-bg-color, #f5f0e6);
  --text: var(--tg-theme-text-color, #1a3329);
  --hint: var(--tg-theme-hint-color, #6b8575);
  --btn: var(--tg-theme-button-color, #2c4a3e);
  --btn-text: var(--tg-theme-button-text-color, #f5f0e6);
  --sec: var(--tg-theme-secondary-bg-color, #e8e0d0);
  --danger: #8b4a3a;
  --ok: #2c4a3e;
  --busy: #5c4033;
}

* { box-sizing: border-box; }

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

.app {
  max-width: 420px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

.header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 650;
}

.sub {
  margin: 0 0 1rem;
  color: var(--hint);
  font-size: 0.9rem;
}

.panel {
  display: grid;
  gap: 0.5rem;
}

.panel.hidden,
.btn.hidden,
.toolbar.hidden,
.mode-bar.hidden,
.day-actions.hidden {
  display: none;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.month-nav {
  font-weight: 650;
  text-transform: capitalize;
}

.mode-bar,
.day-actions {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
}

.day-cell {
  aspect-ratio: 1;
  border: none;
  border-radius: 10px;
  background: var(--sec);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.day-cell:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  text-decoration: line-through;
}

.day-cell.available {
  background: var(--ok);
  color: var(--btn-text);
}

.day-cell.has-busy {
  background: var(--busy);
  color: #fff;
}

.weekday {
  text-align: center;
  font-size: 0.7rem;
  color: var(--hint);
  font-weight: 600;
}

.month-label {
  grid-column: 1 / -1;
  margin: 0.5rem 0 0.25rem;
  font-weight: 650;
}

.slots {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.slots.patient {
  grid-template-columns: repeat(3, 1fr);
}

.slot {
  border: none;
  border-radius: 12px;
  padding: 0.85rem 0.5rem;
  background: var(--btn);
  color: var(--btn-text);
  font-weight: 650;
  font-size: 1rem;
  cursor: pointer;
  text-align: left;
}

.slots.patient .slot {
  text-align: center;
}

.slot:disabled {
  background: var(--sec);
  color: var(--hint);
  opacity: 0.55;
  cursor: not-allowed;
}

.slot.busy,
.slot.closed {
  background: var(--busy);
  color: #fff;
  opacity: 1;
}

.slot .slot-sub {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.9;
  margin-top: 0.2rem;
}

.footer {
  margin-top: 1.25rem;
}

.btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-small {
  width: auto;
  padding: 0.45rem 0.75rem;
  background: var(--sec);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--hint);
}

.btn-mode {
  background: var(--btn);
  color: var(--btn-text);
}

.detail {
  background: var(--sec);
  border-radius: 12px;
  padding: 1rem;
  line-height: 1.45;
}

.detail a {
  color: var(--ok);
}

.file-list {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.file-list li {
  margin: 0.35rem 0;
}

.schedule-day {
  background: var(--sec);
  border-radius: 12px;
  padding: 0.85rem;
  display: grid;
  gap: 0.5rem;
}

.schedule-day h3 {
  margin: 0;
  font-size: 1rem;
}

.schedule-day label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--hint);
}

.schedule-day input,
.schedule-day select {
  border: 1px solid var(--hint);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
}

.schedule-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.error {
  color: var(--danger);
  padding: 1rem 0;
}
