/* Цвета и размеры в одном месте, чтобы тему было легко поменять */
:root {
  color-scheme: dark;
  --bg: #16120f;
  --surface: #211b16;
  --surface-raised: #2c241d;
  --line: #3d3128;
  --text: #f3e9dc;
  --muted: #b8a897;
  --accent: #e9a95b;
  --accent-ink: #2a1a08;
  --danger: #f08e7e;
  --person-1: #e9a95b;
  --person-2: #e893a6;
  --radius: 14px;
  --font-body: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --font-title: Georgia, 'Times New Roman', serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-title);
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

a {
  color: var(--accent);
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Кнопки и поля ---------- */

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-raised);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background-color 0.15s;
}

.button:hover {
  border-color: var(--muted);
}

.button:disabled {
  opacity: 0.6;
  cursor: default;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.button.primary:hover {
  background: #f3bb76;
}

.button.danger {
  color: var(--danger);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  color: var(--muted);
  font-size: 14px;
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

textarea.input {
  min-height: 96px;
  resize: vertical;
}

.form {
  display: grid;
  gap: 14px;
}

.form-error {
  color: var(--danger);
  font-size: 14px;
}

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

/* ---------- Экран входа ---------- */

.auth {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px 16px;
}

.auth-box {
  display: grid;
  gap: 18px;
  width: 100%;
  max-width: 400px;
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.auth-title {
  font-size: 32px;
}

.auth-note {
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Шапка и вкладки ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 16px;
}

.brand {
  flex: none;
  font-family: var(--font-title);
  font-size: 22px;
  color: var(--text);
  text-decoration: none;
}

.tabs {
  display: flex;
  flex: 1;
  gap: 4px;
}

.tab {
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

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

.tab[aria-current='page'] {
  background: var(--surface-raised);
  color: var(--text);
  font-weight: 600;
}

.profile-link {
  flex: none;
  border-radius: 50%;
  text-decoration: none;
}

/* ---------- Аватарки: у каждого человека свой цвет ---------- */

.avatar {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--person-color);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar.medium {
  width: 38px;
  height: 38px;
  font-size: 16px;
}

.avatar.large {
  width: 88px;
  height: 88px;
  font-size: 36px;
}

.person-1 {
  --person-color: var(--person-1);
}

.person-2 {
  --person-color: var(--person-2);
}

/* ---------- Содержимое вкладки ---------- */

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 16px calc(48px + env(safe-area-inset-bottom));
}

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

.page-title {
  font-size: 30px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.pill {
  min-height: 36px;
  padding: 5px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.pill[aria-pressed='true'] {
  background: var(--surface-raised);
  border-color: var(--muted);
  color: var(--text);
}

.search {
  flex: 1 1 200px;
  min-height: 36px;
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.card:hover {
  border-color: var(--muted);
  transform: translateY(-2px);
}

.card-image {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  background: var(--surface-raised);
}

.card-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 3 / 2;
  background: var(--surface-raised);
  color: var(--muted);
  font-family: var(--font-title);
  font-size: 44px;
}

.card-body {
  display: grid;
  flex: 1;
  align-content: start;
  gap: 8px;
  padding: 12px 14px 14px;
}

.card-title {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.status {
  justify-self: start;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 13px;
}

.status.done {
  color: #a9d8a0;
}

.status.active {
  color: var(--accent);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  color: var(--muted);
  font-size: 13px;
}

.author {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--text);
  font-size: 14px;
}

.author-text {
  overflow-wrap: anywhere;
}

.author-date {
  color: var(--muted);
}

.empty {
  padding: 56px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.loading {
  padding: 40px 0;
  color: var(--muted);
  text-align: center;
}

/* ---------- Окно записи ---------- */

dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop {
  background: rgb(8 6 4 / 0.72);
}

.dialog-image {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
}

.dialog-body {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dialog-title {
  font-size: 24px;
}

.close-button {
  flex: none;
  width: 44px;
  height: 44px;
  margin: -8px -8px 0 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
}

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

.description {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.external-link {
  overflow-wrap: anywhere;
}

.section {
  display: grid;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.section-title {
  font-size: 17px;
}

.rating-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
}

.stars {
  display: flex;
}

.star {
  width: 36px;
  height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--line);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.star.on {
  color: var(--accent);
}

.star:disabled {
  cursor: default;
}

.stars.small {
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 1px;
}

.comment {
  display: flex;
  gap: 10px;
}

.comment-content {
  flex: 1;
  min-width: 0;
}

.comment-head {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  color: var(--muted);
  font-size: 13px;
}

.comment-name {
  color: var(--text);
  font-weight: 600;
}

.comment-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment-form {
  display: flex;
  gap: 8px;
}

.comment-form .input {
  flex: 1;
  min-width: 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.image-preview {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 10px;
}

/* ---------- Профиль ---------- */

.profile-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

.profile-info {
  flex: 1 1 220px;
  min-width: 0;
}

.profile-bio {
  margin-top: 4px;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 28px;
}

.stat {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-value {
  font-family: var(--font-title);
  font-size: 26px;
  line-height: 1.2;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.subtitle {
  margin-bottom: 14px;
  font-size: 21px;
}

/* ---------- Всплывающее сообщение ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-raised);
  transform: translateX(-50%);
}

/* ---------- Узкие экраны (телефоны) ---------- */

@media (max-width: 860px) {
  .topbar-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
  }

  /* Шесть вкладок в две строки, чтобы все были видны без прокрутки */
  .tabs {
    display: grid;
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: repeat(3, 1fr);
  }

  .tab {
    padding: 7px 4px;
    text-align: center;
    font-size: 15px;
  }

  .page {
    padding-top: 18px;
  }

  .page-title {
    font-size: 26px;
  }
}

@media (max-width: 480px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .card-body {
    padding: 10px;
  }

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

  .dialog-body {
    padding: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
