/* ================================================================
   覚書ブログ  メインスタイルシート
   テーマ：和風モダン × 落ち着いた書斎感
   フォント：Noto Serif JP（本文） + Zen Kaku Gothic New（UI）
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@400;600;700&family=Zen+Kaku+Gothic+New:wght@300;400;500;700&display=swap');

/* ----------------------------------------------------------------
   CSS カスタムプロパティ
   ---------------------------------------------------------------- */
:root {
  --ink:        #1a1209;
  --ink-mid:    #3d2f1e;
  --ink-light:  #7a6652;
  --paper:      #f5f0e8;
  --paper-warm: #ede7d9;
  --paper-dark: #d8d0c0;
  --accent:     #8b2020;       /* 朱色 */
  --accent-2:   #1a5276;       /* 藍色 */
  --accent-3:   #2e7d32;       /* 萌黄 */
  --gold:       #b8860b;
  --sidebar-w:  260px;
  --radius:     6px;
  --shadow-sm:  0 1px 4px rgba(0,0,0,.10);
  --shadow-md:  0 4px 16px rgba(0,0,0,.14);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.18);
  --trans:      .2s ease;
}

/* ----------------------------------------------------------------
   リセット・ベース
   ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: 'Zen Kaku Gothic New', 'Hiragino Kaku Gothic ProN', sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.75;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* ----------------------------------------------------------------
   レイアウト：左サイドバー + メインコンテンツ
   ---------------------------------------------------------------- */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---- サイドバー ---- */
.left-pane {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 22px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo { font-size: 1.4rem; }
.sidebar-header h1 {
  font-family: 'Noto Serif JP', serif;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--paper);
}

/* ---- アクションボタン ---- */
.action-nav {
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--trans), transform var(--trans), opacity var(--trans);
  text-align: left;
  white-space: nowrap;
  text-decoration: none !important;
}
.btn:active { transform: scale(.97); }

.btn-search  { background: #3d5266; color: #fff; }
.btn-search:hover  { background: #4e6880; }
.btn-print   { background: #4a4035; color: #ede7d9; }
.btn-print:hover   { background: #5e5248; }
.btn-new     { background: var(--accent-3); color: #fff; }
.btn-new:hover     { background: #388e3c; }
.btn-edit    { background: var(--gold); color: #fff; }
.btn-edit:hover    { background: #c9930d; }
.btn-delete  { background: var(--accent); color: #fff; }
.btn-delete:hover  { background: #a52828; }
.btn.disabled { opacity: .38; cursor: not-allowed; pointer-events: none; }

/* ---- セパレータ ---- */
.sidebar-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,.12);
  margin: 10px 14px;
}

/* ----------------------------------------------------------------
   カレンダー
   ---------------------------------------------------------------- */
.calendar { padding: 8px 12px 16px; }

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cal-title {
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--paper-warm);
}
.cal-arrow {
  color: var(--paper-warm);
  font-size: 1.2rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background var(--trans);
  text-decoration: none !important;
}
.cal-arrow:hover { background: rgba(255,255,255,.15); }

.cal-table { width: 100%; border-collapse: collapse; font-size: .76rem; }
.cal-table th {
  color: rgba(255,255,255,.55);
  padding: 3px 2px;
  text-align: center;
  font-weight: 400;
}
.cal-table th.sun { color: #e87070; }
.cal-table th.sat { color: #7aafdf; }

.cal-table td {
  text-align: center;
  padding: 1px;
  position: relative;
}
.cal-table td a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin: auto;
  color: rgba(255,255,255,.75);
  font-size: .78rem;
  transition: background var(--trans), color var(--trans);
  position: relative;
  text-decoration: none !important;
  line-height: 1;
}
.cal-table td a:hover { background: rgba(255,255,255,.18); color: #fff; }
.cal-table td.sun a  { color: #e87070; }
.cal-table td.sat a  { color: #7aafdf; }
/* 今日 */
.cal-table td.today a {
  background: var(--accent);
  color: #fff !important;
  font-weight: 700;
}
/* 閲覧中の日 */
.cal-table td.viewing a {
  outline: 2px solid var(--gold);
  outline-offset: -1px;
}
/* 記事あり：青い点 */
.dot-article {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #7aafdf;
  margin: 1px auto 0;
  flex-shrink: 0;
}
/* 今日マーク（赤い点）は today クラスで background が赤なので不要。
   今日かつ記事あり → 白ドット */
.cal-table td.today .dot-article { background: rgba(255,255,255,.85); }

/* ----------------------------------------------------------------
   メインペイン
   ---------------------------------------------------------------- */
.main-pane {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 60px;
  background: var(--paper);
}

/* 日付バー */
.article-date-bar {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink-mid);
  border-left: 4px solid var(--accent);
  padding-left: 12px;
  margin-bottom: 20px;
  letter-spacing: .06em;
}

/* ジャンルバッジ */
.genre-badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1.5px solid currentColor;
  letter-spacing: .1em;
  margin-bottom: 10px;
}
.genre-1 { color: #c0392b; }
.genre-2 { color: #1a5276; }
.genre-3 { color: #1e8449; }
.genre-4 { color: #7d3c98; }
.genre-5 { color: #d35400; }
.genre-6 { color: #b7950b; }

/* 記事 */
.article-title {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
  margin-bottom: 18px;
  border-bottom: 1px solid var(--paper-dark);
  padding-bottom: 12px;
}

.article-text {
  font-family: 'Noto Serif JP', serif;
  font-size: .95rem;
  line-height: 2;
  color: var(--ink-mid);
  margin-bottom: 28px;
}

/* メディアセクション */
.media-section, .links-section { margin-bottom: 24px; }
.media-label {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--ink-light);
  border-bottom: 1px solid var(--paper-dark);
  padding-bottom: 5px;
  margin-bottom: 12px;
}

.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.media-item { border-radius: var(--radius); overflow: hidden; background: var(--paper-warm); box-shadow: var(--shadow-sm); }
.media-item img { width: 100%; height: 160px; object-fit: cover; display: block; transition: transform .3s; }
.media-item img:hover { transform: scale(1.04); }
.media-item figcaption, .media-item figcaption { font-size: .72rem; color: var(--ink-light); padding: 6px 8px; }
.media-item video { width: 100%; max-height: 240px; display: block; background: #000; }

.link-list { list-style: none; }
.link-list li { padding: 6px 0; border-bottom: 1px dashed var(--paper-dark); font-size: .88rem; }
.link-list li:last-child { border-bottom: none; }
.link-list a::before { content: '→ '; color: var(--accent-2); }

/* 記事なし */
.no-article {
  text-align: center;
  padding: 80px 20px;
  color: var(--ink-light);
}
.no-article-icon { font-size: 3.5rem; margin-bottom: 16px; opacity: .5; }
.no-article p { font-size: 1.05rem; margin-bottom: 24px; }

/* ----------------------------------------------------------------
   リアクションバー（いいね・コメント）
   ---------------------------------------------------------------- */
.reaction-bar {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--paper-dark);
}

.btn-like, .btn-comment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: 24px;
  border: 2px solid var(--paper-dark);
  background: #fff;
  color: var(--ink-mid);
  font-family: inherit;
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--trans);
}
.btn-like:hover  { border-color: var(--accent); color: var(--accent); background: #fff4f4; }
.btn-like.liked  { border-color: var(--accent); background: var(--accent); color: #fff; }
.btn-comment:hover { border-color: var(--accent-2); color: var(--accent-2); background: #f0f4f8; }
.like-count, .comment-count { font-weight: 700; min-width: 16px; text-align: center; }

/* ----------------------------------------------------------------
   コメントエリア
   ---------------------------------------------------------------- */
.comment-area {
  margin-top: 20px;
  background: var(--paper-warm);
  border-radius: var(--radius);
  padding: 20px 24px;
  border: 1px solid var(--paper-dark);
}
.comment-area h3 {
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--ink-light);
  margin-bottom: 14px;
}
.comment-item {
  padding: 10px 0;
  border-bottom: 1px dashed var(--paper-dark);
}
.comment-item:last-of-type { border-bottom: none; }
.comment-author { font-weight: 700; font-size: .82rem; margin-right: 10px; color: var(--accent-2); }
.comment-date   { font-size: .74rem; color: var(--ink-light); }
.comment-text   { font-size: .88rem; margin-top: 5px; color: var(--ink-mid); }
.no-comment     { font-size: .85rem; color: var(--ink-light); padding: 6px 0 14px; }

.comment-form   { margin-top: 16px; }
.form-row       { margin-bottom: 10px; }
.form-row label { display: block; font-size: .78rem; font-weight: 700; color: var(--ink-light); margin-bottom: 4px; letter-spacing: .05em; }
.form-row input, .form-row textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--paper-dark);
  border-radius: var(--radius);
  background: #fff;
  font-family: inherit;
  font-size: .88rem;
  color: var(--ink);
  transition: border-color var(--trans);
}
.form-row input:focus, .form-row textarea:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(26,82,118,.12);
}

/* ----------------------------------------------------------------
   モーダル
   ---------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 32px 36px;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-box h3 { font-family: 'Noto Serif JP', serif; font-size: 1.15rem; margin-bottom: 14px; color: var(--accent); }
.modal-box p  { font-size: .9rem; color: var(--ink-mid); margin-bottom: 22px; line-height: 1.75; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* ----------------------------------------------------------------
   フォームページ（新規・編集）
   ---------------------------------------------------------------- */
.form-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}
.form-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--paper-dark);
  padding-bottom: 14px;
}
.form-header h2 {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
}
.back-link {
  font-size: .82rem;
  color: var(--ink-light);
  border: 1px solid var(--paper-dark);
  padding: 5px 12px;
  border-radius: 20px;
  white-space: nowrap;
  transition: all var(--trans);
}
.back-link:hover { background: var(--paper-dark); text-decoration: none !important; }

.article-form .form-group { margin-bottom: 20px; }
.article-form label {
  display: block;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--ink-light);
  margin-bottom: 6px;
}
.req { color: var(--accent); font-size: .75rem; }
.article-form input[type="text"],
.article-form input[type="date"],
.article-form input[type="url"],
.article-form select,
.article-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--paper-dark);
  border-radius: var(--radius);
  background: #fff;
  font-family: 'Noto Serif JP', serif;
  font-size: .92rem;
  color: var(--ink);
  transition: border-color var(--trans), box-shadow var(--trans);
}
.article-form input:focus,
.article-form select:focus,
.article-form textarea:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(26,82,118,.10);
}
.article-form textarea { resize: vertical; min-height: 220px; line-height: 1.9; }

.file-fieldset {
  border: 1.5px solid var(--paper-dark);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  margin-bottom: 22px;
  background: var(--paper-warm);
}
.file-fieldset legend {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--ink-light);
  padding: 0 8px;
}
.file-row, .link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.file-row label, .link-row label {
  min-width: 60px;
  font-size: .78rem;
  color: var(--ink-light);
  font-weight: 500;
  margin-bottom: 0;
}
.file-row input[type="file"] { flex: 1; min-width: 0; }
.link-row input[type="url"]  { flex: 2; min-width: 160px; }
.link-row input[type="text"] { flex: 1; min-width: 100px; }

.readonly-date {
  padding: 10px 14px;
  background: var(--paper-dark);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--ink-mid);
  font-weight: 600;
  letter-spacing: .05em;
}

.existing-media-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 8px 10px;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--paper-dark);
  flex-wrap: wrap;
}
.existing-media-row .thumb      { width: 64px; height: 48px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.existing-media-row .thumb-video{ width: 90px; height: 56px; flex-shrink: 0; }
.existing-media-row span        { flex: 1; font-size: .8rem; color: var(--ink-mid); min-width: 80px; }
.del-check { font-size: .78rem; color: var(--accent); display: flex; align-items: center; gap: 5px; cursor: pointer; white-space: nowrap; }
.del-check input { cursor: pointer; }
.add-media-title { font-size: .78rem; color: var(--ink-light); margin-top: 12px; font-weight: 700; }
.no-media { font-size: .82rem; color: var(--ink-light); margin-top: 6px; }
.note     { font-size: .76rem; color: var(--ink-light); margin-top: 8px; font-style: italic; }

.form-actions {
  display: flex;
  gap: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--paper-dark);
  justify-content: flex-end;
}
.form-actions .btn { padding: 11px 26px; font-size: .9rem; }

/* アラート */
.alert { border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; font-size: .88rem; }
.alert-error { background: #fdf0f0; border: 1px solid #e0a0a0; color: #8b1a1a; }
.alert-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.alert ul { padding-left: 18px; }
.alert ul li { margin-top: 4px; }

/* ----------------------------------------------------------------
   印刷ページ
   ---------------------------------------------------------------- */
.print-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 30px 24px;
  font-family: 'Noto Serif JP', serif;
}
.print-page .print-header {
  border-bottom: 2px solid var(--ink);
  padding-bottom: 12px;
  margin-bottom: 24px;
}
.print-page h1 { font-size: 1.4rem; }
.print-page .print-date { font-size: .85rem; color: var(--ink-light); margin-top: 4px; }
.print-page .print-body { font-size: .95rem; line-height: 2.1; }
.print-actions { display: flex; gap: 12px; margin-bottom: 24px; }
@media print {
  .print-actions { display: none; }
  body { background: #fff; }
}

/* ----------------------------------------------------------------
   検索ページ
   ---------------------------------------------------------------- */
.search-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}
.search-form-box {
  background: var(--paper-warm);
  border: 1.5px solid var(--paper-dark);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 28px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.search-form-box .sf-group { display: flex; flex-direction: column; gap: 5px; }
.search-form-box label      { font-size: .78rem; font-weight: 700; letter-spacing: .06em; color: var(--ink-light); }
.search-form-box select,
.search-form-box input[type="text"] {
  padding: 9px 13px;
  border: 1.5px solid var(--paper-dark);
  border-radius: var(--radius);
  background: #fff;
  font-family: inherit;
  font-size: .9rem;
  color: var(--ink);
  min-width: 180px;
}
.search-form-box select:focus,
.search-form-box input:focus { outline: none; border-color: var(--accent-2); }

.search-results { display: flex; flex-direction: column; gap: 14px; }
.search-result-item {
  background: #fff;
  border: 1.5px solid var(--paper-dark);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  gap: 18px;
  align-items: flex-start;
  transition: box-shadow var(--trans);
}
.search-result-item:hover { box-shadow: var(--shadow-md); }
.sri-main { flex: 1; min-width: 0; }
.sri-meta  { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; flex-wrap: wrap; }
.sri-date  { font-size: .78rem; color: var(--ink-light); font-weight: 600; }
.sri-title { font-family: 'Noto Serif JP', serif; font-size: 1rem; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.sri-excerpt { font-size: .85rem; color: var(--ink-mid); line-height: 1.65; }
.sri-action { flex-shrink: 0; }
.no-results { text-align: center; padding: 50px; color: var(--ink-light); font-size: .95rem; }

/* ----------------------------------------------------------------
   レスポンシブ（768px以下）
   ---------------------------------------------------------------- */
@media (max-width: 768px) {
  .app-wrapper { flex-direction: column; }
  .left-pane   { width: 100%; height: auto; position: static; flex-direction: column; }
  .action-nav  { flex-direction: row; flex-wrap: wrap; }
  .main-pane   { padding: 18px 16px 40px; }
  .cal-table td a { width: 26px; height: 26px; font-size: .72rem; }
}
