:root {
  --bg: #eef3ef;
  --bg-glow: #d8f0e2;
  --card: #ffffff;
  --ink: #12211a;
  --ink-soft: #6b7d74;
  --ink-faint: #a3b1aa;
  --line: #e4ebe6;
  --accent: #14c07a;
  --accent-soft: #d9f7e9;

  --free: #22c55e;
  --light: #a3d977;
  --mid: #f5b73d;
  --busy: #ef5a5a;
  --off: #dbe3dd;

  --radius: 22px;
  --shadow: 0 10px 30px rgba(18, 52, 38, 0.07);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(120% 60% at 50% 0%, var(--bg-glow) 0%, var(--bg) 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 460px; margin: 0 auto; padding: 16px 16px 120px; }

.top { display: flex; align-items: center; justify-content: space-between; margin: 6px 2px 16px; }
.top h1 { font-size: 26px; letter-spacing: -0.5px; margin: 0; font-weight: 700; }
.top .who { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 14px; }

/* --- месяц --- */
.month-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.month-head .name { font-weight: 650; font-size: 17px; }
.nav { display: flex; gap: 6px; }
.nav button {
  width: 34px; height: 34px; border-radius: 12px; border: none; cursor: pointer;
  background: var(--accent-soft); color: #0d7a4d; font-size: 16px; line-height: 1;
}
.nav button:disabled { opacity: .35; cursor: default; }

.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dow { text-align: center; font-size: 11px; color: var(--ink-faint); padding-bottom: 6px; font-weight: 600; }
.dow.we { color: #c9a0a0; }

.day {
  position: relative; border: none; background: none; cursor: pointer;
  padding: 6px 0 8px; border-radius: 14px; font: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.day .num { font-size: 15px; font-weight: 550; line-height: 1; }
.day.out .num { color: var(--ink-faint); }
.day.off .num { color: var(--ink-faint); }
.day.today .num { color: var(--accent); font-weight: 750; }
.day.sel { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.day.sel .num { color: var(--accent); font-weight: 750; }
.day:active { transform: scale(.94); }

.dots { display: flex; gap: 3px; height: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--off); }
.dot.l0 { background: var(--free); }
.dot.l1 { background: var(--light); }
.dot.l2 { background: var(--mid); }
.dot.l3 { background: var(--busy); }


.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

/* --- день --- */
.day-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.day-head .date { font-size: 18px; font-weight: 700; }
.day-head .free { font-size: 12.5px; color: var(--ink-soft); }

.timeline { margin-top: 14px; position: relative; padding-left: 70px; }
.row { position: relative; min-height: 44px; padding-bottom: 10px; }
.row .time { position: absolute; left: -70px; top: 1px; width: 42px; text-align: right; font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.row .bar { position: absolute; left: -19px; top: 4px; bottom: 6px; width: 2px; border-radius: 2px; background: var(--line); }
.row .pip { position: absolute; left: -24px; top: 3px; width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid var(--line); background: var(--card); }

.block { border-radius: 14px; padding: 10px 12px; font-size: 14px; }
.block .sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.block.work { background: #e8f0fd; color: #34558b; }
.block.personal { background: #f0f1f3; color: #6a7280; }
.block.busy { background: #fdecec; color: #8c3a3a; }
.row.out { opacity: .55; }
.block.mine { background: var(--accent-soft); color: #0d6b47; }

.window { border: 1.5px dashed #bfe7d3; background: #f6fffb; border-radius: 16px; padding: 11px 12px 12px; }
.win-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 14px; color: #0d7a4d; }
.win-head .len { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.chip {
  border: none; background: var(--accent); color: #fff; border-radius: 11px;
  padding: 9px 13px; font: inherit; font-size: 14px; font-weight: 650; cursor: pointer;
  font-variant-numeric: tabular-nums; box-shadow: 0 4px 10px rgba(20,192,122,.25);
}
.chip:active { transform: scale(.94); }
.row .pip.free { border-color: var(--accent); }

.empty { text-align: center; color: var(--ink-soft); font-size: 13.5px; padding: 20px 8px; }

/* --- форма --- */
.sheet { position: fixed; inset: 0; background: rgba(12, 32, 24, .38); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet[hidden] { display: none; }
.sheet .inner { background: var(--card); width: 100%; max-width: 460px; border-radius: 26px 26px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); animation: up .22s ease; }
@keyframes up { from { transform: translateY(18px); opacity: .6; } }
.sheet h2 { margin: 0 0 2px; font-size: 19px; }
.sheet .when { color: var(--accent); font-weight: 650; font-size: 14px; margin-bottom: 14px; }

label { display: block; font-size: 12.5px; color: var(--ink-soft); margin: 10px 0 5px; font-weight: 600; }
input, textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 14px; padding: 12px;
  font: inherit; font-size: 15px; background: #fbfdfc; color: var(--ink);
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); background: #fff; }
textarea { min-height: 76px; resize: vertical; }

.who-pick { display: flex; flex-wrap: wrap; gap: 7px; }
.who {
  border: 1.5px solid var(--line); background: transparent; color: var(--ink-soft);
  border-radius: 12px; padding: 9px 14px; font: inherit; font-size: 14px; cursor: pointer;
}
.who.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 650; }
.who:active { transform: scale(.95); }

.actions { display: flex; gap: 10px; margin-top: 16px; }
button.primary, button.ghost { flex: 1; border-radius: 16px; padding: 14px; font: inherit; font-size: 15px; font-weight: 650; cursor: pointer; border: none; }
button.primary { background: var(--accent); color: #fff; box-shadow: 0 8px 20px rgba(20,192,122,.3); }
button.primary:disabled { opacity: .55; box-shadow: none; }
button.ghost { background: #eef2f0; color: var(--ink-soft); }

.banner.move { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; background: var(--accent-soft); color: #0d6b47; border-color: #9fe0c3; }
.banner.move div { display: flex; flex-direction: column; gap: 2px; }
button.ghost.sm { flex: none; padding: 9px 14px; font-size: 13.5px; border-radius: 12px; }
button.danger { flex: 1; border: none; border-radius: 16px; padding: 14px; font: inherit; font-size: 15px; font-weight: 650; cursor: pointer; background: #fdecec; color: #a33b3b; }
.edit-only[hidden] { display: none; }
.block.mine { cursor: pointer; }
.block.mine::after { content: ' ✎'; opacity: .5; font-size: 12px; }

.note { margin-top: 12px; font-size: 13px; border-radius: 14px; padding: 11px 12px; }
.note.err { background: #fdecec; color: #8c3a3a; }
.note.ok { background: var(--accent-soft); color: #0d6b47; }

.skeleton { background: linear-gradient(90deg, #f0f4f2 25%, #e7eeea 50%, #f0f4f2 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 12px; }
@keyframes sk { to { background-position: -200% 0; } }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1613; --bg-glow: #14291f; --card: #16211c; --ink: #e8f2ec; --ink-soft: #8fa79b;
    --ink-faint: #5f7469; --line: #243029; --accent-soft: #123528; --off: #2a3831;
  }
  input, textarea { background: #101a16; }
  button.ghost { background: #1e2a24; }
  button.danger { background: #2e1b1b; color: #f0a5a5; }
  .block.busy { background: #2e1b1b; color: #f0a5a5; }
  .block.work { background: #16233a; color: #9dbdf0; }
  .block.personal { background: #1e2429; color: #93a1ab; }
  .window { background: #10231b; border-color: #1f5741; }
  .win-head { color: #5fd8a4; }
  .note.err { background: #2e1b1b; color: #f0a5a5; }
}

/* Чей созвон записываем — строкой под временем в форме */
.lead-of {
  margin: -4px 0 12px;
  font-size: 13px;
  opacity: 0.75;
}
.lead-of a {
  color: inherit;
  text-decoration: underline;
}
