:root {
  font-family: Inter, system-ui, sans-serif;
  color: #18233c;
  background: #f5f6fa;
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 600;
  background: #635bff;
  color: white;
}
button:hover {
  filter: brightness(0.94);
}
button.secondary {
  background: #eeecff;
  color: #574cc5;
}
input,
select,
textarea {
  padding: 12px;
  border: 1px solid #dce0eb;
  border-radius: 9px;
  background: white;
  color: #26324c;
  max-width: 100%;
}
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid #bdb8ff;
}
label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
}
textarea {
  min-height: 130px;
  resize: vertical;
}
.brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -1px;
}
.brand span {
  color: #7f74ff;
}
.layout {
  display: grid;
  grid-template-columns: 245px 1fr;
  min-height: 100vh;
}
aside {
  background: #fff;
  border-right: 1px solid #e7e9f1;
  padding: 32px 22px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}
aside small {
  color: #9198ad;
  font-size: 10px;
  letter-spacing: 2px;
}
nav {
  display: grid;
  gap: 10px;
}
nav button {
  text-align: left;
  background: transparent;
  color: #727d93;
}
nav button.active {
  color: #6255db;
  background: #f0edff;
}
.profile {
  margin-top: auto;
  border-top: 1px solid #eee;
  padding-top: 22px;
  display: grid;
  gap: 8px;
}
.avatar {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: #e9e6ff;
  border-radius: 12px;
  color: #695bca;
  font-weight: 700;
}
main {
  padding: 30px 44px;
  max-width: 1500px;
  width: 100%;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 30px;
}
.muted {
  color: #7b859c;
  font-size: 13px;
}
.hero {
  background: linear-gradient(115deg, #312e76, #685af1);
  border-radius: 22px;
  padding: 34px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.hero:after {
  content: "✳";
  font-size: 200px;
  position: absolute;
  right: 30px;
  top: -20px;
  color: #ffffff15;
}
.hero h1 {
  font-size: 31px;
  margin: 10px 0;
  letter-spacing: -1px;
}
.hero p {
  color: #d8d4ff;
  max-width: 600px;
  line-height: 1.6;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 2px;
  font-weight: 700;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 22px 0;
}
.stat {
  background: white;
  border: 1px solid #e8eaf3;
  border-radius: 14px;
  padding: 21px;
}
.stat strong {
  font-size: 27px;
  display: block;
  margin-top: 8px;
}
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 28px 0 16px;
}
.section-title h2 {
  font-size: 20px;
  margin: 0;
}
.topics {
  display: flex;
  gap: 10px;
  overflow: auto;
  padding-bottom: 10px;
}
.topic {
  white-space: nowrap;
  background: #fff;
  color: #68728a;
  border: 1px solid #e2e5ef;
}
.topic.selected {
  background: #6258e8;
  color: #fff;
  border-color: #6258e8;
}
.filters {
  display: flex;
  gap: 10px;
  margin: 20px 0;
  flex-wrap: wrap;
}
.filters input[type="search"] {
  flex: 1;
  min-width: 200px;
}
.filters label {
  font-size: 11px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.card {
  background: white;
  border: 1px solid #e5e8f1;
  border-radius: 16px;
  padding: 25px;
  box-shadow: 0 4px 12px #27364f03;
}
.card h3 {
  margin: 16px 0 12px;
  font-size: 19px;
  letter-spacing: -0.4px;
}
.card p {
  font-size: 14px;
  color: #717c92;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.badge {
  display: inline-block;
  background: #eeebff;
  color: #6557c8;
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 7px;
}
.date {
  font-size: 12px;
  color: #8d97aa;
}
.card-foot {
  border-top: 1px solid #f0f1f6;
  margin-top: 20px;
  padding-top: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #7c8599;
}
.deadline {
  background: #fff6e6;
  color: #b17c23;
  font-size: 12px;
  padding: 10px;
  border-radius: 8px;
  margin: 10px 0;
}
.empty {
  padding: 45px;
  text-align: center;
  border: 1px dashed #d9dceb;
  border-radius: 15px;
  color: #7e89a1;
  grid-column: 1/-1;
}
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.auth-story {
  background: linear-gradient(150deg, #26255d, #6d5af3);
  color: white;
  padding: 70px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-story h1 {
  font-size: 52px;
  letter-spacing: -2px;
  line-height: 1.08;
}
.auth-story p {
  line-height: 1.8;
  color: #d7d2ff;
}
.auth-form {
  padding: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.auth-form form {
  width: 100%;
  max-width: 400px;
  display: grid;
  gap: 18px;
}
.auth-form h2 {
  margin: 0;
  font-size: 27px;
}
dialog {
  border: 0;
  border-radius: 20px;
  width: min(640px, 95vw);
  padding: 28px;
  box-shadow: 0 20px 100px #1a154250;
}
dialog::backdrop {
  background: #15162b77;
}
dialog form {
  display: grid;
  gap: 16px;
}
.row {
  display: flex;
  gap: 12px;
  align-items: center;
}
.row > * {
  flex: 1;
}
.close {
  float: right;
  background: #f0f0f5;
  color: #626b80;
  padding: 6px 12px;
}
.comment {
  background: #f6f7fb;
  padding: 14px;
  border-radius: 10px;
  margin: 12px 0;
  font-size: 14px;
}
.comment p {
  white-space: pre-wrap;
}
.user {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 18px;
  background: white;
  border-radius: 12px;
  margin: 12px 0;
}
.user .identity {
  flex: 1;
  min-width: 180px;
}
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #252441;
  color: white;
  padding: 15px 22px;
  border-radius: 12px;
  display: none;
  z-index: 5;
  max-width: 90vw;
}
.error {
  color: #bc375b;
  font-size: 13px;
}
.notifications .card {
  margin-bottom: 12px;
}
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
  aside {
    padding: 18px;
    gap: 12px;
  }
  nav {
    display: flex;
    flex-wrap: wrap;
  }
  .profile {
    display: none;
  }
  main {
    padding: 20px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .auth {
    grid-template-columns: 1fr;
  }
  .auth-story {
    padding: 35px;
  }
  .auth-story h1 {
    font-size: 36px;
  }
  .auth-form {
    padding: 30px;
  }
  .hero h1 {
    font-size: 25px;
  }
  .stats {
    gap: 8px;
  }
  .stat {
    padding: 13px;
  }
}

/* Fluid layout: grid children must be able to shrink below their content width. */
html,
body {
  width: 100%;
  min-width: 0;
}
.layout {
  grid-template-columns: 245px minmax(0, 1fr);
  min-height: calc(100dvh - 50px);
}
main,
aside,
#content,
.auth-story,
.auth-form,
.card,
.stat,
.row > * {
  min-width: 0;
}
h1,
h2,
h3,
p,
.identity,
.badge,
.brand,
.date {
  overflow-wrap: anywhere;
}
main {
  max-width: none;
}
.grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
}
.auth {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: calc(100dvh - 50px);
}
.row {
  flex-wrap: wrap;
}
.row > * {
  flex: 1 1 160px;
}
.card-foot,
.top,
.section-title {
  gap: 12px;
  flex-wrap: wrap;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.actions button {
  padding: 9px 12px;
}
.danger {
  background: #fff0f2;
  color: #b73550;
  border: 1px solid #f4ccd4;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.credit {
  text-align: center;
  font-size: 12px;
  color: #727c94;
  padding: 18px 12px;
  background: #fff;
  border-top: 1px solid #e7e9f1;
  line-height: 1.5;
}
dialog {
  max-height: 90dvh;
  overflow: auto;
}
dialog .credit {
  margin-top: 24px;
}
.history {
  font-size: 12px;
  color: #72698e;
  padding: 10px;
  background: #f7f5ff;
  border-radius: 8px;
  margin-bottom: 12px;
}
.history summary {
  cursor: pointer;
}
.history div {
  padding-top: 8px;
}
.profile-form {
  display: grid;
  gap: 16px;
  max-width: 700px;
  margin: 20px 0;
}
.avatar {
  object-fit: cover;
}
.photo-preview .avatar {
  width: 90px;
  height: 90px;
  font-size: 30px;
}
.topic-editor {
  border: 1px solid #e2e5ef;
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 14px;
}
fieldset {
  border: 1px solid #e0e2ec;
  border-radius: 12px;
  min-width: 0;
  padding: 15px;
}
legend {
  font-size: 14px;
  font-weight: 600;
}
.reminder-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 15px;
}
.reminder-row label {
  flex: 1 1 100px;
}
.reminder-row input,
.reminder-row select {
  width: 100%;
}
.filters label {
  flex: 1 1 180px;
}
.filters input[type="search"] {
  min-width: 0;
  flex: 2 1 240px;
}
.user select {
  min-width: 0;
}
.topics {
  max-width: 100%;
}
.topic {
  flex-shrink: 0;
}
.profile {
  display: grid;
}
@media (min-width: 1600px) {
  main {
    padding: 40px 5vw;
  }
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  }
}
@media (max-width: 1000px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  aside {
    padding: 18px;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid #e7e9f1;
  }
  nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  nav button {
    flex: 1 1 150px;
  }
  .profile {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin: 0;
    padding-top: 12px;
    gap: 12px;
  }
  .profile strong {
    flex: 1;
  }
  main {
    padding: 24px;
  }
  .auth {
    grid-template-columns: minmax(0, 1fr);
  }
  .auth-story {
    padding: 35px;
  }
  .auth-story h1 {
    font-size: 36px;
  }
  .auth-form {
    padding: 30px;
  }
  .auth-story .eyebrow {
    margin-top: 30px !important;
  }
}
@media (max-width: 520px) {
  main {
    padding: 16px;
  }
  .hero {
    padding: 24px;
  }
  .hero h1 {
    font-size: 24px;
  }
  .hero:after {
    right: -60px;
  }
  .stats {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
  }
  .stat strong {
    margin: 0;
    font-size: 23px;
  }
  .card {
    padding: 18px;
  }
  .section-title {
    align-items: flex-start;
  }
  .section-title > .actions {
    width: 100%;
  }
  .filters > * {
    width: 100%;
  }
  .auth-story {
    padding: 26px;
  }
  .auth-story h1 {
    font-size: 32px;
  }
  .auth-form {
    padding: 24px;
  }
  .row {
    align-items: stretch;
  }
  .row > * {
    flex-basis: 100%;
  }
  .card-foot > .actions {
    width: 100%;
  }
  .user > * {
    width: 100%;
  }
  .user .identity {
    min-width: 0;
  }
  .profile strong {
    flex-basis: calc(100% - 55px);
  }
  dialog {
    padding: 20px;
    width: calc(100vw - 20px);
  }
  .reminder-row label {
    flex-basis: calc(50% - 10px);
  }
  .reminder-row button {
    width: 100%;
  }
  input,
  select,
  textarea {
    font-size: 16px;
  }
  .photo-preview .avatar {
    width: 75px;
    height: 75px;
  }
  .top > span {
    width: 100%;
  }
}

form,
label,
fieldset {
  min-width: 0;
}
.profile-form,
dialog form {
  grid-template-columns: minmax(0, 1fr);
}
label > input,
label > select,
label > textarea {
  width: 100%;
  min-width: 0;
}
input[type="checkbox"] {
  width: auto;
}

/* All subjects remain visible; the sidebar follows the viewport, not the feed. */
.topics {
  flex-wrap: wrap;
  overflow: visible;
  gap: 10px;
}
.topic {
  white-space: normal;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: left;
}
@media (min-width: 1001px) {
  .layout {
    align-items: start;
  }
  aside {
    position: sticky;
    top: 0;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    padding: clamp(12px, 2vh, 26px) 20px;
    gap: clamp(8px, 2vh, 22px);
  }
  aside > .brand,
  aside > small,
  aside > .profile {
    flex-shrink: 0;
  }
  aside nav {
    min-height: 0;
    overflow-y: auto;
    flex: 1;
    align-content: start;
  }
  aside .profile {
    margin-top: 0;
    padding-top: 12px;
    gap: 6px;
  }
}
@media (max-width: 1000px) {
  aside {
    position: static;
    height: auto;
    max-height: none;
    overflow: visible;
  }
  aside nav {
    overflow: visible;
  }
}
.backup-form {
  display: grid;
  gap: 16px;
  margin: 20px 0;
  max-width: 760px;
}
.backup-selection {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.backup-selection label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.backup-selection input {
  width: auto;
}
.warning {
  padding: 14px;
  border-radius: 10px;
  background: #fff6e6;
  color: #8c641b;
  font-size: 13px;
  line-height: 1.7;
}
.backup-counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.backup-counts > div {
  display: grid;
  gap: 6px;
  background: #f5f4ff;
  padding: 14px;
  border-radius: 10px;
  font-size: 12px;
}
.backup-counts strong {
  font-size: 23px;
}
.backup-form h2 {
  margin: 0;
}
.backup-form > form {
  margin: 0;
}
[hidden] {
  display: none !important;
}
.profile strong {
  min-width: 0;
  overflow-wrap: anywhere;
}
@media (min-width: 1001px) {
  aside .profile {
    grid-template-columns: 38px minmax(0, 1fr);
    column-gap: 10px;
  }
  aside .profile > .avatar {
    grid-row: 1 / span 2;
    align-self: center;
  }
  aside .profile > button {
    grid-column: 1 / -1;
  }
}
.text-button {
  background: transparent;
  color: #6255db;
  text-decoration: underline;
}
.audience-fields {
  margin: 12px 0;
}
.audience-fields input:disabled {
  opacity: 0.35;
}
.recovery-card {
  margin: 14px 0;
}
.recovery-card .badge {
  margin-bottom: 8px;
}
.audience-fields .backup-selection {
  gap: 12px;
}
