@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;1,400;1,600&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg:            #fdf6f0;
  --surface:       #fffcf9;
  --surface-white: #ffffff;
  --nav-bg:        #f5ede4;
  --border:        #e8d5c4;

  --text-primary:   #3a2820;
  --text-secondary: #7a5a50;
  --text-muted:     #b09080;

  --shadow-sm: 0 1px 4px rgba(80, 40, 20, 0.07);
  --shadow:    0 4px 18px rgba(80, 40, 20, 0.10);
  --shadow-lg: 0 8px 36px rgba(80, 40, 20, 0.13);

  --radius:    14px;
  --radius-sm: 8px;
  --pill:      100px;

  --max-w: 540px;
  --transition: 0.2s ease;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Lora', Georgia, serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.65;
  min-height: 100vh;
}

img { display: block; max-width: 100%; }
.hidden { display: none !important; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity var(--transition), transform var(--transition);
}
.btn:hover  { opacity: 0.82; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--text-primary); color: var(--bg); }
.btn-ghost   { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: rgba(0,0,0,0.05); opacity: 1; }
.btn-full { width: 100%; padding-top: 12px; padding-bottom: 12px; font-size: 15px; }

/* ── Form fields ───────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 7px; }

.field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="date"],
textarea {
  font-family: inherit;
  font-size: 16px;
  color: var(--text-primary);
  background: var(--surface-white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  outline: none;
  width: 100%;
  -webkit-appearance: none;
  transition: border-color var(--transition);
}
input:focus, textarea:focus { border-color: var(--text-secondary); }
textarea { resize: vertical; min-height: 110px; }

.error-msg {
  background: #fde8e8;
  color: #8b2020;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
}

/* ── Login page ────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--surface-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 44px 40px;
  width: 100%;
  max-width: 380px;
}

.login-header {
  text-align: center;
  margin-bottom: 36px;
}

.login-heart {
  font-size: 30px;
  margin-bottom: 14px;
  line-height: 1;
  /* soft pulse */
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.08); }
}

.login-title {
  font-size: 30px;
  font-weight: 600;
  font-style: italic;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
}

.login-form { display: flex; flex-direction: column; gap: 18px; }

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

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.app-title {
  font-size: 20px;
  font-weight: 600;
  font-style: italic;
  color: var(--text-primary);
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.greeting {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Feed layout ───────────────────────────────────────── */
.feed-page main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 28px 16px 80px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.state-msg {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
  font-style: italic;
  font-size: 16px;
  line-height: 2;
}

.loading::after {
  content: '';
  display: block;
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--text-muted);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 16px auto 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Post card ─────────────────────────────────────────── */
.post-card {
  background: var(--surface-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.post-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.post-photo-wrap {
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: #efe8e0;
}
.post-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}
.post-card:hover .post-photo { transform: scale(1.025); }

.post-body { padding: 18px 20px 22px; }

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.user-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 11px;
  border-radius: var(--pill);
  text-transform: uppercase;
}

.post-date {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  margin-left: auto;
}

.delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  transition: color var(--transition);
  flex-shrink: 0;
}
.delete-btn:hover { color: #b83030; }

.post-title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.post-message {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.75;
}

/* ── Add post page ─────────────────────────────────────── */
.add-post-page main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 28px 16px 80px;
}

.add-post-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.upload-area {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--transition), background var(--transition);
  min-height: 180px;
}
.upload-area:hover {
  border-color: var(--text-secondary);
  background: var(--surface-white);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 52px 24px;
  gap: 6px;
  pointer-events: none;
}
.upload-icon   { font-size: 38px; line-height: 1; margin-bottom: 6px; }
.upload-label  { font-size: 15px; color: var(--text-secondary); font-weight: 500; }
.upload-hint   { font-size: 13px; color: var(--text-muted); }

#photo-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

#photo-preview {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  background: #f0e8e0;
}

.has-preview .upload-placeholder { display: none; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 480px) {
  .login-card { padding: 36px 24px; }
  .app-title  { font-size: 18px; }
  .greeting   { display: none; }
}
