@import url("https://fonts.googleapis.com/css2?family=Fraunces:wght@600;700&family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #0d0f12;
  --surface: #14171b;
  --surface-2: #1a1e24;
  --surface-3: #21262e;
  --border: #2c313a;
  --border-soft: #2c313a80;
  --text: #f2efe6;
  --text-muted: #9a968c;
  --accent: #f4c430;
  --accent-hover: #e0b32a;
  --accent-ink: #14120a;
  --coral: #ea5a37;
  --teal: #57ab9f;
  --error-bg: #2a1712;
  --error-border: #4a2318;
  --error-text: #ff9270;
  --success-bg: #12241c;
  --success-border: #1f4534;
  --success-text: #6fcf9e;

  --display: "Fraunces", serif;
  --body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ---------- Topbar (тот же компонент, что в остальных сервисах) ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  color: var(--accent);
  white-space: nowrap;
}

.new-event-btn {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
}

.new-event-btn:hover {
  background: var(--accent-hover);
}

main {
  flex: 1;
  padding: 20px 24px 40px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.state-box {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
}

.state-box.error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
}

/* ---------- Панель управления календарём ---------- */

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-arrow {
  font-size: 18px;
}

.calendar-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  margin-left: 6px;
  text-transform: capitalize;
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.ghost-btn:hover {
  border-color: var(--accent);
}

.ghost-btn.danger-text {
  color: var(--coral);
}

.ghost-btn.danger-text:hover {
  border-color: var(--coral);
}

/* ---------- Сетка месяца ---------- */

.calendar-grid {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.weekday-cell {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.calendar-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(96px, 1fr);
}

.day-cell {
  border-right: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: pointer;
  min-width: 0;
}

.day-cell:hover {
  background: var(--surface-2);
}

.day-cell.outside-month {
  color: var(--text-muted);
  background: #0d0f1280;
}

.day-cell.outside-month .day-num {
  color: var(--text-muted);
}

.day-cell.today .day-num {
  background: var(--accent);
  color: var(--accent-ink);
}

.day-num {
  font-size: 12.5px;
  font-weight: 600;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.event-chip {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface-3);
  border: none;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-chip:hover {
  background: #2a303a;
}

.event-chip-invite {
  border-left-color: var(--teal);
}

.event-chip-pending {
  border-left-style: dashed;
}

.event-chip-declined {
  opacity: 0.5;
  text-decoration: line-through;
}

.event-more {
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 6px;
}

/* ---------- Модалка события ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: #000000a6;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

/* Специфичность класса .modal-overlay { display: flex } формально равна
   встроенному UA-правилу [hidden] { display: none }, и авторский CSS
   выигрывает — без этого переопределения модалка виднелась бы поверх всего
   при наличии атрибута hidden. См. похожий баг, найденный ранее в
   disk-frontend. */
.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px 24px;
  box-shadow: 0 26px 60px -18px rgba(0, 0, 0, 0.65);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  padding: 0;
}

.modal-close:hover {
  color: var(--text);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
}

.modal-actions .primary {
  margin-left: auto;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
}

.modal-actions .primary:hover {
  background: var(--accent-hover);
}

/* ---------- Форма события ---------- */

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 14px;
  background: var(--surface-2);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 14px;
  cursor: pointer;
}

.checkbox-label input {
  margin: 0;
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: -8px 0 14px;
}

/* ---------- Просмотр события ---------- */

.event-view-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 10px;
}

.event-view-row {
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 8px;
}

.event-view-attendees {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}

.attendee-row {
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 2px 0;
}

.event-respond {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

.event-respond-label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.event-respond-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.respond-btn {
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
}

.respond-btn:hover {
  border-color: var(--accent);
}

/* ---------- Сетка сервисов prufit / меню аккаунта ---------- */

.icon-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 50%;
  line-height: 1;
}

.icon-btn:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

.dropdown-holder {
  position: relative;
}

.apps-panel,
.account-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 26px 60px -18px rgba(0, 0, 0, 0.65);
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 60;
}

.apps-panel {
  width: 280px;
  padding: 18px;
}

.apps-panel.show,
.account-panel.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.apps-panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 14px 6px;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}

.apps-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 6px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 12.5px;
  text-align: center;
}

.apps-tile:hover {
  background: var(--surface-3);
}

.apps-tile-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: var(--surface-3);
}

.apps-tile.active .apps-tile-icon {
  background: var(--accent);
}

.account-panel {
  width: 264px;
  padding: 20px;
}

.account-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--coral));
  color: var(--accent-ink);
  border: none;
  cursor: pointer;
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: box-shadow 0.2s ease;
}

.account-avatar:hover:not(:disabled) {
  box-shadow: 0 0 0 4px #f4c43026;
}

.account-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.account-avatar-lg {
  width: 46px;
  height: 46px;
  font-size: 19px;
  cursor: default;
}

.account-avatar-lg:hover {
  box-shadow: none;
}

.account-panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.account-panel-hi {
  font-family: var(--body);
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}

.account-email {
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
}

.account-panel-link {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 10px;
}

.account-panel-link:hover {
  color: var(--accent);
}

.account-panel-logout {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 8px;
}

.account-panel-logout:hover:not(:disabled) {
  border-color: var(--coral);
  color: var(--coral);
  background: transparent;
}

/* ---------- Мобильная адаптация ---------- */

@media (max-width: 640px) {
  main {
    padding: 14px 10px 30px;
  }

  .calendar-body {
    grid-auto-rows: minmax(70px, 1fr);
  }

  .day-cell {
    padding: 4px;
  }

  .event-chip {
    font-size: 10.5px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .calendar-title {
    font-size: 16px;
  }
}
