:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #666666;
  --border: #dddddd;

  --bg-dark: #0f1115;
  --text-dark: #e6e6e6;
  --muted-dark: #9aa0a6;
  --border-dark: #2a2f36;

  --content-max-width: 1024px;
  --base-font-px: 24;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  font-size: clamp(calc(var(--base-font-px) * 0.75px), 1.2vw + 0.5rem, calc(var(--base-font-px) * 1px));
}

body[data-theme="dark"] {
  color: var(--text-dark);
  background: var(--bg-dark);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  position: sticky;
  top: 0;
  backdrop-filter: saturate(1.1) blur(6px);
  z-index: 10;
}

body[data-theme="dark"] .site-header {
  border-bottom-color: var(--border-dark);
  background: color-mix(in oklab, var(--bg-dark) 92%, transparent);
}

.brand { display: flex; align-items: center; gap: 12px; }
.app-title { font-size: 20px; margin: 0; }
.actions { display: flex; gap: 8px; }

#app {
  max-width: min(var(--content-max-width), calc(100vw - 32px));
  margin: 24px auto;
  padding: 0 8px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  padding: 16px;
}
body[data-theme="dark"] .card {
  border-color: var(--border-dark);
  background: color-mix(in oklab, var(--bg-dark) 98%, #0000);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.meta {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.author { font-weight: 600; }
.time { font-variant-numeric: tabular-nums; }

.content { display: grid; gap: 24px; }

.text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.media { display: grid; gap: 16px; }
.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.image {
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
}
body[data-theme="dark"] .image { border-color: var(--border-dark); }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: color-mix(in oklab, currentColor 10%, transparent); }
.btn:focus-visible { outline: 3px solid #5b9dd9; outline-offset: 2px; }

.primary { background: #0d6efd; color: #ffffff; border-color: #0d6efd; }
.primary:hover { background: #0b5ed7; border-color: #0b5ed7; }

.danger { background: #dc3545; border-color: #dc3545; color: #ffffff; }
.danger:hover { background: #c82333; border-color: #c82333; }

.field { display: grid; gap: 8px; margin-bottom: 16px; }
.label { font-weight: 600; }

.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: inherit;
}
.input:focus-visible { outline: 3px solid #5b9dd9; outline-offset: 2px; }

.small { font-size: 0.9em; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }

.err {
  max-width: min(var(--content-max-width), calc(100vw - 32px));
  margin: 12px auto 0;
  padding: 8px 12px;
  display: grid;
  gap: 4px;
}
.err .item {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #c42;
  background: color-mix(in oklab, #ffdddd 80%, transparent);
  color: #5a0f0f;
}
.err .warn {
  border-color: #c79a00;
  background: color-mix(in oklab, #fff3cd 80%, transparent);
  color: #5a4a00;
}

.compose-grid { display: grid; gap: 24px; }
@media (min-width: 980px) {
  .compose-grid { grid-template-columns: 1fr 1fr; align-items: start; }
}

.form-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.two .field { flex: 1; }

.img-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.img-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.img-list .url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.preview .preview-head { margin-bottom: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  padding: 10px 14px;
  background: #111;
  color: #fff;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 20;
}

a { color: #0d6efd; text-decoration: underline; }
body[data-theme="dark"] a { color: #78a9ff; }

body[data-theme="dark"] .btn:focus-visible,
body[data-theme="dark"] .input:focus-visible,
body[data-theme="dark"] a:focus-visible { outline-color: #78a9ff; }

iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 10px;
  background: #000;
}

