:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e1e5eb;
  --border-strong: #c9d0da;
  --text: #1b2430;
  --muted: #5f6b7a;
  --faint: #8a94a3;
  --primary: #0f6cbd;
  --primary-hover: #0c5aa0;
  --primary-ring: rgba(15, 108, 189, 0.22);
  --error: #c4314b;
  --error-bg: #fdf3f4;
  --radius: 10px;
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Top bar */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  flex-shrink: 0;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12.5px; font-weight: 500;
  text-decoration: none;
  transition: color .15s, border-color .15s;
}
.back-link:hover { color: var(--primary); border-color: var(--primary); }
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: grid; place-items: center;
}
.brand-title { font-weight: 600; font-size: 15px; }
.brand-sub { color: var(--muted); font-size: 12.5px; }

.account-switch {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 12.5px;
}
.account-switch select { width: auto; padding: 6px 30px 6px 10px; font-size: 12.5px; }

/* Layout */
.layout {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 28px 48px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 24px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.form-card { padding: 8px 28px 24px; }

.section { padding: 18px 0; border-bottom: 1px solid var(--border); }
.section:last-of-type { border-bottom: 0; }

.section-title {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.step {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #e8f1fa;
  color: var(--primary);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
}

.grid { display: grid; gap: 4px 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: 1.2fr 1fr 1fr; }

.field { display: flex; flex-direction: column; margin-bottom: 4px; }
.field label { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.req { color: var(--error); font-weight: 600; }
.optional { color: var(--faint); font-weight: 400; font-size: 12px; margin-left: 4px; }

input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 9px 11px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%235f6b7a' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
textarea { resize: vertical; min-height: 200px; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: #a3acb9; }
input:hover, select:hover, textarea:hover { border-color: #aab4c2; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.field.invalid input, .field.invalid textarea {
  border-color: var(--error);
  background: var(--error-bg);
}
.field.invalid input:focus { box-shadow: 0 0 0 3px rgba(196, 49, 75, 0.18); }

.error { color: var(--error); font-size: 12.5px; margin: 4px 0 0; min-height: 18px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; min-height: 18px; }
.field .hint + .error { min-height: 0; }

.link-btn {
  background: none; border: 0; padding: 0;
  color: var(--primary);
  font: inherit; font-size: 12.5px;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }
.link-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 2px; }

/* Actions */
.actions { padding-top: 20px; border-top: 1px solid var(--border); }

.form-alert {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid #f1c3cc;
  background: var(--error-bg);
  color: var(--error);
  border-radius: 6px;
  font-size: 13px;
}

.btn-primary {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 20px;
  font: inherit; font-size: 15px; font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 108, 189, 0.3);
  transition: background 0.12s, transform 0.06s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:focus-visible { outline: none; box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--primary); }

.actions-row {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin-top: 10px;
}
.note { margin: 0; color: var(--faint); font-size: 12px; }

.btn-secondary {
  flex-shrink: 0;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 7px 14px;
  cursor: pointer;
}
.btn-secondary:hover { background: #f6f8fa; }
.btn-secondary:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); border-color: var(--primary); }

.shortcut { margin: 14px 0 0; color: var(--faint); font-size: 12px; }
kbd {
  font-family: inherit; font-size: 11px;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #fafbfc;
  color: var(--muted);
}

/* Preview */
.preview-card {
  position: sticky;
  top: 24px;
  overflow: hidden;
}
.preview-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.preview-label {
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.preview-status {
  font-size: 11.5px; font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: #fff4e5;
  color: #8a5300;
}
.preview-status.ready { background: #e7f5ec; color: #17693a; }

.preview { margin: 0; padding: 6px 22px 18px; }
.preview-row { padding: 12px 0; border-bottom: 1px solid #eef1f4; }
.preview-row:last-child { border-bottom: 0; }
.preview-row.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.preview dt {
  font-size: 11.5px; font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}
.preview dd { margin: 0; word-break: break-word; }
.pv-subject { font-size: 15px; font-weight: 600; }
.pv-description {
  white-space: pre-wrap;
  color: #2e3a48;
  max-height: 46vh;
  overflow: auto;
  font-size: 13.5px;
}
.placeholder { color: #a3acb9; font-style: italic; }
.attendee {
  display: inline-block;
  margin: 2px 6px 2px 0;
  padding: 1px 9px;
  border-radius: 999px;
  background: #eef4fb;
  color: #1c4f80;
  font-size: 13px;
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .preview-card { position: static; }
}
@media (max-width: 600px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; padding: 12px 18px; }
  .layout { padding: 16px 14px 32px; }
  .form-card { padding: 4px 18px 18px; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .actions-row { flex-direction: column; align-items: flex-start; }
}

.checkbox {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 4px;
  font-size: 13px; color: var(--muted);
  cursor: pointer;
}
.checkbox input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }

.pv-local { margin-top: 2px; color: var(--muted); font-size: 12.5px; }
