/* Meeting Calendar — minimal editorial theme.
   Warm paper ground, serif headings, ink UI, one restrained blue accent.
   Fonts load from Google with a graceful system fallback (works offline). */

:root {
  --font-sans: 'Instrument Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Instrument Serif', 'Iowan Old Style', Georgia, 'Times New Roman', serif;

  --paper: #f6f4ef;
  --surface: #ffffff;
  --ink: #1b1a17;
  --muted: #6f6a60;
  --faint: #97918476;
  --line: #e6e2d8;
  --line-strong: #d7d2c5;

  --accent: #2f5aa8;
  --accent-ink: #23477f;
  --accent-wash: #eef2fa;

  --ok: #1f7a4d;
  --ok-wash: #e7f2ea;
  --danger: #b13a35;
  --danger-wash: #f6e8e5;
  --pending: #8b8577;
  --pending-wash: #efece3;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(20, 18, 15, .05);
  --shadow: 0 4px 16px rgba(20, 18, 15, .06), 0 1px 2px rgba(20, 18, 15, .04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  background-image: radial-gradient(120% 80% at 50% -10%, #fdfcf9 0%, rgba(253, 252, 249, 0) 55%);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Typography ---------- */
h1, h2 { font-family: var(--font-serif); font-weight: 400; letter-spacing: .1px; line-height: 1.1; }
h1 { font-size: 2.35rem; margin: 0 0 1rem; }
h2 { font-size: 1.55rem; margin: 0 0 .35rem; }
h3 { font-size: 1.05rem; font-weight: 600; margin: 0 0 .4rem; letter-spacing: .1px; }
p { margin: .5rem 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: .85rem 1.75rem;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--ink);
  letter-spacing: .2px;
}
.topbar .brand:hover { text-decoration: none; color: var(--accent-ink); }
.topbar nav { display: flex; align-items: center; gap: .35rem; margin-left: auto; }
.topbar nav a {
  color: var(--muted);
  padding: .35rem .6rem;
  border-radius: var(--radius-sm);
  font-size: .93rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.topbar nav a:hover { color: var(--ink); background: #00000008; text-decoration: none; }
.topbar .me {
  color: var(--muted);
  font-size: .88rem;
  padding: .3rem .6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  margin-right: .35rem;
  white-space: nowrap;
}

/* ---------- Layout ---------- */
.container { padding: 2.25rem 1.75rem 4rem; max-width: 880px; margin: 0 auto; }

/* ---------- Buttons ---------- */
button {
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
button:hover { border-color: var(--muted); background: #fbfaf7; }
button:active { transform: translateY(1px); }
button[type="submit"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fdfdfb;
}
button[type="submit"]:hover { background: #322f2a; border-color: #322f2a; }

button.link {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--accent);
  padding: 0;
  font-weight: 500;
}
button.link:hover { background: none; color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }

.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: 1.25rem 0 .5rem; }
.actions a { padding: .5rem .6rem; }

/* ---------- Forms ---------- */
form label { display: block; margin: .7rem 0; color: var(--muted); font-size: .9rem; font-weight: 500; }
input[type="text"], input[type="password"], input[type="number"],
input[type="datetime-local"], input:not([type]) {
  display: block;
  width: 100%;
  max-width: 22rem;
  margin-top: .3rem;
  font: inherit;
  color: var(--ink);
  padding: .5rem .65rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
input[type="checkbox"] { width: auto; display: inline; margin: 0 .4rem 0 0; accent-color: var(--accent); }

fieldset {
  margin: 1.1rem 0;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fcfbf8;
}
fieldset legend { padding: 0 .4rem; color: var(--muted); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
fieldset label { display: flex; align-items: center; gap: .1rem; margin: .35rem 0; color: var(--ink); font-weight: 400; }

/* ---------- Cards ---------- */
.meeting {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 1.15rem 1.35rem;
  margin: .9rem 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s, transform .18s, border-color .18s;
}
article.meeting { border-left: 3px solid var(--line-strong); }
.day .meeting:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--line-strong); }
.meeting h3 a { color: var(--ink); }
.meeting h3 a:hover { color: var(--accent-ink); }
.meeting > p { color: var(--muted); font-size: .92rem; margin-top: 0; }

/* Whole-card link target on the calendar list. The <a class="meeting-link">
   wraps the calendar's article content (h3, p, ul) and gets rendered as
   block so the entire card is clickable, not just the title. The detail
   page (meeting_card.html) does not use this class, so its buttons remain
   actionable. */
.meeting-link {
  display: block;
  color: inherit;
  text-decoration: none;
}
.meeting-link h3 { color: var(--ink); transition: color .15s; }
.meeting-link:hover h3 { color: var(--accent-ink); }

.meeting > h1 { font-size: 1.9rem; }

/* ---------- Participants as status pills ---------- */
ul.participants { list-style: none; padding-left: 0; margin: .6rem 0; display: flex; flex-wrap: wrap; gap: .4rem; }
ul.participants li {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .84rem;
  padding: .22rem .6rem;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--muted);
  background: var(--pending-wash);
}
ul.participants li form { display: inline; margin: 0; }
ul.participants li button { padding: 0 .1rem; font-size: .78rem; line-height: 1; box-shadow: none; border: none; background: none; color: inherit; opacity: .65; }
ul.participants li button:hover { opacity: 1; background: none; }

li.invited { color: var(--pending); background: var(--pending-wash); }
li.accepted { color: var(--ok); background: var(--ok-wash); font-weight: 500; }
li.declined { color: var(--danger); background: var(--danger-wash); text-decoration: line-through; }

/* ---------- Calendar nav ---------- */
.calnav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem;
  margin: 0 0 1.5rem;
  padding: .35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  width: fit-content;
}
.calnav a {
  color: var(--muted);
  padding: .35rem .7rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
}
.calnav a:hover { color: var(--ink); background: #00000008; text-decoration: none; }

.day { border-top: 1px solid var(--line); padding-top: 1.25rem; margin-top: 1.75rem; }
.day:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }
.day > h2 { color: var(--ink); }

/* ---------- States & messages ---------- */
.error { color: var(--danger); }
.conflict {
  color: var(--danger);
  background: var(--danger-wash);
  border: 1px solid #e7c9c5;
  border-radius: var(--radius-sm);
  padding: .7rem 1rem;
  font-weight: 500;
}
.empty { color: var(--muted); font-style: italic; }
.occupied { background: var(--danger-wash); }
.free { background: var(--ok-wash); }

#suggestions button, #conflict-banner { margin-top: .5rem; }

@media (max-width: 560px) {
  .container { padding: 1.5rem 1.1rem 3rem; }
  h1 { font-size: 1.95rem; }
  .topbar { padding: .7rem 1rem; gap: .75rem; flex-wrap: wrap; }
  .topbar nav { gap: .1rem; }
  .topbar .me { display: none; }
}

/* ---------- Action buttons, select & invite row (meeting card) ---------- */
select {
  display: inline-block;
  font: inherit;
  color: var(--ink);
  max-width: 22rem;
  padding: .5rem 2rem .5rem .65rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--muted); background: #fbfaf7; text-decoration: none; color: var(--ink); }
.actions a.btn { padding: .5rem 1rem; }

button.btn-primary, .btn-primary {
  background: var(--ink); border-color: var(--ink); color: #fdfdfb;
}
button.btn-primary:hover, .btn-primary:hover { background: #322f2a; border-color: #322f2a; }

button.btn-danger {
  background: var(--surface); border-color: #d8b3ae; color: var(--danger);
}
button.btn-danger:hover { background: var(--danger-wash); border-color: var(--danger); }

.invite { margin-top: 1rem; }
.invite > label {
  display: block;
  color: var(--muted); font-size: .82rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; margin: 0;
}
.invite .actions { margin: .4rem 0 0; }

ul.participants li .remove:hover { color: var(--danger); opacity: 1; }

/* ---------- Meeting form sections (added 2026-07-08) ---------- */
.form-section { margin: 1.4rem 0 1.2rem; }
.form-section + .form-section { border-top: 1px solid var(--line); padding-top: 1.2rem; }
.section-heading {
  font-size: .82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 0 0 .6rem;
}
.section-num { color: var(--line-strong); margin-right: .35rem; }
.section-field { display: block; }
.section-field > input[type="text"],
.section-field > input[name="title"] {
  max-width: 28rem;
}

/* Когда-карточка */
.when-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem 1.25rem;
  box-shadow: var(--shadow-sm);
}
.when-preview {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  line-height: 1.2;
  color: var(--ink);
  margin: .25rem 0 .9rem;
}
.when-preview.is-empty { color: var(--muted); font-style: italic; }
.when-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: flex-end;
}
.when-input {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  flex: 1 1 12rem;
}
.when-input-label {
  font-size: .82rem;
  color: var(--muted);
  font-weight: 500;
}
.when-actions {
  margin-top: .9rem;
  display: flex;
  gap: .5rem;
  align-items: center;
}

/* ---------- Time input (added 2026-07-08, kept independent of base input rule) ---------- */
input[type="time"] {
  display: block;
  width: 100%;
  max-width: 22rem;
  margin-top: .3rem;
  font: inherit;
  color: var(--ink);
  padding: .5rem .65rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}

/* ---------- Date input (added 2026-07-09, mirrors the time input rule) ---------- */
input[type="date"] {
  display: block;
  width: 100%;
  max-width: 22rem;
  margin-top: .3rem;
  font: inherit;
  color: var(--ink);
  padding: .5rem .65rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}

/* Когда-карточка: состояния и чипы (added 2026-07-08) */
.when-conflict {
  margin-top: .8rem;
  padding: .55rem .8rem;
  background: var(--danger-wash);
  border: 1px solid #e7c9c5;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-weight: 500;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
}
.when-action-link {
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
  cursor: pointer;
}
.when-action-link:hover { color: var(--ink); }

.when-suggestion {
  margin-top: .8rem;
  padding: .7rem .8rem;
  background: var(--ok-wash);
  border: 1px solid #c4ddcb;
  border-radius: var(--radius-sm);
  color: var(--ok);
}
.when-suggestion-head {
  font-weight: 500;
  margin-bottom: .5rem;
}
.slot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.slot-chip {
  font: inherit;
  font-size: .85rem;
  padding: .22rem .65rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  box-shadow: none;
  transition: background .15s, border-color .15s;
}
.slot-chip:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-wash); }

.when-escalation {
  margin-top: .8rem;
  padding: .6rem .8rem;
  background: #fcfbf8;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
}
.when-escalation-head {
  font-weight: 500;
  color: var(--muted);
  margin-bottom: .5rem;
}
.when-escalation-row {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.btn-pill {
  font: inherit;
  font-size: .85rem;
  padding: .22rem .7rem;
  background: transparent;
  border: 1px solid #bccae6;
  border-radius: 999px;
  color: var(--accent);
  cursor: pointer;
  box-shadow: none;
}
.btn-pill:hover { background: var(--accent-wash); color: var(--accent-ink); border-color: var(--accent); }

.when-single {
  margin-top: .8rem;
  color: var(--muted);
  font-style: italic;
}

/* Disabled-состояние (scoped to meeting form so other screens are unaffected) */
form#meeting-form button[disabled], form#meeting-form .btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
  background: var(--surface);
  border-color: var(--line);
  color: var(--muted);
}
form#meeting-form button[type="submit"][disabled] {
  background: var(--muted);
  border-color: var(--muted);
  color: var(--surface);
}

/* ---------- Centered column + cheap responsive (added 2026-07-09) ---------- */

/* All meeting-form sections share one centered column; the constraint drops
   the inherited 22rem input max-width so the column reads as one unit
   rather than a 22rem island next to a wider card. */
.form-section {
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
}

/* Inputs inside .form-section fill the column instead of being capped at 22rem. */
.form-section input[type="text"],
.form-section input[type="date"],
.form-section input[type="time"],
.form-section input[type="number"] {
  max-width: none;
}

/* Textarea inside the title section mirrors the input rule above: fill the
   36rem centered column with the same border / padding / focus treatment. */
.form-section textarea {
  display: block;
  width: 100%;
  max-width: none;
  margin-top: .6rem;
  font: inherit;
  color: var(--ink);
  padding: .55rem .65rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
  resize: vertical;
  min-height: 5.5rem;
}
.form-section textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

/* ---------- Meeting description (added 2026-07-09) ---------- */
/* On the calendar card, clamp the description to a few lines so a long note
   doesn't push the date/time off the card. Full text remains on the detail
   page (no clamp there). */
.meeting-link .meeting-desc {
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.4;
  margin: .1rem 0 .35rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Detail page: full text, same muted paragraph vibe as the time line. */
article.meeting > .meeting-desc {
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  margin: .15rem 0 .55rem;
}

/* Save/Cancel row centered under the same column. Scoped to meeting form
   so .actions in meeting_card is untouched. */
form#meeting-form .actions {
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
  justify-content: flex-end;
}

/* Mobile: drop the column cap (let sections fill container) and stack
   date+time inputs vertically so they each get full width on a phone. */
@media (max-width: 560px) {
  .form-section,
  form#meeting-form .actions { max-width: none; margin-left: 0; margin-right: 0; }
  .when-inputs { flex-direction: column; align-items: stretch; }
  .when-input { flex: 1 1 auto; }
  .preset { padding: .25rem .65rem; font-size: .85rem; }
}

/* Участники-пилюли (label > checkbox visually hidden, :has drives styling) и пресеты длительности (added 2026-07-08) */
.participant-pills {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .9rem;
  padding: .3rem .75rem;
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  border: 1px dashed #bccae6;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.pill input[type="checkbox"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}
.pill:has(input:checked),
.pill[data-self="1"] {
  background: var(--ok-wash);
  color: var(--ok);
  border: 1px solid #c4ddcb;
  font-weight: 500;
}
.pill[data-self="1"] { cursor: default; }
.pill:not([data-self="1"]):hover { background: var(--accent-wash); border-style: solid; border-color: var(--accent); }

.duration-presets {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .55rem;
}
.preset {
  font: inherit;
  font-size: .9rem;
  padding: .3rem .85rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: none;
  transition: background .15s, color .15s, border-color .15s;
}
.preset:hover { border-color: var(--muted); }
.preset.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}
.preset-custom { color: var(--muted); font-style: italic; border-style: dashed; }
.preset-custom:hover { color: var(--ink); border-color: var(--muted); }
