:root {
  --green: #07c160;
  --green-dark: #06ad56;
  --bg: #f5f6f7;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #888;
  --danger: #e54d42;
  --border: #e5e5e5;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 14px 40px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
}

.topbar {
  padding: 8px 4px 16px;
}
.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.topbar-row h1 { flex: 1; }
.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}
.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.card h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.card-head h2 { margin-bottom: 0; }
.small-hint { font-size: 0.75rem; font-weight: 400; }

.label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
  margin-top: 8px;
}
.label:first-child { margin-top: 0; }

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.row input[type="date"] { flex: 1; margin-bottom: 0; }

input[type="date"],
input[type="datetime-local"],
input[type="text"],
input[type="password"],
input[type="file"],
textarea {
  width: 100%;
  font-size: 16px; /* avoid iOS zoom */
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  margin-bottom: 10px;
}
textarea {
  resize: vertical;
  min-height: 160px;
  line-height: 1.55;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 600;
  background: #f0f0f0;
  color: var(--text);
  cursor: pointer;
  min-height: 48px;
}
.btn:active { opacity: 0.85; }
.btn.primary {
  background: var(--green);
  color: #fff;
}
.btn.primary:active { background: var(--green-dark); }
.btn.ghost {
  background: transparent;
  color: var(--green);
  padding-left: 8px;
  padding-right: 8px;
}
.btn.danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid #f0c0bc;
  margin-top: 8px;
}
.btn.danger.tiny {
  margin-top: 0;
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.btn.block { width: 100%; display: block; margin-top: 8px; }
.btn.small {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.date-badge {
  display: inline-block;
  background: #e8f8ef;
  color: var(--green-dark);
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.95rem;
}

.copy-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
  margin: 12px 0;
  padding: 0;
  background: transparent;
}

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.post-list li {
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  gap: 0;
  background: #fff;
  transition: box-shadow 0.15s, opacity 0.15s, transform 0.15s;
  touch-action: pan-y;
}
.post-list li:first-child { border-top: none; }
.post-list li.dragging {
  opacity: 0.92;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  z-index: 2;
  position: relative;
}
.post-list li.drag-over {
  border-top: 2px solid var(--green);
}
.post-list .drag-handle {
  flex: 0 0 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 1.1rem;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  padding: 0 4px;
}
.post-list .drag-handle:active { cursor: grabbing; color: var(--green); }
.post-list .post-main {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: transparent;
  border: none;
  padding: 14px 4px;
  font-size: 1rem;
  min-height: 56px;
  cursor: pointer;
}
.post-list .post-actions {
  display: flex;
  align-items: center;
  padding: 8px 4px 8px 0;
}
.post-list .date { font-weight: 700; color: var(--green-dark); }
.post-list .meta { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.post-list .preview {
  color: #444;
  font-size: 0.9rem;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.post-list .list-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
}
.post-list .list-thumb {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f3f3f3;
}
.post-list .list-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  vertical-align: top;
}
.post-list .list-thumb-more {
  flex: 0 0 auto;
  min-width: 48px;
  height: 48px;
  border-radius: 6px;
  border: 1px dashed var(--green);
  color: var(--green-dark);
  background: #f0faf4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.image-item {
  position: relative;
  background: #fafafa;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.image-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #eee;
}
.image-item .actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
}
.image-item .actions a,
.image-item .actions button {
  text-align: center;
  font-size: 0.8rem;
  padding: 8px 4px;
  min-height: 36px;
  border-radius: 6px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
.image-item .dl {
  background: var(--green);
  color: #fff;
}
.image-item .rm {
  background: #fff0ee;
  color: var(--danger);
}
.image-item.pending-badge::after {
  content: "新";
  position: absolute;
  top: 4px;
  left: 4px;
  background: var(--green);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); font-size: 0.9rem; min-height: 1.2em; }
.toast {
  text-align: center;
  color: var(--green-dark);
  font-weight: 600;
  margin-top: 8px;
}
