/* ============== Base ============== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: #f1e3f5;
  color: #1c1730;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

:root {
  --bg: #f1e3f5;
  --card: #ffffff;
  --ink: #14102b;
  --ink-2: #2d2548;
  --muted: #8a7da0;
  --purple: #6a1f6a;
  --purple-dark: #4f154f;
  --purple-bright: #9b2a8f;
  --accent: #b94aa6;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============== Header ============== */

.site-header {
  position: relative;
  padding: 56px 24px 24px;
  text-align: center;
}
.site-title {
  font-size: clamp(36px, 5.5vw, 64px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
  cursor: pointer;
  display: inline-block;
  white-space: nowrap;
}
.site-title:hover { color: var(--purple); }
.site-header.compact { padding: 28px 24px 12px; }
.site-header.compact .site-title { font-size: clamp(28px, 4vw, 40px); }
.site-sub {
  margin: 6px 0 0;
  font-size: 16px;
  color: var(--ink-2);
  font-weight: 500;
}

.header-actions {
  position: absolute;
  top: 24px;
  right: 24px;
  display: flex;
  gap: 10px;
}

/* ============== Buttons ============== */

.primary-btn {
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 18px -8px rgba(106, 31, 106, 0.55);
}
.primary-btn:hover { background: var(--purple-dark); transform: translateY(-1px); }
.primary-btn.small { padding: 8px 16px; font-size: 13px; }
.primary-btn .plus { font-size: 18px; line-height: 1; font-weight: 400; }

.ghost-btn {
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(106,31,106,0.18);
  color: var(--purple-dark);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s ease;
}
.ghost-btn:hover { background: #fff; }
.ghost-btn.danger { color: #b3261e; border-color: rgba(179,38,30,0.25); }
.ghost-btn.danger:hover { background: #fde9e7; }

.icon-btn {
  background: transparent;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--ink-2);
}
.icon-btn:hover { background: rgba(0,0,0,0.05); }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--purple);
  font-size: 13px;
  text-decoration: underline;
}

/* ============== Content ============== */

.content {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

.manage-bar {
  background: #fff;
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--ink-2);
  box-shadow: 0 4px 24px -10px rgba(106,31,106,0.18);
  flex-wrap: wrap;
}
.manage-actions { display: flex; gap: 8px; }

/* ============== Hero ============== */

.hero-wrap { position: relative; margin-bottom: 56px; }

.hero {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  aspect-ratio: 16/8;
  background: #d8c9dd;
}
.hero-clickable { cursor: pointer; }
.hero-media { position: absolute; inset: 0; }
.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hero-caption {
  position: absolute;
  left: 28px;
  bottom: 28px;
  right: 28px;
  background: #fff;
  border-radius: 16px;
  padding: 18px 22px 22px;
  box-shadow: 0 10px 40px -16px rgba(0,0,0,0.25);
  max-width: 720px;
}
.hero-title {
  font-size: clamp(20px, 2.6vw, 32px);
  font-weight: 800;
  line-height: 1.2;
  margin: 12px 0 0;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.hero-manage {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
}

/* ============== Badge ============== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  padding: 6px 14px;
  line-height: 1;
}
.badge-cat {
  background: var(--purple);
  color: #fff;
}
.badge-time {
  background: #fff;
  color: var(--ink-2);
  border: 1px solid rgba(20,16,43,0.08);
  font-weight: 500;
}

/* ============== Grid ============== */

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  align-items: stretch;
}
.grid-item {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.grid-item > .card {
  flex: 1;
  height: 100%;
}
@media (max-width: 980px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 22px; }
}
@media (max-width: 620px) {
  .grid { grid-template-columns: 1fr; gap: 18px; }
  .hero-caption { left: 14px; right: 14px; bottom: 14px; padding: 14px; }
}

/* ============== Card ============== */

.card {
  background: var(--card);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 4px 24px -12px rgba(74, 31, 88, 0.18);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 40px -18px rgba(74, 31, 88, 0.3);
}
.card-media {
  position: relative;
  aspect-ratio: 16/10;
  background: #e5d6ea;
  overflow: hidden;
}
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-cat {
  position: absolute;
  bottom: 12px;
  left: 12px;
}
.badge-time {
  position: absolute;
  bottom: 12px;
  right: 12px;
}

.card-body {
  padding: 22px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}
.card-title {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.3;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.005em;
  text-wrap: pretty;
}
.card-excerpt {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 0;
  text-wrap: pretty;
}
.card-date {
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: auto;
}
.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}
.read-link {
  color: var(--purple);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.read-link:hover { color: var(--purple-bright); }
.read-link .arrow { transition: transform 0.18s ease; }
.read-link:hover .arrow { transform: translateX(4px); }

.delete-btn {
  background: transparent;
  border: 1px solid rgba(179,38,30,0.25);
  color: #b3261e;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
}
.delete-btn:hover { background: #fde9e7; }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  background: #fff;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* ============== Footer ============== */

.site-footer {
  margin-top: auto;
  padding: 36px 24px 24px;
  font-size: 13px;
  color: var(--ink-2);
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 24px;
  align-items: center;
}
.copy { margin: 0; line-height: 1.5; }
.footer-nav { display: flex; gap: 28px; justify-content: center; flex-wrap: wrap; }
.footer-nav a { color: var(--ink-2); }
.footer-nav a:hover { color: var(--purple); }
.top-link {
  background: transparent;
  border: none;
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 600;
}
.top-link:hover { color: var(--purple); }
@media (max-width: 760px) {
  .footer-inner { grid-template-columns: 1fr; text-align: center; }
}

/* ============== Modal ============== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 43, 0.5);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade-in 0.2s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #fff;
  border-radius: 20px;
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: rise 0.22s ease;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.4);
}
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px 8px;
}
.modal-head h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
}
.modal-body {
  padding: 8px 22px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-foot {
  padding: 14px 22px 22px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid rgba(0,0,0,0.06);
  background: #fafafd;
  border-radius: 0 0 20px 20px;
}

/* ============== Form Fields ============== */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.field > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.field input[type="text"],
.field input[type="url"],
.field input[type="number"],
.field textarea,
.field select {
  font-family: inherit;
  font-size: 15px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1.5px solid rgba(20,16,43,0.1);
  background: #fff;
  color: var(--ink);
  transition: border 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgba(106,31,106,0.1);
}
.field textarea { resize: vertical; }

.row { display: flex; gap: 14px; }
@media (max-width: 520px) { .row { flex-direction: column; } }

.auto-toggle {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.auto-toggle input { margin: 0; }

.time-input {
  display: flex;
  align-items: center;
  gap: 10px;
}
.time-input .unit {
  font-size: 14px;
  color: var(--muted);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
}

/* Image picker */
.image-picker {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.image-preview {
  width: 160px;
  height: 110px;
  border-radius: 12px;
  overflow: hidden;
  background: #f0e9f4;
  flex-shrink: 0;
}
.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.image-empty { width: 100%; height: 100%; }
.image-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.image-controls input[type="url"] {
  font-family: inherit;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1.5px solid rgba(20,16,43,0.1);
}

@media (max-width: 520px) {
  .image-picker { flex-direction: column; align-items: stretch; }
  .image-preview { width: 100%; height: 160px; }
}

/* ============== Article page ============== */

.article-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 0 40px;
}
.article-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}
.back-link {
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(106,31,106,0.18);
  color: var(--purple-dark);
  border-radius: 999px;
  padding: 9px 18px 9px 14px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease, transform 0.15s ease;
}
.back-link:hover { background: #fff; transform: translateX(-2px); }
.arrow-back { transition: transform 0.15s ease; }
.back-link:hover .arrow-back { transform: translateX(-3px); }

.article-actions { display: flex; gap: 8px; }

.article-hero {
  width: 100%;
  aspect-ratio: 16/8;
  border-radius: 20px;
  overflow: hidden;
  background: #e5d6ea;
  margin-bottom: 28px;
  box-shadow: 0 12px 32px -16px rgba(74, 31, 88, 0.3);
}
.article-hero img,
.article-hero svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.article-time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--ink-2);
}
.article-date {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.article-title {
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 800;
  margin: 0 0 18px;
  color: var(--ink);
  letter-spacing: -0.015em;
  line-height: 1.15;
  text-wrap: balance;
}
.article-kicker {
  font-size: 17px;
  color: var(--muted);
  margin: -8px 0 22px;
  line-height: 1.4;
  text-wrap: pretty;
}
.article-kicker em { font-style: italic; }

.article-lead {
  font-size: 19px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0 0 32px;
  font-weight: 500;
  text-wrap: pretty;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(20,16,43,0.1);
}

.article-body {
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink-2);
}
.article-body h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  margin: 36px 0 14px;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.article-body h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin: 28px 0 12px;
  letter-spacing: -0.005em;
  line-height: 1.3;
}
.article-body p { margin: 0 0 18px; text-wrap: pretty; }
.article-body ul {
  margin: 0 0 22px;
  padding-left: 22px;
}
.article-body li {
  margin-bottom: 10px;
  padding-left: 4px;
}
.article-body li::marker {
  color: var(--purple);
}
.article-body strong { color: var(--ink); font-weight: 700; }
.article-body em { font-style: italic; color: var(--ink); }
.article-body blockquote {
  margin: 22px 0;
  padding: 18px 22px;
  background: rgba(106,31,106,0.06);
  border-left: 4px solid var(--purple);
  border-radius: 0 12px 12px 0;
  font-size: 17px;
  font-style: italic;
  color: var(--ink);
}

.article-body .table-wrap {
  margin: 22px 0 28px;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid rgba(20,16,43,0.1);
}
.article-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 15px;
  background: #fff;
}
.article-body thead th {
  background: #f7f1f9;
  text-align: left;
  font-weight: 700;
  color: var(--ink);
  padding: 12px 16px;
  border-bottom: 1px solid rgba(20,16,43,0.12);
  font-size: 14px;
}
.article-body tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(20,16,43,0.07);
  vertical-align: top;
  color: var(--ink-2);
  line-height: 1.5;
}
.article-body tbody tr:last-child td { border-bottom: none; }
.article-body tbody tr:nth-child(even) td { background: #fafafd; }
.article-body tbody td:first-child {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.article-empty {
  background: #fff;
  border-radius: 16px;
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.related {
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid rgba(20,16,43,0.1);
}
.related-title {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 22px;
  color: var(--ink);
}
.related-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.related-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 22px;
  padding: 16px 0;
  align-items: start;
  border-bottom: 1px solid rgba(20,16,43,0.06);
  cursor: pointer;
  transition: background 0.15s ease;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}
.related-row:last-child { border-bottom: none; }
.related-row:hover { background: rgba(255,255,255,0.5); padding-left: 8px; padding-right: 8px; }
.related-thumb {
  width: 120px;
  height: 80px;
  border-radius: 10px;
  overflow: hidden;
  background: #e5d6ea;
  flex-shrink: 0;
}
.related-thumb img,
.related-thumb svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.related-row-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--purple-dark);
  line-height: 1.3;
  text-wrap: pretty;
}
.related-row:hover .related-row-title { color: var(--purple-bright); }
.related-row-excerpt {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 0;
  text-wrap: pretty;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (max-width: 540px) {
  .related-row { grid-template-columns: 90px 1fr; gap: 14px; }
  .related-thumb { width: 90px; height: 64px; }
  .related-row-title { font-size: 15px; }
  .related-row-excerpt { font-size: 13.5px; -webkit-line-clamp: 2; }
}

/* ============== Form extras ============== */

.body-textarea {
  font-size: 14.5px !important;
  line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  min-height: 200px;
}

.hint-link {
  font-size: 11px;
  font-weight: 500;
  color: var(--purple);
  text-decoration: underline;
  cursor: pointer;
}
.hint-link:hover { color: var(--purple-bright); }

.field-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 6px;
}

/* ============== Floating action button ============== */
.fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  border: none;
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
  box-shadow: 0 12px 32px -8px rgba(106, 31, 106, 0.55);
  transition: transform 0.15s ease, background 0.15s ease;
  z-index: 50;
}
.fab:hover { background: var(--purple-dark); transform: scale(1.08); }
@media (max-width: 620px) {
  .fab { bottom: 18px; right: 18px; width: 52px; height: 52px; font-size: 26px; }
  .header-actions .ghost-btn { display: none; }
  .header-actions .primary-btn { padding: 9px 14px; font-size: 13px; }
  .site-header { padding-top: 80px; }
}
