:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1b1f24;
  --text-muted: #6b7280;
  --accent: #2f6feb;
  --accent-contrast: #ffffff;
  --danger-bg: #fdecea;
  --danger-text: #9a2620;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 1px rgba(16, 24, 40, 0.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
    sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f25;
    --border: #2b2f37;
    --text: #e7e9ec;
    --text-muted: #9aa1ab;
    --danger-bg: #3a1d1c;
    --danger-text: #f2a7a2;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
  color: inherit;
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  width: 100%;
}

.btn-ghost {
  background: transparent;
}

.btn-inline {
  width: auto;
}

.btn-small {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* --- top bar / layout --- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 1.05rem;
  margin: 0;
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* --- banners --- */

.banner {
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.banner-error {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.banner-warning {
  background: #fff8e1;
  color: #7a5b00;
}

.banner-success {
  background: #dafbe1;
  color: #1a7f37;
}

@media (prefers-color-scheme: dark) {
  .banner-warning {
    background: #3a3010;
    color: #f2d98a;
  }

  .banner-success {
    background: #123822;
    color: #7ee2a8;
  }
}

/* --- summary --- */

.summary {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.summary-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.1rem;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.summary-chip strong {
  font-size: 1.4rem;
  color: var(--text);
  margin-right: 0.3rem;
}

/* --- tabs --- */

.tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.tab {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-muted);
}

.tab-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

/* --- grid / cards --- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.12);
  outline: none;
}

.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.thumb-wrap {
  aspect-ratio: 16 / 9;
  background: var(--bg);
}

.thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 700;
  color: #fff;
  background: hsl(var(--placeholder-hue, 210) 55% 45%);
}

.card-body {
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}

.card-shrine {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.card-title {
  font-size: 1rem;
  margin: 0;
  line-height: 1.4;
}

.card-period {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.card-badges {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.platform-badge {
  background: var(--badge-color, #666);
  color: #fff;
}

.status-badge {
  background: var(--badge-bg, #eee);
  color: var(--badge-color, #333);
}

.map-link {
  margin-left: auto;
  text-decoration: none;
  font-size: 1rem;
  line-height: 1;
}

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 0;
}

/* --- login --- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  width: min(360px, 90vw);
}

.login-card h1 {
  font-size: 1.1rem;
  margin: 0 0 0.3rem;
}

.login-sub {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 1.2rem;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.login-card label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.login-card input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 0.6rem;
}

.login-card .banner {
  margin: 1rem 0 0;
}

/* --- post detail modal --- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 22, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 1rem;
  overflow-y: auto;
  z-index: 100;
}

/* `.modal-overlay { display: flex }` above has the same specificity as the
   browser's built-in `[hidden] { display: none }` rule, and author styles
   win that tie — so without this override the overlay stayed visible (with
   nothing populated in it yet) even while `hidden` was set, i.e. from page
   load, before any card was ever clicked. This restores hidden-means-hidden. */
.modal-overlay[hidden] {
  display: none;
}

.modal {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.3);
  width: min(560px, 100%);
  overflow: hidden;
}

.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 1;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.75);
}

.modal-thumb {
  aspect-ratio: 16 / 9;
  background: var(--bg);
}

.modal-thumb .thumb-wrap {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}

.modal-thumb .thumb-placeholder {
  font-size: 4rem;
}

.modal-body {
  padding: 1.25rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.modal-shrine {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-title {
  font-size: 1.25rem;
  margin: 0;
  line-height: 1.4;
}

.modal-badges {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin: 0.2rem 0;
}

.modal-period {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-description {
  margin: 0.75rem 0 0;
  white-space: pre-line;
  line-height: 1.75;
  font-size: 0.92rem;
}

.modal-links {
  margin-top: 1rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.modal-links a {
  color: var(--accent);
  font-size: 0.88rem;
  text-decoration: none;
}

.modal-links a:hover {
  text-decoration: underline;
}

/* --- create-post form modal --- */

.modal-form {
  width: min(640px, 100%);
  max-height: 90vh;
  overflow-y: auto;
}

.form-note {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-row {
  margin-bottom: 1rem;
}

.form-row label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.form-row .required {
  color: #d1242f;
}

.form-row input[type='text'],
.form-row input[type='date'],
.form-row input[type='url'],
.form-row select,
.form-row textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.form-row textarea {
  resize: vertical;
  min-height: 6rem;
}

.form-row-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.3rem;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* --- dropzone --- */

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
}

.dropzone:focus-visible,
.dropzone-active {
  outline: none;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
}

.dropzone-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.image-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.image-preview-wrap img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  object-fit: contain;
}

.upload-loading {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- distribution-target checkboxes --- */

.targets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 400;
}

.checkbox-disabled {
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.form-actions .btn-primary {
  width: auto;
}
