/* =========================================================
   おたすけ — ご近所ゆずりあい掲示板
   デザインコンセプト：町内会の「回覧板」＋手書きの荷札（タグ）
   ========================================================= */

:root{
  --paper:      #EDEEE4;   /* 背景：くすんだ紙のグレーグリーン */
  --paper-card: #F8F8F2;   /* カード面：やや明るい紙 */
  --ink:        #23301C;   /* 本文：深い墨緑 */
  --ink-soft:   #5B6552;   /* 副次テキスト */
  --line:       #C9CBB9;   /* 罫線・点線 */
  --give:       #3F6B4A;   /* 譲ります：苔緑 */
  --give-ink:   #EAF1EA;
  --want:       #B5622A;   /* 求めます：焼き柿色 */
  --want-ink:   #FBEDE2;
  --seal-red:   #A83232;   /* 判子の朱色 */
  --gold:       #C8952A;   /* 麻紐・アクセント */
  --danger:     #B23A3A;
  --shadow:     0 2px 0 rgba(35,48,28,0.06), 0 8px 20px rgba(35,48,28,0.08);

  --font-display: "Shippori Mincho B1", serif;
  --font-body:    "Zen Kaku Gothic New", sans-serif;
}

*{ box-sizing: border-box; }
html,body{ margin:0; padding:0; }

body{
  background: var(--paper);
  background-image:
    radial-gradient(rgba(35,48,28,0.035) 1px, transparent 1px);
  background-size: 14px 14px;
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a{ color: inherit; text-decoration: none; }
button{ font-family: inherit; cursor: pointer; }
input, select, textarea{ font-family: inherit; }

/* ---------------- ヘッダー ---------------- */
.site-header{
  position: sticky; top:0; z-index: 20;
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
  box-shadow: 0 3px 0 rgba(35,48,28,0.05);
}
.header-inner{
  max-width: 1120px; margin: 0 auto;
  display:flex; align-items:center; justify-content: space-between;
  padding: 12px 20px;
  gap: 16px;
}
.brand{ display:flex; align-items:center; gap:12px; }
.hanko{
  display:flex; align-items:center; justify-content:center;
  width: 42px; height: 42px;
  border: 2.5px solid var(--seal-red);
  border-radius: 6px;
  color: var(--seal-red);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  transform: rotate(-3deg);
  flex-shrink: 0;
}
.brand-text{ display:flex; flex-direction: column; line-height: 1.25; }
.brand-title{ font-family: var(--font-display); font-weight:700; font-size: 20px; letter-spacing: 0.04em; }
.brand-sub{ font-size: 11px; color: var(--ink-soft); letter-spacing: 0.05em; }

.header-actions{ display:flex; align-items:center; gap:10px; flex-wrap: wrap; }
.user-chip{
  font-size: 13px; color: var(--ink-soft);
  padding: 4px 10px; border: 1px dashed var(--line); border-radius: 20px;
}

/* ---------------- ボタン ---------------- */
.btn{
  border: none; border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px; font-weight: 700;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.btn:active{ transform: translateY(1px); }
.btn-primary{ background: var(--ink); color: var(--paper-card); box-shadow: var(--shadow); }
.btn-primary:hover{ opacity: .92; }
.btn-ghost{ background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.btn-ghost:hover{ background: rgba(35,48,28,0.06); }
.btn-lg{ padding: 14px 28px; font-size: 16px; }
.btn-block{ width: 100%; }
.btn-oauth{
  flex:1; background: var(--paper-card); border: 1.5px solid var(--line);
  border-radius: 8px; padding: 10px 12px; font-size: 13px; font-weight: 700;
  display:flex; align-items:center; justify-content:center; gap:8px;
}
.btn-oauth span{ font-family: var(--font-display); }
.btn-oauth:hover{ border-color: var(--ink); }

/* ---------------- ヒーロー ---------------- */
.hero{
  max-width: 1120px; margin: 0 auto;
  padding: 64px 20px 48px;
}
.hero-inner{ max-width: 560px; }
.eyebrow{
  font-size: 12px; letter-spacing: 0.18em; color: var(--seal-red);
  font-weight: 700; margin: 0 0 14px;
}
.hero h1{
  font-family: var(--font-display);
  font-size: 38px; line-height: 1.45; margin: 0 0 18px;
  font-weight: 700;
}
.hero-desc{ color: var(--ink-soft); font-size: 15px; margin: 0 0 28px; }

/* ---------------- 掲示板ツールバー ---------------- */
.board{ max-width: 1120px; margin: 0 auto; padding: 12px 20px 80px; }
.board-toolbar{
  display:flex; flex-direction: column; gap: 14px;
  margin: 24px 0 28px;
}
.search-row{ display:flex; gap: 10px; flex-wrap: wrap; }
.search-row input[type="search"]{
  flex: 1 1 260px;
  padding: 12px 14px;
  border: 1.5px solid var(--ink); border-radius: 8px;
  background: var(--paper-card);
  font-size: 14px;
}
.search-row select{
  padding: 12px 14px;
  border: 1.5px solid var(--ink); border-radius: 8px;
  background: var(--paper-card);
  font-size: 14px;
}
.type-tabs{ display:flex; gap: 8px; }
.type-tab{
  background: transparent; border: 1.5px dashed var(--line);
  border-radius: 20px; padding: 7px 16px; font-size: 13px; font-weight: 700;
  color: var(--ink-soft);
}
.type-tab.is-active{ border-style: solid; border-color: var(--ink); color: var(--ink); background: var(--paper-card); }

.empty-state{ text-align:center; color: var(--ink-soft); padding: 60px 0; }

/* ---------------- 荷札カード（タグ）グリッド ---------------- */
.tag-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 22px 18px;
}

.tag-card{
  position: relative;
  background: var(--paper-card);
  border: 1.5px solid var(--ink);
  border-radius: 4px 14px 4px 4px;
  padding: 16px 14px 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s ease;
}
.tag-card:hover{ transform: translateY(-3px) rotate(-0.4deg); }

/* 荷札の穴＋紐 */
.tag-card::before{
  content: "";
  position: absolute; top: -9px; right: 18px;
  width: 14px; height: 14px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 50%;
}
.tag-card::after{
  content: "";
  position: absolute; top: -22px; right: 22px;
  width: 8px; height: 16px;
  border-left: 1.5px solid var(--gold);
  border-right: 1.5px solid var(--gold);
  border-top: 1.5px solid var(--gold);
  border-radius: 8px 8px 0 0;
}

.tag-card-image{
  width: 100%; height: 120px; object-fit: cover;
  border-radius: 2px; margin-bottom: 10px;
  border: 1px solid var(--line);
  background: #E4E4D8;
}
.tag-card-image.placeholder{
  display:flex; align-items:center; justify-content:center;
  font-family: var(--font-display); color: var(--ink-soft); font-size: 13px;
}

.stamp-badge{
  display:inline-flex; align-items:center; justify-content:center;
  font-family: var(--font-display); font-weight: 700; font-size: 12px;
  border: 2px solid var(--give); color: var(--give);
  border-radius: 50%; width: 30px; height: 30px;
  transform: rotate(-6deg);
  margin-bottom: 8px;
}
.stamp-badge.want{ border-color: var(--want); color: var(--want); }

.tag-card-title{ font-size: 15px; font-weight: 700; margin: 0 0 4px; }
.tag-card-cat{ font-size: 12px; color: var(--ink-soft); margin: 0 0 6px; }
.tag-card-foot{ display:flex; justify-content: space-between; align-items:center; font-size: 11px; color: var(--ink-soft); }
.status-pill{
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
  background: var(--line); color: var(--ink);
}
.status-pill.done{ background: var(--ink); color: var(--paper-card); }

/* ---------------- フッター ---------------- */
.site-footer{
  text-align:center; padding: 28px 20px 40px;
  color: var(--ink-soft); font-size: 12px;
  border-top: 1px dashed var(--line);
}

/* ---------------- モーダル共通 ---------------- */
.modal-overlay{
  position: fixed; inset: 0; z-index: 50;
  background: rgba(35,48,28,0.45);
  display:flex; align-items:flex-start; justify-content:center;
  padding: 40px 16px; overflow-y: auto;
}
/* hidden属性がある間は必ず非表示にする（.modal-overlayのdisplay:flexに負けないよう明示） */
.modal-overlay[hidden]{
  display: none;
}
.modal{
  position: relative;
  background: var(--paper-card);
  border: 2px solid var(--ink);
  border-radius: 6px;
  max-width: 480px; width: 100%;
  padding: 30px 26px 26px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}
.modal-close{
  position:absolute; top: 12px; right: 14px;
  background: none; border: none; font-size: 22px; line-height: 1;
  color: var(--ink-soft);
}
.modal-close:hover{ color: var(--ink); }
.modal-title{
  font-family: var(--font-display); font-size: 22px; margin: 0 0 18px;
}

/* ---------------- 認証フォーム ---------------- */
.auth-tabs{ display:flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.auth-tab{
  flex:1; background:none; border:none; padding: 10px 0;
  font-weight: 700; color: var(--ink-soft); border-bottom: 2px solid transparent;
}
.auth-tab.is-active{ color: var(--ink); border-color: var(--seal-red); }

.auth-form, .post-form{ display:flex; flex-direction: column; gap: 14px; }
.auth-form label, .post-form label{
  display:flex; flex-direction: column; gap: 6px;
  font-size: 13px; font-weight: 700; color: var(--ink-soft);
}
.auth-form input, .post-form input, .post-form select, .post-form textarea{
  border: 1.5px solid var(--line); border-radius: 6px;
  padding: 10px 12px; font-size: 14px; color: var(--ink);
  background: #fff;
}
.auth-form input:focus, .post-form input:focus, .post-form select:focus, .post-form textarea:focus{
  outline: 2px solid var(--seal-red); outline-offset: 1px; border-color: var(--seal-red);
}

.auth-divider{ text-align:center; margin: 18px 0 14px; position: relative; color: var(--ink-soft); font-size: 12px; }
.auth-divider::before, .auth-divider::after{
  content:""; position:absolute; top:50%; width: 40%; border-top: 1px dashed var(--line);
}
.auth-divider::before{ left:0; } .auth-divider::after{ right:0; }
.oauth-row{ display:flex; gap: 10px; }

.form-error{ color: var(--danger); font-size: 13px; margin: 0; }
.form-success{ color: var(--give); font-size: 13px; margin: 0; }
.form-hint{ color: var(--ink-soft); font-size: 12px; margin: 0; font-style: italic; }

/* ---------------- 出品フォーム：種別セグメント ---------------- */
.segmented{ display:flex; border: 1.5px solid var(--ink); border-radius: 20px; overflow:hidden; }
.segmented-option{ flex:1; text-align:center; padding: 9px 0; font-size: 13px; font-weight:700; cursor:pointer; }
.segmented-option input{ display:none; }
.segmented-option span{ display:block; color: var(--ink-soft); }
.segmented-option:has(input:checked){ background: var(--ink); }
.segmented-option:has(input:checked) span{ color: var(--paper-card); }

/* ---------------- 詳細モーダル ---------------- */
.detail-modal{ max-width: 640px; }
.detail-body{ display:flex; flex-direction:column; gap: 22px; }
.detail-image-wrap img{ width:100%; max-height: 260px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.detail-meta{ font-size: 12px; color: var(--ink-soft); }
.detail-desc{ white-space: pre-wrap; font-size: 14px; }
.owner-actions{ padding-top: 6px; border-top: 1px dashed var(--line); }
.status-toggle{ display:flex; align-items:center; gap: 8px; font-size: 13px; font-weight: 700; }

.detail-messages{ border-top: 2px solid var(--ink); padding-top: 18px; }
.detail-messages h3{ font-family: var(--font-display); font-size: 16px; margin: 0 0 12px; }
.conversation-picker{ margin-bottom: 12px; }
.conversation-picker label{ display:flex; flex-direction:column; gap:6px; font-size:12px; font-weight:700; color: var(--ink-soft); }
.conversation-picker select{ border: 1.5px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 13px; background:#fff; }
.message-thread{
  max-height: 220px; overflow-y:auto; display:flex; flex-direction:column; gap: 10px;
  margin-bottom: 14px; padding-right: 4px;
}
.message-bubble{
  max-width: 78%; padding: 9px 12px; border-radius: 10px; font-size: 13px;
  background: #fff; border: 1px solid var(--line); align-self: flex-start;
}
.message-bubble.mine{ background: var(--give-ink); border-color: var(--give); align-self: flex-end; }
.message-time{ display:block; font-size: 10px; color: var(--ink-soft); margin-top: 4px; }
.message-form{ display:flex; flex-direction:column; gap: 8px; }
.message-form textarea{
  border: 1.5px solid var(--line); border-radius: 6px; padding: 10px 12px; font-size: 13px; resize: vertical;
}

/* ---------------- トースト ---------------- */
.toast{
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper-card);
  padding: 12px 22px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.25); z-index: 100;
}
.toast.error{ background: var(--danger); }

/* ---------------- レスポンシブ ---------------- */
@media (max-width: 640px){
  .hero h1{ font-size: 28px; }
  .header-actions{ gap: 6px; }
  .btn{ padding: 9px 12px; font-size: 13px; }
  .tag-grid{ grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 12px; }
  .modal{ padding: 24px 18px 20px; }
}
.br-mobile{ display:none; }
@media (max-width: 480px){ .br-mobile{ display:inline; } }
