:root {
  --teams: #6264a7;
  --teams-dark: #464775;
  --ink: #242424;
  --muted: #616161;
  --line: #dedee6;
  --panel: #ffffff;
  --surface: #f4f5f8;
  --blue: #0f6cbd;
  --green: #13a10e;
  --amber: #f2b544;
  --rose: #c4314b;
  --teal: #038387;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 64px 286px minmax(0, 1fr) 330px;
  min-height: 100vh;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(120deg, rgb(98 100 167 / 12%), rgb(15 108 189 / 10%)),
    var(--surface);
  padding: 24px;
}

.auth-card {
  width: min(430px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 52px rgb(0 0 0 / 12%);
  padding: 24px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 28px;
}

.auth-brand p,
.form-message {
  margin: 4px 0 0;
  color: var(--muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 22px;
  border-bottom: 1px solid var(--line);
}

.auth-tabs button {
  border: 0;
  background: white;
  min-height: 42px;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 3px solid transparent;
}

.auth-tabs button.selected {
  color: var(--teams-dark);
  border-bottom-color: var(--teams);
}

.gmail-button {
  width: 100%;
  min-height: 42px;
  margin-top: 16px;
  border: 1px solid #d1d1d1;
  border-radius: 4px;
  background: white;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
}

.gmail-button:hover {
  background: #fafafa;
  border-color: #bdbdbd;
}

.gmail-button:disabled {
  cursor: progress;
  opacity: 0.68;
}

.gmail-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #1a73e8;
  border: 1px solid #dadce0;
  font-weight: 800;
  font-size: 14px;
}

.auth-form {
  margin-top: 8px;
}

.database-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.form-message {
  min-height: 20px;
  color: var(--rose);
  font-size: 13px;
}

.rail {
  background: #f0f0f7;
  border-right: 1px solid #d6d6e6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 14px 8px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--teams);
  color: white;
  font-weight: 700;
  font-size: 22px;
}

.rail-button,
.icon-button {
  border: 0;
  background: transparent;
  color: #424242;
}

.rail-button {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 22px;
}

.rail-button.active,
.rail-button:hover {
  background: white;
  color: var(--teams-dark);
  box-shadow: inset 4px 0 0 var(--teams);
}

.sidebar,
.details-panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px;
  overflow: auto;
}

.details-panel {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.new-button,
.ghost-button {
  min-height: 34px;
  border-radius: 4px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 600;
}

.new-button {
  width: 100%;
  background: var(--teams);
  color: white;
}

.new-button:hover {
  background: var(--teams-dark);
}

.ghost-button {
  background: white;
  color: var(--teams-dark);
  border-color: var(--line);
}

.ghost-button.compact {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.mini-card,
.sidebar-section {
  margin-top: 18px;
}

.mini-header,
.topbar,
.calendar-header,
.drawer-header,
.drawer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 22px;
}

.icon-button:hover {
  background: #f0f0f7;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 8px;
}

.mini-grid span,
.mini-grid button {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--ink);
  min-width: 0;
}

.mini-grid.weekdays span {
  aspect-ratio: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mini-grid button.selected {
  background: var(--teams);
  color: white;
}

.mini-grid button.has-item {
  box-shadow: inset 0 -3px 0 var(--green);
}

.sidebar-section h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.sidebar-section label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 9px 0;
  color: var(--muted);
}

.notification-list {
  display: grid;
  gap: 8px;
}

.notification {
  border: 1px solid var(--line);
  border-left: 4px solid var(--teams);
  border-radius: 6px;
  padding: 9px;
  background: #fbfbfd;
  font-size: 13px;
}

.notification strong {
  display: block;
  color: var(--ink);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 12px 22px;
  min-height: 68px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.topbar p,
.drawer-header p,
.empty-state p {
  margin: 3px 0 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.segmented {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  background: white;
}

.segmented button {
  border: 0;
  background: white;
  padding: 8px 12px;
  color: var(--muted);
}

.segmented button.selected {
  background: #ececf7;
  color: var(--teams-dark);
  font-weight: 700;
}

.segmented button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.calendar-surface {
  flex: 1;
  margin: 14px 18px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  min-height: 680px;
}

.section-view {
  flex: 1;
  margin: 14px 18px 18px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: auto;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.section-header h2,
.section-card h3,
.section-subtitle {
  margin: 0;
}

.section-header p,
.section-card p {
  margin: 4px 0 0;
  color: var(--muted);
}

.section-action {
  width: auto;
  flex: 0 0 auto;
}

.section-list,
.friend-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.friend-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.section-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfbfd;
  padding: 14px;
}

.section-card h3 {
  margin-top: 8px;
  font-size: 16px;
}

.section-empty {
  margin-top: 14px;
}

.section-subtitle {
  margin-top: 22px;
  font-size: 18px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--teams);
  color: white;
  font-weight: 800;
}

.calendar-header {
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 0;
  justify-content: stretch;
}

.time-zone {
  width: 72px;
  padding-left: 16px;
  color: var(--muted);
  font-size: 13px;
}

.day-heading {
  border: 0;
  border-left: 1px solid #ececf2;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--teams-dark);
  min-width: 0;
}

.day-heading strong {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--ink);
}

.day-heading.active strong {
  background: var(--teams);
  color: white;
}

.schedule {
  position: relative;
  overflow-x: auto;
}

.time-row {
  display: grid;
  min-height: 64px;
  min-width: 0;
}

.time-label {
  padding: 6px 12px 0 0;
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  border-right: 1px solid var(--line);
}

.time-slot {
  position: relative;
  border-bottom: 1px solid #ececf2;
  border-left: 1px solid #f0f0f5;
  min-width: 0;
}

.calendar-item {
  position: absolute;
  left: 6px;
  right: 6px;
  min-height: 44px;
  border-radius: 4px;
  border: 0;
  border-left: 5px solid var(--blue);
  padding: 8px 10px;
  background: #eaf4ff;
  color: #052f5f;
  box-shadow: none;
  overflow: hidden;
  text-align: left;
}

.calendar-item.meeting {
  border-left-color: var(--teams);
  background: #efeffa;
  color: var(--teams-dark);
}

.calendar-item.task {
  border-left-color: var(--green);
  background: #edf7ed;
  color: #0b4f0b;
}

.calendar-item.overdue {
  border-left-color: var(--rose);
  background: #fff0f3;
  color: #7a1026;
}

.calendar-item strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.calendar-item span {
  font-size: 11px;
}

.empty-state,
.detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfbfd;
}

.detail-card h2 {
  margin: 0 0 8px;
}

.detail-row {
  margin: 12px 0;
}

.detail-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: #ececf7;
  color: var(--teams-dark);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.suggestion-list {
  margin: 8px 0 0;
  padding-left: 18px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 22%);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(460px, 100vw);
  height: 100vh;
  background: white;
  box-shadow: -14px 0 38px rgb(0 0 0 / 18%);
  padding: 20px;
  overflow: auto;
  z-index: 2;
}

.drawer h2 {
  margin: 0;
}

.field {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.field span {
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid #c9c9d6;
  border-radius: 6px;
  padding: 10px 11px;
  background: white;
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid #c6c7eb;
  border-color: var(--teams);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.smart-preview {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfbfd;
}

.smart-preview p {
  margin: 8px 0 0;
  color: var(--muted);
}

.drawer-actions {
  margin-top: 18px;
}

.drawer-actions .new-button {
  width: auto;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 58px 254px minmax(0, 1fr);
  }

  .details-panel {
    display: none;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: fixed;
    z-index: 3;
    bottom: 0;
    left: 0;
    right: 0;
    height: 58px;
    flex-direction: row;
    justify-content: space-around;
    border-top: 1px solid #d7d7e8;
    border-right: 0;
    padding: 6px;
  }

  .brand-mark {
    display: none;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .calendar-surface {
    margin: 12px;
    min-height: 620px;
  }

  .time-row {
    grid-template-columns: 54px 1fr;
  }

  .time-zone {
    width: 54px;
    padding-left: 8px;
  }

  .calendar-item {
    left: 8px;
    right: 8px;
  }

  .main {
    padding-bottom: 64px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }
}
