:root {
  --bg: #faf8f5;
  --bg-card: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #8a8a8a;
  --text-tertiary: #b0b0b0;
  --accent: #e85d4a;
  --accent-soft: #fff0ee;
  --border: #f0ece8;
  --chat-alter: #f5f0eb;
  --chat-user: #e85d4a;
  --radius: 16px;
  --radius-sm: 10px;
  --nav-height: 72px;
  --header-height: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
}

/* Header */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(250, 248, 245, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
}

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

.logo {
  font-family: 'Noto Serif SC', serif;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 1px;
}

.header-location {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.location-dot {
  color: var(--accent);
  font-size: 8px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Main content */
main {
  padding-top: calc(var(--header-height) + var(--safe-top));
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
}

.view { display: none; }
.view.active { display: block; }

/* Timeline */
.feed { padding: 8px 0; }

.post-card {
  background: var(--bg-card);
  margin: 8px 12px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.post-images {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: #f0ece8;
}

.post-images img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.post-images-multi {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  height: 100%;
}

.post-images-multi img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-body { padding: 14px 16px; }

.post-location {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.post-text {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 10px;
  white-space: pre-wrap;
}

.post-time {
  font-size: 12px;
  color: var(--text-tertiary);
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}

.post-action {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 0;
  transition: color 0.2s;
}

.post-action:active { color: var(--accent); }
.post-action.liked { color: var(--accent); }
.post-action.liked svg { fill: var(--accent); }

/* Placeholder image */
.placeholder-img {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f0eb, #e8e0d8);
  color: var(--text-tertiary);
  font-size: 48px;
}

/* Chat */
.chat-container {
  padding: 16px 12px;
  padding-bottom: 80px;
  min-height: calc(100dvh - var(--header-height) - var(--nav-height) - var(--safe-top) - var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-bubble.alter {
  align-self: flex-start;
  background: var(--chat-alter);
  border-bottom-left-radius: 4px;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--chat-user);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-time {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 8px 0;
}

.chat-input-area {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom));
  left: 0;
  right: 0;
  background: rgba(250, 248, 245, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 50;
}

.chat-input-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
}

#chat-input {
  flex: 1;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0 16px;
  font-size: 15px;
  background: var(--bg-card);
  outline: none;
  transition: border-color 0.2s;
}

#chat-input:focus { border-color: var(--accent); }

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
  flex-shrink: 0;
}

.send-btn:active { transform: scale(0.92); }

/* Typing indicator */
.typing-indicator {
  align-self: flex-start;
  padding: 12px 18px;
  background: var(--chat-alter);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 4px;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Admin */
.admin-panel { padding: 16px; }

.admin-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.admin-section h2 {
  font-size: 16px;
  margin-bottom: 14px;
}

.code-block {
  background: #f8f6f3;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.editor {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  margin-bottom: 10px;
}

.editor:focus { border-color: var(--accent); }

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.btn {
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-accent {
  background: linear-gradient(135deg, #e85d4a, #d94a38);
  color: white;
}

.btn:active { transform: scale(0.96); }

.script-item {
  padding: 12px;
  background: #f8f6f3;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  position: relative;
}

.script-item h3 { font-size: 14px; margin-bottom: 4px; }
.script-item p { font-size: 13px; color: var(--text-secondary); white-space: pre-wrap; }
.script-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 16px;
}

/* Bottom Nav */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(250, 248, 245, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}

#bottom-nav {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  height: var(--nav-height);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active { color: var(--accent); }
.nav-item.active svg { stroke: var(--accent); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-sub { font-size: 13px; color: var(--text-tertiary); margin-top: 4px; }

/* Loading */
.loading-indicator {
  display: flex;
  justify-content: center;
  padding: 20px;
}

.dot-pulse {
  display: flex;
  gap: 6px;
}

.dot-pulse::before, .dot-pulse::after, .dot-pulse {
  content: '';
  display: inline-block;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-content {
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  max-width: 480px;
  width: 100%;
  max-height: 85dvh;
  overflow-y: auto;
  padding: 20px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
}

/* Comment section in modal */
.comment-section { margin-top: 16px; }

.comment-item {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  font-size: 14px;
}

.comment-author {
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

.comment-input-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.comment-input-row input {
  flex: 1;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0 14px;
  font-size: 14px;
  outline: none;
}

.comment-input-row button {
  padding: 0 16px;
  border-radius: 18px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 13px;
  cursor: pointer;
}

/* Scrollbar */
::-webkit-scrollbar { width: 0; }
