.blog-wrap {
  --blog-border: rgba(0, 0, 0, 0.16);
  --blog-muted: rgba(20, 22, 26, 0.7);
  --blog-card: rgba(0, 0, 0, 0.03);
  --blog-input-bg: rgba(0, 0, 0, 0.02);
  --blog-input-border: rgba(0, 0, 0, 0.2);
  --blog-text: rgba(20, 22, 26, 0.95);
  --blog-chip: rgba(0, 0, 0, 0.06);
  --blog-chip-on: rgba(0, 0, 0, 0.88);
  --blog-chip-on-text: #fff;
  margin-top: 0.4rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: break-word;
}

.blog-wrap *,
.blog-wrap *::before,
.blog-wrap *::after,
.crop-modal,
.crop-modal * {
  box-sizing: border-box;
}

html[data-theme="dark"] .blog-wrap {
  --blog-border: rgba(255, 255, 255, 0.16);
  --blog-muted: rgba(255, 255, 255, 0.72);
  --blog-card: rgba(255, 255, 255, 0.04);
  --blog-input-bg: #1c1f26;
  --blog-input-border: rgba(255, 255, 255, 0.22);
  --blog-text: #f4f6f8;
  --blog-chip: rgba(255, 255, 255, 0.08);
  --blog-chip-on: rgba(255, 255, 255, 0.92);
  --blog-chip-on-text: #111;
}

.blog-intro {
  margin: 0 0 1.2rem;
  line-height: 1.65;
  opacity: 0.92;
}

.blog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.4rem;
}

.blog-chip {
  border: 1px solid var(--blog-input-border);
  background: var(--blog-chip);
  color: inherit;
  border-radius: 999px;
  padding: 0.32rem 0.78rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.blog-chip.is-active {
  background: var(--blog-chip-on);
  color: var(--blog-chip-on-text);
  border-color: transparent;
}

.blog-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.35rem;
}

.blog-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--blog-border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--blog-card);
}

.blog-card:hover {
  text-decoration: none;
}

.blog-card__image {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: rgba(127, 127, 127, 0.12);
}

.blog-card__body {
  padding: 0.95rem 1rem 1.05rem;
}

.blog-card__title {
  margin: 0;
  font-size: clamp(1.05rem, 2.6vw, 1.28rem);
  line-height: 1.35;
}

.blog-card__meta,
.blog-post__meta {
  margin: 0.4rem 0 0;
  font-size: 0.92rem;
  color: var(--blog-muted);
}

.blog-card__excerpt {
  margin: 0.55rem 0 0;
  line-height: 1.6;
  opacity: 0.92;
}

.blog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.7rem;
}

.blog-tag {
  font-size: 0.82rem;
  opacity: 0.85;
}

.blog-empty,
.blog-note {
  padding: 0.9rem 0;
  color: var(--blog-muted);
}

.blog-cover {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 14px;
  margin: 0 0 1.1rem;
  display: block;
}

.blog-post__title {
  margin: 0;
  font-size: clamp(1.45rem, 5vw, 2.2rem);
  line-height: 1.25;
}

.blog-post__content {
  margin-top: 1rem;
  line-height: 1.7;
  overflow-x: auto;
}

.blog-post__content img,
.rich-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
  margin: 1rem 0;
}

.blog-post__content p {
  margin: 0 0 1rem;
}

.blog-post__content h2,
.blog-post__content h3 {
  margin: 1.4rem 0 0.6rem;
}

.blog-post__content ul,
.blog-post__content ol {
  margin: 0 0 1rem 1.25rem;
}

.blog-post__content table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  margin: 0 0 1rem;
  display: block;
  overflow-x: auto;
}

.blog-post__content pre,
.blog-post__content code {
  max-width: 100%;
  overflow-x: auto;
}

.blog-post__content iframe,
.blog-post__content video {
  max-width: 100%;
}

.rich-wrap {
  width: 100%;
  min-width: 0;
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.35rem 0 0.45rem;
  position: sticky;
  top: 70px;
  z-index: 6;
  padding: 0.35rem 0;
  background: var(--global-bg-color, #111);
}

.rich-toolbar button {
  border: 1px solid var(--blog-input-border);
  background: #2a2e38;
  color: #f4f6f8;
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  font-size: 0.9rem;
  min-height: 40px;
  min-width: 40px;
  cursor: pointer;
  touch-action: manipulation;
}

.rich-hint {
  margin: 0.4rem 0 0;
  font-size: 0.88rem;
  color: var(--blog-muted);
}

.rich-editor {
  min-height: min(52vh, 380px);
  background: #14161c !important;
  color: #f5f7fa !important;
  caret-color: #f5f7fa;
  -webkit-text-fill-color: #f5f7fa;
  border: 1px solid var(--blog-input-border);
  border-radius: 8px;
  padding: 0.85rem 0.9rem;
  line-height: 1.7;
  outline: none;
  color-scheme: dark;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  cursor: text;
  -webkit-user-select: text;
  user-select: text;
}

.rich-editor p,
.rich-editor h2,
.rich-editor h3,
.rich-editor li,
.rich-editor div,
.rich-editor span {
  color: #f5f7fa !important;
  -webkit-text-fill-color: #f5f7fa;
  background: transparent !important;
}

.rich-editor:empty:before {
  content: attr(data-placeholder);
  color: rgba(245, 247, 250, 0.45);
  -webkit-text-fill-color: rgba(245, 247, 250, 0.45);
}

.rich-editor img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0.85rem 0;
  border-radius: 8px;
}

html:not([data-theme="dark"]) .rich-toolbar button {
  background: #eceef2;
  color: #16181d;
}

html:not([data-theme="dark"]) .rich-editor {
  background: #ffffff !important;
  color: #16181d !important;
  caret-color: #16181d;
  -webkit-text-fill-color: #16181d;
  color-scheme: light;
}

html:not([data-theme="dark"]) .rich-editor p,
html:not([data-theme="dark"]) .rich-editor h2,
html:not([data-theme="dark"]) .rich-editor h3,
html:not([data-theme="dark"]) .rich-editor li,
html:not([data-theme="dark"]) .rich-editor div,
html:not([data-theme="dark"]) .rich-editor span {
  color: #16181d !important;
  -webkit-text-fill-color: #16181d;
}

html:not([data-theme="dark"]) .rich-editor:empty:before {
  color: rgba(22, 24, 29, 0.45);
  -webkit-text-fill-color: rgba(22, 24, 29, 0.45);
}

.crop-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
}

.crop-modal__box {
  width: min(720px, 100%);
  max-height: 100%;
  background: #15171c;
  color: #f4f6f8;
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.crop-modal__canvas {
  height: min(58vh, 420px);
  overflow: hidden;
  background: #000;
}

.crop-modal__canvas img {
  display: block;
}

.crop-modal__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}

.blog-comments {
  margin-top: 2.2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--blog-border);
}

.blog-comments h2 {
  margin: 0 0 0.9rem;
  font-size: 1.35rem;
}

.blog-comment {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--blog-border);
}

.blog-comment__meta {
  font-size: 0.88rem;
  color: var(--blog-muted);
  margin-bottom: 0.25rem;
}

.blog-form {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
}

.blog-form input,
.blog-form textarea,
.blog-form select,
.admin-editor input[type="text"],
.admin-editor input[type="email"],
.admin-editor input[type="password"] {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--blog-input-border);
  background: var(--blog-input-bg) !important;
  color: var(--blog-text) !important;
  caret-color: var(--blog-text);
  border-radius: 8px;
  padding: 0.7rem 0.75rem;
  font-size: 16px;
  color-scheme: dark;
}

html:not([data-theme="dark"]) .blog-form input,
html:not([data-theme="dark"]) .blog-form textarea,
html:not([data-theme="dark"]) .admin-editor input[type="text"] {
  background: #ffffff !important;
  color: #16181d !important;
  caret-color: #16181d;
  color-scheme: light;
}

.blog-form input::placeholder,
.blog-form textarea::placeholder {
  color: var(--blog-muted);
  opacity: 0.85;
}

.blog-form textarea {
  min-height: 110px;
  resize: vertical;
}

.blog-form label {
  font-weight: 600;
  font-size: 0.94rem;
}

.blog-btn,
.admin-btn {
  border: 1px solid var(--blog-input-border);
  background: var(--blog-chip);
  color: inherit;
  border-radius: 8px;
  font-weight: 600;
  padding: 0.6rem 1rem;
  cursor: pointer;
  width: fit-content;
  max-width: 100%;
  min-height: 44px;
  touch-action: manipulation;
}

.blog-btn:disabled,
.admin-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.blog-status {
  min-height: 1.2rem;
  font-size: 0.92rem;
}

.blog-hp {
  position: absolute;
  left: -9999px;
  opacity: 0;
}

.admin-login,
.admin-panel {
  width: 100%;
  max-width: 860px;
}

.admin-login {
  max-width: 420px;
}

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.admin-list {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 1.5rem;
}

.admin-item {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  border-bottom: 1px solid var(--blog-border);
  padding: 0.7rem 0;
  flex-wrap: wrap;
}

.admin-item__title {
  margin: 0;
  font-size: 1.05rem;
}

.admin-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.admin-editor {
  display: grid;
  gap: 0.75rem;
}

.admin-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.9rem;
}

.admin-tags label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
}

.admin-tags input[type="checkbox"] {
  width: 1.1rem !important;
  height: 1.1rem;
  display: inline-block !important;
  margin: 0 !important;
  box-shadow: none;
  background: transparent !important;
}

.admin-preview {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 10px;
  display: none;
}

.admin-editor input[type="checkbox"] {
  width: auto !important;
  display: inline-block;
  margin: 0 0.45rem 0 0;
  box-shadow: none;
  background: transparent !important;
}

.admin-publish {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.admin-editor input[type="file"],
.admin-file {
  width: 100%;
  max-width: 100%;
  display: block;
  background: transparent !important;
  color: var(--blog-text) !important;
  border: 1px dashed var(--blog-input-border);
  box-shadow: none;
  padding: 0.7rem;
  border-radius: 8px;
  font-size: 16px;
}

.admin-hidden {
  display: none !important;
}

body.crop-open {
  overflow: hidden;
}

.blog-chip {
  min-height: 40px;
  touch-action: manipulation;
}

@media (max-width: 639px) {
  .blog-filters {
    gap: 0.4rem;
  }

  .admin-toolbar,
  .admin-item {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-actions,
  .admin-btn,
  .blog-btn,
  .crop-modal__actions .admin-btn {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .rich-editor {
    min-height: 46vh;
    padding: 0.75rem;
  }

  .crop-modal {
    padding: 0;
    align-items: stretch;
  }

  .crop-modal__box {
    width: 100%;
    min-height: 100%;
    border-radius: 0;
    padding: max(0.85rem, env(safe-area-inset-top)) 0.85rem max(0.85rem, env(safe-area-inset-bottom));
  }

  .crop-modal__canvas {
    height: 52vh;
  }
}

@media (min-width: 640px) {
  .blog-grid {
    grid-template-columns: 1fr 1fr;
  }

  .rich-editor {
    min-height: 320px;
  }
}

@media (min-width: 900px) {
  .rich-editor {
    min-height: 380px;
  }

  .blog-post__title {
    font-size: 2.2rem;
  }
}

@media (min-width: 1200px) {
  .blog-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .rich-editor {
    min-height: 160px;
  }

  .crop-modal__canvas {
    height: 48vh;
  }

  .rich-toolbar {
    top: 56px;
  }
}
