:root {
  --app-max-width: 500px;
  --page-padding: 16px;
  --text: #111;
  --muted: #444;
  --line: #e6e6e6;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: none;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: #fff;
  color: var(--text);
  font-family:
    "Roboto Condensed",
    system-ui,
    -apple-system,
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  appearance: none;
}

a {
  color: inherit;
  text-decoration: none;
}

.page-shell {
  width: 100%;
  max-width: var(--app-max-width);
  margin: 0 auto;
  padding: 72px var(--page-padding) 56px;
}

.page-shell-post {
  padding-top: 0;
}

.site-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, var(--app-max-width));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px var(--page-padding) 18px;
  background: transparent;
  z-index: 20;
}

.site-header-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.site-title {
  display: inline-block;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: 0;
}

.site-tagline {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
  color: var(--text);
}

.edit-mark {
  font-size: 0.8em;
  font-weight: 400;
  white-space: nowrap;
}

.post-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.post-row {
  display: grid;
  grid-template-columns: calc((100% - 12px) / 3) calc(((100% - 12px) / 3) * 2);
  gap: 12px;
  align-items: stretch;
  width: 100%;
  padding: 0;
  border: 0;
  background: #fff;
  text-align: left;
  color: inherit;
  overflow: hidden;
}

.post-row.is-clickable {
  cursor: pointer;
}

.post-thumb-wrap {
  position: relative;
  overflow: hidden;
}

.post-thumb-link {
  display: block;
}

.post-thumb {
  aspect-ratio: 4 / 5;
  width: 100%;
  object-fit: cover;
  border-radius: 0;
  background: #efefef;
}

.post-edit-trigger {
  position: absolute;
  right: 8px;
  bottom: 8px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.post-copy {
  display: flex;
  min-width: 0;
  height: 100%;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  padding: 0;
  color: inherit;
  overflow: hidden;
}

.post-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0;
}

.post-subtitle,
.post-date {
  margin: 0;
  line-height: 1.2;
}

.post-subtitle {
  font-size: 15px;
  color: var(--text);
}

.post-date {
  font-size: 14px;
  color: var(--muted);
}

.post-excerpt {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.25;
  max-height: calc(1.25em * 3);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-chip {
  display: block;
  margin: 0;
  padding: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.floating-add {
  position: fixed;
  right: max(16px, calc((100vw - var(--app-max-width)) / 2 + 16px));
  bottom: 16px;
  display: grid;
  height: 72px;
  width: 72px;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: #111;
  color: #fff;
  font-size: 42px;
  line-height: 1;
  cursor: pointer;
  z-index: 30;
}

.empty-state {
  margin: 0;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 0 0 10px;
}

.back-link {
  color: var(--text);
  font-size: 14px;
}

.post-view {
  display: grid;
  gap: 0;
}

.carousel-shell {
  position: relative;
  overflow: hidden;
  border-radius: 0;
  background: #fff;
}

.carousel-track {
  display: flex;
  transition: transform 220ms ease;
  touch-action: pan-y;
}

.carousel-slide {
  min-width: 100%;
}

.carousel-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: #efefef;
}

.carousel-nav {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
}

.ghost-button {
  border: 0;
  border-radius: 0;
  background: rgba(17, 17, 17, 0.9);
  color: #fff;
  padding: 8px 10px;
  font-size: 12px;
  cursor: pointer;
  touch-action: manipulation;
}

.carousel-dots {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 6px;
}

.carousel-dot {
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.5);
}

.carousel-dot.is-active {
  background: #fff;
}

.post-body-shell {
  padding: 14px 0 0;
}

.post-body-shell .post-title {
  margin-bottom: 6px;
  font-size: 21px;
}

.post-body {
  margin-top: 18px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.post-admin-actions {
  display: flex;
  gap: 18px;
  margin-top: 18px;
}

.post-inline-action {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
  cursor: pointer;
}

.modal,
.login-modal {
  position: fixed;
  inset: 0;
  display: none;
  padding: 0;
  background: rgba(255, 255, 255, 0.96);
  z-index: 40;
}

.modal {
  place-items: end center;
}

.login-modal {
  place-items: center;
}

.modal.is-open,
.login-modal.is-open {
  display: grid;
}

.modal-card,
.login-card {
  width: min(100%, var(--app-max-width));
  border: 1px solid var(--line);
  background: #fff;
}

.modal-card {
  max-height: 100vh;
  overflow: auto;
  border-radius: 0;
  padding: 16px;
}

.login-card {
  border-radius: 0;
  padding: 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-title,
.login-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.login-copy,
.form-message,
.login-error {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.icon-button {
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  padding: 0;
}

.editor-form,
.login-form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field textarea,
.login-input {
  width: 100%;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
}

.field textarea {
  min-height: 160px;
  resize: vertical;
}

.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 6px;
}

.button {
  border: 0;
  border-radius: 0;
  padding: 12px 14px;
  cursor: pointer;
}

.button-primary {
  background: #111;
  color: #fff;
}

.button-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.preview-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
}

.preview-item {
  position: relative;
}

.preview-strip img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 0;
  background: #efefef;
}

.preview-remove {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 32px;
  height: 32px;
  border: 0;
  background: rgba(17, 17, 17, 0.88);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 520px) {
  .page-shell {
    padding-top: 68px;
  }

  .page-shell-post {
    padding-top: 0;
  }

  .site-header {
    padding-top: 12px;
  }

  .site-title {
    font-size: 22px;
  }

  .post-row {
    grid-template-columns: calc((100% - 12px) / 3) calc(((100% - 12px) / 3) * 2);
    gap: 12px;
    background: #fff;
  }

  .post-copy {
    padding: 0;
  }

  .floating-add {
    right: 0;
    bottom: 0;
  }

  .modal-card,
  .login-card {
    width: 100%;
    min-height: auto;
  }
}
