/* ===== CSS Variables ===== */
:root {
  --bg: #0f0f13;
  --bg2: #1a1a22;
  --bg3: #242430;
  --border: #2e2e3e;
  --text: #e8e8f0;
  --text2: #9999bb;
  --primary: #7c6aff;
  --primary-hover: #9080ff;
  --danger: #ff4d6a;
  --danger-hover: #ff6b84;
  --success: #4caf82;
  --warning: #f5a623;
  --radius: 10px;
  --radius-sm: 6px;
  --header-h: 56px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo', sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; display: block; }
textarea, input, button { font-family: inherit; font-size: 1rem; }

/* ===== Layout ===== */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px;
}
.main-content {
  padding-top: calc(var(--header-h) + 8px);
  padding-bottom: 80px;
}

/* ===== Header ===== */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.header-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.header-logo:hover { color: var(--primary); }
.header-nav { display: flex; gap: 4px; align-items: center; }
.nav-link {
  color: var(--text2);
  font-size: 0.9rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover, .nav-link.active { color: var(--text); background: var(--bg3); }
.nav-logout { color: var(--danger); }
.nav-logout:hover { color: var(--danger-hover); background: rgba(255,77,106,0.1); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-ghost {
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-xs { padding: 4px 10px; font-size: 0.78rem; }
.btn-block { display: flex; width: 100%; }

/* ===== Forms ===== */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.required { color: var(--danger); }
.form-input, .form-textarea {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.form-input:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,106,255,0.2);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text2); opacity: 0.7; }
.form-textarea { resize: vertical; min-height: 100px; }
.mt-2 { margin-top: 8px; }

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.label-row .form-label { margin-bottom: 0; }

.radio-group, .checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.radio-label, .checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.15s, background 0.15s;
}
.radio-label:hover, .checkbox-label:hover { border-color: var(--primary); }
.radio-label input, .checkbox-label input { accent-color: var(--primary); }

.char-counter {
  text-align: right;
  font-size: 0.82rem;
  color: var(--text2);
  margin-top: 4px;
}
.char-counter.over { color: var(--danger); font-weight: 700; }

.form-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.edit-form { padding-bottom: 20px; }

/* ===== Login Page ===== */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
}
.login-title {
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 28px;
  color: var(--text);
}

/* ===== Alerts ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
}
.alert-danger { background: rgba(255,77,106,0.15); border: 1px solid rgba(255,77,106,0.4); color: #ff8fa0; }
.alert-success { background: rgba(76,175,130,0.15); border: 1px solid rgba(76,175,130,0.4); color: #6fcca0; }
.alert code { background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 4px; font-size: 0.88em; }

/* ===== Status Badges ===== */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.tag-idea { background: rgba(245,166,35,0.2); color: #f5a623; border: 1px solid rgba(245,166,35,0.3); }
.tag-draft { background: rgba(74,144,226,0.2); color: #6ab0ff; border: 1px solid rgba(74,144,226,0.3); }
.tag-done { background: rgba(76,175,130,0.2); color: #4caf82; border: 1px solid rgba(76,175,130,0.3); }
.tag-posted { background: rgba(180,80,255,0.2); color: #d480ff; border: 1px solid rgba(180,80,255,0.3); }

/* ===== Tag Pills ===== */
.tag-pill {
  display: inline-block;
  padding: 3px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text2);
  transition: border-color 0.15s, color 0.15s;
  cursor: pointer;
  text-decoration: none;
}
.tag-pill:hover, .tag-pill.active { border-color: var(--primary); color: var(--primary); }
.tag-clear { color: var(--danger); border-color: rgba(255,77,106,0.3); }
.tag-clear:hover { background: rgba(255,77,106,0.1); }

/* ===== Search ===== */
.search-form { margin-bottom: 16px; }
.search-row { display: flex; gap: 8px; }
.search-input { flex: 1; }

/* ===== Filter Tabs ===== */
.filter-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
  flex-shrink: 0;
  padding: 7px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text2);
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.filter-tab:hover { border-color: var(--primary); color: var(--text); }
.filter-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tab-count {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 0 6px;
  font-size: 0.75rem;
  margin-left: 4px;
}
.filter-tab.active .tab-count { background: rgba(255,255,255,0.25); }

/* ===== Tag Filter Row ===== */
.tag-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

/* ===== Content Cards ===== */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: block;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.1s;
}
.card:hover { border-color: var(--primary); transform: translateY(-1px); color: var(--text); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-date { font-size: 0.8rem; color: var(--text2); }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 6px; line-height: 1.4; }
.card-preview { font-size: 0.85rem; color: var(--text2); margin-bottom: 8px; line-height: 1.5; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; }

/* ===== FAB ===== */
.fab {
  position: fixed;
  bottom: 24px;
  right: 20px;
  width: 56px;
  height: 56px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  box-shadow: 0 4px 20px rgba(124,106,255,0.5);
  text-decoration: none;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  z-index: 50;
  line-height: 1;
}
.fab:hover { background: var(--primary-hover); transform: scale(1.08); box-shadow: 0 6px 24px rgba(124,106,255,0.6); color: #fff; }

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 8px;
}
.page-title { font-size: 1.2rem; font-weight: 700; }
.page-actions { display: flex; gap: 8px; }

/* ===== Detail Page ===== */
.detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.detail-date { font-size: 0.85rem; color: var(--text2); }
.detail-title {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 12px;
}
.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.detail-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.section-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-title-row .section-title { margin-bottom: 0; }
.section-body {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.x-draft-body {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 0.95rem;
}
.x-char-count { font-size: 0.82rem; color: var(--text2); }
.mt-2 { margin-top: 8px; }

/* ===== Image Grid ===== */
.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.image-grid-2col { grid-template-columns: repeat(2, 1fr); }
.image-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg3);
}
.image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.2s;
}
.image-item:hover img { opacity: 0.6; }
.image-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  padding: 8px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}
.image-item:hover .image-overlay { opacity: 1; }
.image-name {
  font-size: 0.72rem;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.image-link { font-size: 0.72rem; color: var(--primary); }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}
.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { margin-bottom: 20px; }
.empty-state-sm {
  text-align: center;
  padding: 20px;
  color: var(--text2);
  font-size: 0.88rem;
}

/* ===== Hidden Input ===== */
.hidden-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

/* ===== Code ===== */
code {
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.85em;
}

/* ===== Responsive ===== */
@media (min-width: 600px) {
  .image-grid { grid-template-columns: repeat(4, 1fr); }
  .image-grid-2col { grid-template-columns: repeat(3, 1fr); }
  .form-actions { flex-direction: row; }
  .form-actions .btn-block { flex: 1; width: auto; }
}

/* ===== プロフィールページ追加スタイル ===== */
.alert-success { background: rgba(68,204,136,0.15); border: 1px solid rgba(68,204,136,0.3); color: #44cc88; }
.form-section { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.form-section-title { font-size: 0.9rem; font-weight: 700; color: var(--text2); margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.form-note { font-size: 0.82rem; color: var(--text2); margin-bottom: 12px; margin-top: -8px; }

.search-highlight { background: #ffeb3b; color: #000; border-radius: 2px; padding: 0 2px; }

.search-highlight { background: #ffeb3b; color: #000; border-radius: 2px; padding: 0 2px; }
.search-highlight-active { background: #ff9800; color: #fff; border-radius: 2px; padding: 0 2px; outline: 2px solid #e65100; }
.search-nav-bar { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 8px 16px; border-radius: 24px; display: flex; align-items: center; gap: 10px; box-shadow: 0 4px 12px rgba(0,0,0,.3); z-index: 9999; white-space: nowrap; }
.search-nav-label { font-size: 13px; opacity: .8; }
.search-nav-counter { font-size: 13px; min-width: 48px; text-align: center; }
.search-nav-bar .btn { color: #fff; border-color: rgba(255,255,255,.4); }
.search-nav-bar .btn:hover { background: rgba(255,255,255,.15); }
.header-search { display: flex; align-items: center; gap: 4px; }
.header-search-input { height: 32px; padding: 0 10px; border: 1px solid rgba(255,255,255,.3); border-radius: 16px; background: rgba(255,255,255,.15); color: inherit; font-size: 13px; width: 160px; outline: none; }
.header-search-input::placeholder { opacity: .6; }
.header-search-input:focus { background: rgba(255,255,255,.25); border-color: rgba(255,255,255,.6); }
.header-search-btn { background: none; border: none; cursor: pointer; font-size: 15px; padding: 4px; line-height: 1; }
.header-search-bar { background: var(--surface, #1e1e2e); padding: 10px 16px; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; justify-content: center; }
.hdr-search-form { display: flex; gap: 8px; max-width: 480px; }
.hdr-search-input { flex: 1; height: 36px; padding: 0 12px; border: 1px solid rgba(255,255,255,.2); border-radius: 6px; background: rgba(255,255,255,.08); color: inherit; font-size: 14px; outline: none; }
.hdr-search-input:focus { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.5); }
.header-search-bar .search-input { flex: 1; }