:root {
  --bg: #fafafa;
  --card: #ffffff;
  --border: #dbdbdb;
  --text: #262626;
  --muted: #8e8e8e;
  --accent: #0095f6;
  --like: #ed4956;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
.header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header__inner {
  max-width: 614px;
  margin: 0 auto;
  padding: 0 16px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header__title {
  font-size: 22px;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1;
}

.header__nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header__icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 6px;
  border-radius: 6px;
  transition: opacity 0.15s;
}
.header__icon-btn:hover { opacity: 0.5; }

/* Clique filter in header */
.clique-filter {
  font-size: 13px;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  outline: none;
  max-width: 140px;
}
.clique-filter:focus { border-color: var(--text); }

.avatar-small {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.avatar-trigger {
  position: relative;
  cursor: pointer;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.avatar-trigger__overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  color: white;
}
.avatar-trigger:hover .avatar-trigger__overlay { opacity: 1; }

.admin-badge {
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

/* ── Main ── */
.main {
  max-width: 614px;
  margin: 0 auto;
  padding: 24px 0 80px;
}

/* ── Composer ── */
.composer {
  background: var(--card);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  padding: 16px;
}

.composer__top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.composer__textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: transparent;
  line-height: 1.5;
  min-height: 56px;
}
.composer__textarea::placeholder { color: var(--muted); }

.composer__preview {
  position: relative;
  margin: 12px 0 0 40px;
  overflow: hidden;
  border: 1px solid var(--border);
  max-height: 300px;
}
.composer__preview img {
  width: 100%;
  display: block;
  object-fit: cover;
  max-height: 300px;
}
.composer__remove-img {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.composer__remove-img:hover { background: rgba(0,0,0,0.85); }

.composer__bottom {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.composer__tools { display: flex; gap: 4px; }

.btn-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s;
}
.btn-tool:hover { color: var(--text); }

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

.char-count { font-size: 12px; color: var(--muted); }

.btn-publish {
  padding: 5px 16px;
  background: none;
  color: var(--accent);
  border: none;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-publish:hover:not(:disabled) { opacity: 0.6; }
.btn-publish:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Feed ── */
.feed { display: flex; flex-direction: column; gap: 24px; }

.info-message {
  background: #eff7ff;
  border: 1px solid #c8e3f8;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 24px;
}

.state-msg {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  font-size: 14px;
}

/* ── Post card ── */
.post {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 3px;
}

.post__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
}

.post__header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

/* Keep .post__meta for backwards compat but hide time from header */
.post__meta { display: flex; flex-direction: column; }
.post__time { display: none; }

.post__author {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.post__more {
  background: none;
  border: none;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  letter-spacing: 2px;
  line-height: 1;
  font-family: var(--font);
}
.post__more:hover { opacity: 0.6; }

/* ── Media ── */
.post__media { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.post__media-img {
  display: block;
  width: 100%;
  max-height: 600px;
  object-fit: cover;
}

/* ── Post body ── */
.post__body { padding: 0; }

/* ── Action bar ── */
.post__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 2px;
}

.post__actions-left {
  display: flex;
  align-items: center;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text);
  border-radius: 4px;
  transition: opacity 0.1s;
}
.action-btn:hover { opacity: 0.5; }
.action-btn.like-btn.active { color: var(--like); }

/* ── Likes ── */
.post__likes {
  padding: 0 12px 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.likes-stat { cursor: pointer; }
.likes-stat:hover { opacity: 0.7; }

/* Keep .post__stats hidden (old markup) */
.post__stats { display: none; }

/* ── Caption ── */
.post__caption {
  padding: 0 12px 6px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}
.post__caption-author {
  font-weight: 600;
  margin-right: 5px;
}

/* ── View comments ── */
.post__view-comments {
  display: block;
  padding: 0 12px 4px;
  background: none;
  border: none;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  transition: color 0.15s;
}
.post__view-comments:hover { color: var(--text); }

/* ── Timestamp ── */
.post__timestamp {
  padding: 2px 12px 12px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.2px;
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal[hidden] { display: none; }

.modal__box {
  background: var(--card);
  border-radius: 12px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08), 0 20px 60px rgba(0,0,0,0.3);
  position: relative;
}

.modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  border-radius: 50%;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  font-family: var(--font);
  transition: background 0.15s;
}
.modal__close:hover { background: var(--bg); }

.modal__body { padding: 20px 20px 24px; }

.modal__body h3 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ── Likes list ── */
.likes-list, .comments-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.like-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
}
.like-item:hover { background: var(--bg); border-radius: 4px; }
.like-item span { font-weight: 600; font-size: 14px; }

/* ── Comments ── */
.comment-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.comment-input {
  flex: 1;
  padding: 8px 0;
  border: none;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-family: var(--font);
  background: transparent;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.comment-input:focus { border-color: var(--text); }
.comment-input::placeholder { color: var(--muted); }

.comments-items { display: flex; flex-direction: column; gap: 14px; }

.comment-item { display: flex; gap: 12px; align-items: flex-start; }

.comment-content { flex: 1; font-size: 14px; line-height: 1.5; }

.comment-author {
  font-weight: 600;
  color: var(--text);
  margin-right: 5px;
}
.comment-text { color: var(--text); word-break: break-word; }
.comment-time { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }

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

/* ── Clique composer picker ── */
.clique-picker {
  font-size: 12px;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  outline: none;
  max-width: 130px;
}
.clique-picker:focus { border-color: var(--text); color: var(--text); }

/* ── Clique tag on posts ── */
.post__clique-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: #eff7ff;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 2px;
}

/* ── Settings panel ── */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
}
.settings-overlay[hidden] { display: none; }

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 100vw;
  background: var(--card);
  border-left: 1px solid var(--border);
  z-index: 201;
  overflow-y: auto;
  box-shadow: -4px 0 24px rgba(0,0,0,0.1);
}
.settings-panel[hidden] { display: none; }

.settings-panel__inner { display: flex; flex-direction: column; }

.settings-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}
.settings-panel__header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.settings-panel__close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  font-family: var(--font);
}
.settings-panel__close:hover { color: var(--text); }

.settings-section {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.settings-section__title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 14px;
}

/* Profile row */
.settings-profile {
  display: flex;
  align-items: center;
  gap: 14px;
}
.settings-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  display: block;
}
.settings-username {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.settings-email {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

/* Cliques list */
.cliques-empty {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.clique-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg);
}
.clique-item:last-child { border-bottom: none; }

.clique-item__info { display: flex; flex-direction: column; gap: 2px; }
.clique-item__name { font-size: 14px; font-weight: 600; color: var(--text); }
.clique-item__count { font-size: 12px; color: var(--muted); }

.clique-item__actions { display: flex; gap: 6px; }

.clique-btn {
  font-size: 12px;
  font-family: var(--font);
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: none;
  color: var(--text);
  transition: background 0.15s;
}
.clique-btn:hover { background: var(--bg); }
.clique-delete-btn, .clique-leave-btn { color: #ed4956; border-color: #ed4956; }
.clique-delete-btn:hover, .clique-leave-btn:hover { background: #fff0f1; }

/* New clique form */
.new-clique-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.settings-input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}
.settings-input:focus { border-color: var(--text); background: var(--card); }

.btn-settings-action {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 9px 0;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-settings-action:hover { background: #eff7ff; }

.btn-settings-primary {
  padding: 8px 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-settings-primary:hover { opacity: 0.85; }
.btn-settings-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-settings-cancel {
  padding: 8px 14px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  color: var(--muted);
}
.btn-settings-cancel:hover { background: var(--bg); }

.btn-settings-danger {
  display: block;
  width: 100%;
  padding: 10px;
  background: none;
  border: 1px solid #ed4956;
  border-radius: 8px;
  color: #ed4956;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-settings-danger:hover { background: #fff0f1; }

/* Clique modal — members list */
.clique-members-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.clique-remove-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
  font-family: var(--font);
}
.clique-remove-btn:hover { background: #fff0f1; color: #ed4956; }

.clique-add-member {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* ── Clique modal notification row ── */
.clique-notify-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 12px;
}

.clique-notify-row__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.clique-modal-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 14px;
}

/* ── Settings hint text ── */
.settings-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

/* ── Permission rows ── */
.user-permissions-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.permission-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg);
}
.permission-row:last-child { border-bottom: none; }

.permission-row__info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.permission-row__username {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.permission-row__email {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.permission-status {
  font-size: 11px;
  font-style: italic;
}

/* ── Toggle switch ── */
.toggle {
  flex-shrink: 0;
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.toggle__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle__track {
  display: block;
  width: 42px;
  height: 24px;
  background: var(--border);
  border-radius: 99px;
  transition: background 0.2s;
  position: relative;
}

.toggle__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}

.toggle__input:checked + .toggle__track {
  background: var(--accent);
}

.toggle__input:checked + .toggle__track::after {
  transform: translateX(18px);
}

.toggle__input:disabled + .toggle__track {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .main { padding: 0 0 60px; }
  .post { border-radius: 0; border-left: none; border-right: none; }
  .feed { gap: 0; }
  .post + .post { border-top: none; }
  .header__inner { padding: 0 12px; }
  .settings-panel { width: 100vw; }
  .clique-filter { max-width: 100px; }
}
