/* =======================================
   Base (cleaned)
======================================= */
@import url('https://fonts.googleapis.com/css2?family=DotGothic16&family=M+PLUS+Rounded+1c:wght@400;600&display=swap');

:root {
  --bg:#f7f7fb; --card:#fff; --text:#222; --muted:#667085;
  --border:#e6e6ef; --primary:#6c5ce7; --primary-weak:#efeefd;
  --danger:#e5484d; --danger-weak:#ffe9ec;
  --shadow:0 8px 24px rgba(0,0,0,.06); --radius:14px;
}

@media (prefers-color-scheme: dark){
  :root{
    --bg:#0e0f14; --card:#151823; --text:#eef0f4; --muted:#9aa3b2;
    --border:#262b3a; --primary:#8a7bff; --primary-weak:#262240;
    --danger:#ff6b81; --danger-weak:#3a1d25; --shadow:0 8px 24px rgba(0,0,0,.35);
  }
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0; padding:24px;
  background:
    radial-gradient(1200px 600px at -10% -20%, rgba(108,92,231,.08), transparent 65%),
    radial-gradient(900px 500px at 110% 20%, rgba(255,107,150,.08), transparent 60%),
    var(--bg);
  color:var(--text);
  font-family:"DotGothic16", system-ui, -apple-system, Segoe UI, Roboto, "M PLUS Rounded 1c", sans-serif;
  line-height:1.6;
}

/* Container & Header */
.container{ max-width:960px; margin:0 auto; }
.site-header{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:12px 16px; margin:0 0 18px; background:var(--card);
  border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow);
}
.site-title{ font-size:clamp(20px,3.6vw,28px); margin:0; }
.header-actions a{ color:var(--muted); text-decoration:none; }
.header-actions a:hover{ color:var(--primary); }

/* Sections */
section{
  background:var(--card); border:1px solid var(--border);
  border-radius:var(--radius); box-shadow:var(--shadow);
  padding:18px; margin:16px 0;
}
h1,h2{ margin:0 0 12px; line-height:1.2; }
h2{ font-size:clamp(16px,3vw,20px); }

/* Thread list */
ul{ list-style:none; padding:0; margin:0; }
.thread-item{
  display:grid; grid-template-columns:1fr auto; gap:8px;
  padding:12px 10px; border-top:1px solid var(--border);
}
.thread-item:first-child{ border-top:0; }
.thread-item a{ color:var(--text); text-decoration:none; font-weight:600; }
.thread-item a:hover{ color:var(--primary); }
.thread-meta{ color:var(--muted); font-size:.9em; }

/* Posts */
.posts{ display:grid; gap:14px; }
.post{
  background:var(--card); border:1px solid var(--border);
  border-radius:calc(var(--radius) - 4px); padding:14px;
}
.post header{
  display:flex; align-items:center; justify-content:space-between;
  font-size:.95em; color:var(--muted); margin-bottom:8px;
}
.post p{ margin:8px 0; }

/* Images */
.post-image, .post-thumb{
  width:clamp(180px, 40vw, 360px); /* ← 好みで調整 */
  border-radius:10px; overflow:hidden; margin:8px 0;
  border:1px solid var(--border); background:#fafafd;
}
.post-img{ display:block; width:100%; height:auto; }
.post-thumb{ aspect-ratio:4/3; }
.post-thumb img{ width:100%; height:100%; object-fit:cover; }

/* Forms */
form{ display:grid; gap:10px; max-width:640px; }
input[type="text"], input[type="password"], input[type="file"], textarea{
  width:100%; border:1px solid var(--border); background:transparent;
  padding:10px 12px; border-radius:10px; color:var(--text);
}
textarea{ min-height:120px; resize:vertical; }

/* Buttons */
button, .btn{
  appearance:none; border:1px solid var(--border); background:#fff; color:#727272;
  padding:10px 14px; border-radius:9999px; cursor:pointer;
  transition:transform .12s ease, box-shadow .12s ease, background .12s;
}
button:hover, .btn:hover{ box-shadow:var(--shadow); transform:translateY(-1px); }
.btn-primary{ background:var(--primary); border-color:transparent; color:#fff; }
.btn-danger{ background:var(--danger-weak); border-color:transparent; color:var(--danger); }
.btn-ghost{ background:transparent; }

/* Like button (with animations) */
.like-btn{
  display:inline-flex; align-items:center; gap:.25rem;
  border:1px solid var(--border); border-radius:9999px;
  padding:.35rem .7rem; background:#fff; cursor:pointer;
  transition:transform .15s ease, box-shadow .15s ease, background .15s;
}
.like-btn:hover{ box-shadow:var(--shadow); }
.like-btn[disabled], .like-btn.is-busy{ opacity:.6; cursor:default; pointer-events:none; }
.like-btn.liked{ background:var(--primary-weak); border-color: color-mix(in oklab, var(--primary) 35%, var(--border)); }

@keyframes pop{ 0%{transform:scale(1)} 50%{transform:scale(1.12)} 100%{transform:scale(1)} }
@keyframes shake{ 0%,100%{transform:translateX(0)} 25%{transform:translateX(-2px)} 75%{transform:translateX(2px)} }
.like-btn.pop{ animation:pop .22s ease; }
.like-btn.shake{ animation:shake .18s linear; }

/* Delete buttons in posts a bit smaller */
.post form[action$="delete.php"] button{ font-size:.9em; }

/* Image zoom overlay */
.zoom-overlay{
  position:fixed; inset:0; background:rgba(0,0,0,.72);
  display:flex; align-items:center; justify-content:center;
  z-index:9999; padding:24px; animation:zoomfade .12s ease;
}
.zoom-overlay img{
  max-width:96vw; max-height:90vh; border-radius:10px;
  box-shadow:0 8px 28px rgba(0,0,0,.35);
}
@keyframes zoomfade{ from{opacity:0} to{opacity:1} }

/* Misc */
small, time{ color:var(--muted); }
a{ color:var(--primary); }
a:hover{ opacity:.9; }
kbd{ background:#111; color:#fff; border-radius:6px; padding:.1em .4em; font-size:.85em; }


/* =======================================
   Responsive
======================================= */

/* ~480px（スマホ縦） */
@media (max-width: 480px) {
  body { padding: 16px; }

  .site-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
  }
  .site-title { font-size: 20px; }
  .header-actions { display: flex; justify-content: flex-end; }

  section { padding: 14px; margin: 12px 0; }
  h2 { font-size: 16px; }

  .container { max-width: 100%; }

  /* スレ一覧は1列で詰める */
  .thread-item {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 10px 6px;
  }
  .thread-meta { font-size: .8em; }

  /* 投稿 */
  .posts { gap: 12px; }
  .post { padding: 12px; }
  .post header { font-size: .9em; }

  /* 画像は幅いっぱいでOK */
  .post-image, .post-thumb {
    width: 100%;
    margin: 6px 0;
  }

  /* フォームのタップしやすさ＆iOSズーム防止 */
  form { max-width: 100%; gap: 8px; }
  input[type="text"], input[type="password"], input[type="file"], textarea {
    font-size: 16px; /* iOSでの自動ズーム抑止 */
    padding: 10px 12px;
  }

  /* ボタンは少し大きめ */
  button, .btn { padding: 12px 14px; }
  .post form[action$="delete.php"] button { font-size: .95em; }
}

/* ~768px（スマホ横〜タブレット） */
@media (max-width: 768px) {
  .container { max-width: 100%; }
  section { padding: 16px; }
  .posts { gap: 12px; }

  /* 画像はちょい広めの可変 */
  .post-image, .post-thumb {
    width: clamp(200px, 60vw, 380px);
  }
}

/* 1024px〜（PCワイド） */
@media (min-width: 1024px) {
  .container { max-width: 1040px; }
  /* 詳細ページの画像を少し大きめに */
  .post-image, .post-thumb {
    width: clamp(240px, 36vw, 480px);
  }
}

/* アニメが苦手な人向け（OS設定に追従） */
@media (prefers-reduced-motion: reduce) {
  .like-btn,
  .like-btn:hover { transition: none; }
  .like-btn.pop,
  .like-btn.shake,
  .zoom-overlay { animation: none !important; }
}
