/* Random Coffee. Светлая и тёмная тема: по теме кошелька, а без неё — как в системе. */
:root {
  --c-bg: #ffffff;
  --c-text: #1c1b1a;
  --c-hint: #8b8580;
  --c-link: #8a4b23;
  --c-button: #8a4b23;
  --c-button-text: #ffffff;
  --c-secondary-bg: #f3efea;
  --c-section-bg: #ffffff;
  --c-section-separator: #e6e0d9;
  --c-accent-text: #8a4b23;
  --c-destructive-text: #d1382b;
  --coffee: #8a4b23;
  --crema: #f4e6d4;
  --good: #2f8a4c;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-bg: #17181a;
    --c-text: #f2eee9;
    --c-hint: #98928c;
    --c-link: #e2a476;
    --c-button: #c97b45;
    --c-button-text: #1b120c;
    --c-secondary-bg: #0f1011;
    --c-section-bg: #1d1f22;
    --c-section-separator: #2c2e32;
    --c-accent-text: #e2a476;
    --c-destructive-text: #ff6b5e;
    --coffee: #c97b45;
    --crema: #3a2a1f;
    --good: #5cc77d;
    color-scheme: dark;
  }
}
/* Кошелёк сказал, что у него тёмная тема. */
:root[data-theme="dark"] {
  --c-bg: #17181a;
  --c-text: #f2eee9;
  --c-hint: #98928c;
  --c-link: #e2a476;
  --c-button: #c97b45;
  --c-button-text: #1b120c;
  --c-secondary-bg: #0f1011;
  --c-section-bg: #1d1f22;
  --c-section-separator: #2c2e32;
  --c-accent-text: #e2a476;
  --c-destructive-text: #ff6b5e;
  --coffee: #c97b45;
  --crema: #3a2a1f;
  --good: #5cc77d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--c-secondary-bg);
  color: var(--c-text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body.busy { cursor: progress; }
main { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 16px 16px 8px; }
h1 { font-size: 22px; line-height: 1.2; margin: 0; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin: 0; }
p { margin: 0 0 8px; }
p:last-child { margin-bottom: 0; }
.muted { color: var(--c-hint); }
.small { font-size: 14px; }

/* шапка и приветствие */
.top { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; }
.top .cup { width: 44px; height: 44px; flex: none; }
.hero { text-align: center; padding: 24px 8px 16px; }
.hero .cup { width: 88px; height: 88px; margin-bottom: 8px; }
.hero h1 { font-size: 26px; margin-bottom: 8px; }
.lead { color: var(--c-hint); max-width: 420px; margin: 0 auto 8px; }
.cup .body { fill: var(--coffee); }
.cup .handle { stroke: var(--coffee); }
.cup .saucer { fill: var(--c-hint); opacity: .45; }
.cup .steam { stroke: var(--c-hint); opacity: .6; }

/* разделы как в настройках Telegram */
.section { margin: 0 0 16px; }
.section-title { color: var(--c-hint); padding: 0 4px 6px; }
.card { background: var(--c-section-bg); border-radius: var(--radius); padding: 14px; }
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 4px; }
.field .label { font-size: 14px; font-weight: 600; }
input, textarea {
  font: inherit;
  color: var(--c-text);
  background: var(--c-secondary-bg);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 12px;
  width: 100%;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--c-button); }
textarea { resize: vertical; min-height: 72px; }
.readonly { padding: 11px 12px; border-radius: 10px; background: var(--c-secondary-bg); color: var(--c-hint); overflow-wrap: anywhere; }
input.code { font-size: 26px; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.hero.compact { padding: 12px 8px 8px; }
.error { color: var(--c-destructive-text); min-height: 0; margin: 0; font-size: 14px; }
.error:empty { display: none; }

/* кнопки */
.btn {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--c-secondary-bg);
  color: var(--c-text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--c-button); color: var(--c-button-text); }
.btn.danger { background: var(--c-destructive-text); color: #fff; }
.btn.plain { background: transparent; color: var(--c-link); padding-left: 8px; padding-right: 8px; }
.btn.muted-btn { color: var(--c-hint); }
.btn.small { font-size: 15px; padding: 8px 14px; min-height: 38px; }
.btn.wide { width: 100%; margin-top: 10px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.row.center { justify-content: center; }
.row.wrap { flex-wrap: wrap; }
.links { display: flex; justify-content: center; margin: 4px 0 12px; }

/* собеседник */
.partners { display: grid; gap: 12px; }
.person { display: flex; gap: 12px; align-items: flex-start; }
.avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--crema);
  color: var(--coffee);
  font-weight: 700;
  font-size: 18px;
  display: grid;
  place-items: center;
}
.who { flex: 1; min-width: 0; }
.who .name { font-weight: 600; font-size: 17px; }
.who .about { margin-top: 4px; font-size: 15px; }

/* выбор времени */
.hint { color: var(--c-hint); font-size: 14px; }
.days { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; margin: 4px -2px 0; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.day {
  position: relative;
  flex: none;
  width: 52px;
  padding: 6px 0;
  border: 0;
  border-radius: 12px;
  background: var(--c-secondary-bg);
  color: var(--c-text);
  font: inherit;
  display: grid;
  justify-items: center;
  cursor: pointer;
}
.day .wd { font-size: 12px; color: var(--c-hint); text-transform: lowercase; }
.day .dn { font-size: 18px; font-weight: 600; }
.day.on { background: var(--c-button); color: var(--c-button-text); }
.day.on .wd { color: inherit; opacity: .8; }
.day .badge {
  position: absolute;
  top: -4px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--good);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
}
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); vertical-align: middle; }
.day .dot { position: absolute; top: 4px; right: 6px; }
.day-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 6px; font-weight: 600; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.slot {
  position: relative;
  font: inherit;
  font-variant-numeric: tabular-nums;
  padding: 10px 0;
  border-radius: 10px;
  border: 1.5px solid var(--c-section-separator);
  background: transparent;
  color: var(--c-text);
  cursor: pointer;
}
.slot.theirs::after { content: ""; position: absolute; top: 5px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.slot.on { background: var(--c-button); border-color: var(--c-button); color: var(--c-button-text); font-weight: 600; }
.slot.on.theirs::after { background: var(--c-button-text); }
.legend { margin: 10px 0 0; }
.confirm { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--c-secondary-bg); }
.confirm .row { margin-top: 6px; }

/* назначенная встреча */
.when { display: flex; gap: 14px; align-items: center; }
.when .big { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--c-accent-text); }
.when .date { font-weight: 600; }

/* история */
.history { list-style: none; margin: 0 0 8px; padding: 0; }
.history li { display: grid; grid-template-columns: 84px 1fr auto; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--c-section-separator); font-size: 15px; align-items: baseline; }
.history li:last-child { border-bottom: 0; }
.history .date { color: var(--c-hint); }
.history .names { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .status { font-size: 13px; color: var(--c-hint); }
.history .status.done { color: var(--good); }

.banner { background: var(--crema); color: var(--c-text); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; }
.banner .btn { margin-top: 4px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--c-text);
  color: var(--c-bg);
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--c-destructive-text); color: #fff; }

.loading { display: grid; place-items: center; min-height: 60vh; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--c-section-separator); border-top-color: var(--c-button); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* пометка студии: совсем маленькая */
.brand { text-align: center; font-size: 11px; color: var(--c-hint); opacity: .7; padding: 6px 16px calc(10px + env(safe-area-inset-bottom)); }

@media (prefers-reduced-motion: reduce) {
  .btn, .toast { transition: none; }
  .spinner { animation-duration: 2s; }
}
