:root {
  --bg: #fbfafc;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --ink: #1f2028;
  --muted: #666b75;
  --line: #d8dbe2;
  --rose: #e85d75;
  --rose-dark: #c83f59;
  --teal: #007c73;
  --gold: #d69a00;
  --shadow: 0 18px 45px rgba(30, 32, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.hidden {
  display: none !important;
}

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

.auth-panel {
  width: min(100%, 420px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-mark,
.mini-mark,
.profile-avatar,
.avatar {
  display: grid;
  place-items: center;
  background: var(--rose);
  color: #ffffff;
  font-weight: 800;
}

.brand-mark {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  margin: 0 auto 14px;
}

.auth-panel h1,
.auth-panel p {
  text-align: center;
  margin: 0;
}

.auth-panel h1 {
  font-size: 34px;
  line-height: 1.1;
}

.auth-panel > p,
.profile-panel p {
  color: var(--muted);
}

.auth-form,
.upload-panel {
  display: grid;
  gap: 14px;
  margin-top: 26px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 13px 14px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(232, 93, 117, 0.14);
}

.primary-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--rose);
  color: #ffffff;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--rose-dark);
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--teal);
  font-weight: 800;
}

.form-message,
.status-line {
  min-height: 20px;
  margin: 0;
  color: var(--rose-dark);
  font-size: 14px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  padding: 0 max(18px, calc((100vw - 760px) / 2));
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
}

.mini-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 15px;
}

.tabbar {
  position: sticky;
  top: 62px;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 10px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.tab-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab-button.active {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.tab-icon,
.file-picker-icon,
.icon-button svg,
.icon-action svg {
  width: 22px;
  height: 22px;
}

.tab-panel {
  display: none;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 14px 12px 40px;
}

.tab-panel.active {
  display: block;
}

.feed-list {
  display: grid;
  gap: 14px;
}

.post-card,
.upload-panel,
.profile-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(30, 32, 40, 0.05);
}

.post-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 14px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.post-author {
  display: block;
}

.post-time {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.media-pill {
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
}

.post-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--surface-2);
  overflow: hidden;
}

.post-media img,
.post-media video,
.media-preview img,
.media-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.post-caption {
  margin: 0;
  padding: 13px 14px 5px;
  white-space: pre-wrap;
}

.post-caption:empty {
  display: none;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 10px;
}

.icon-button,
.icon-action {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

.icon-button:hover,
.icon-action:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.icon-action.liked {
  color: var(--rose);
}

.icon-button.accent {
  color: var(--teal);
}

.upload-panel,
.profile-panel {
  padding: 18px;
}

.upload-panel h2,
.profile-panel h2,
.dialog-head h2 {
  margin: 0;
}

.file-picker {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px dashed var(--teal);
  border-radius: 8px;
  color: var(--teal);
  background: #f2fbfa;
  font-size: 15px;
}

.file-picker input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.media-preview {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.media-preview.empty {
  display: none;
}

.profile-panel {
  min-height: 320px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
}

.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  font-size: 34px;
}

.comments-dialog {
  width: min(100% - 24px, 620px);
  max-height: min(720px, 90vh);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.comments-dialog::backdrop {
  background: rgba(31, 32, 40, 0.38);
}

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

.comments-list {
  display: grid;
  gap: 14px;
  max-height: 430px;
  overflow: auto;
  padding: 16px;
}

.comment-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
}

.comment-row p {
  margin: 3px 0 0;
  white-space: pre-wrap;
}

.comment-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
}

@media (max-width: 560px) {
  .auth-shell {
    padding: 0;
  }

  .auth-panel {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    display: grid;
    align-content: center;
  }

  .topbar {
    padding-inline: 14px;
  }

  .tabbar {
    top: 62px;
    padding-inline: 8px;
  }

  .tab-button span:last-child {
    display: none;
  }

  .tab-panel {
    padding-inline: 8px;
  }
}
