/* ============================================
   Studylink Journal — Styles
   ============================================ */

:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --text: #2c2c2c;
  --text-muted: #777;
  --border: #e5e1d6;
  --primary: #6b9b76;
  --primary-hover: #588462;
  --secondary: #5b8def;
  --secondary-hover: #4a78d4;
  --accent: #e8a87c;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --radius-small: 6px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
               "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3 { margin: 0 0 0.5em; }

p { margin: 0 0 0.5em; }

.muted { color: var(--text-muted); }
.small { font-size: 0.85em; }

/* ============================================
   Layout
   ============================================ */
.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.app-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.card-title {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--text);
}

.section-title {
  font-size: 1.1rem;
  margin: 24px 0 16px;
  padding-left: 4px;
}

.entries-section {
  margin-top: 8px;
}

/* ============================================
   Login Card
   ============================================ */
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 32px;
  text-align: center;
  max-width: 360px;
  width: 100%;
}

.brand {
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.3;
}

.subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
}

.login-note {
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================
   Forms
   ============================================ */
.input, .textarea, .select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  font-family: inherit;
  font-size: 0.95rem;
  background: #fdfcf8;
  color: var(--text);
  margin-bottom: 12px;
}

.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}

.textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='%23777' d='M4 6l4 4 4-4z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  padding-right: 32px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 140px;
}

.field-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.field .select {
  margin-bottom: 0;
}

.row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.controls-row > * { margin-bottom: 0; }

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.status-text {
  font-size: 0.85rem;
  color: var(--primary);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-block;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-small);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

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

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary {
  background: var(--secondary);
  color: white;
}
.btn-secondary:hover:not(:disabled) { background: var(--secondary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: #f0ede4; }

.btn-block { width: 100%; padding: 12px; }
.btn-small { padding: 6px 12px; font-size: 0.85rem; }

/* ============================================
   Entry Card
   ============================================ */
.entry-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 16px;
}

.entry-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

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

.entry-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 8px 0;
}

.entry-body {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 8px 0;
  line-height: 1.7;
}

.entry-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.read-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff4e6;
  border: 1px solid #f4d3a8;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.8rem;
  color: #8b5a2b;
}

.read-avatar {
  font-size: 1rem;
}

/* ============================================
   Comments
   ============================================ */
.entry-comments {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.comment {
  background: #f9f6ee;
  border-radius: var(--radius-small);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.comment-avatar { font-size: 1rem; }

.comment-author {
  font-weight: 600;
  color: var(--text);
}

.comment-body {
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-compose {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.comment-compose .textarea {
  margin-bottom: 8px;
}

/* ============================================
   Empty State
   ============================================ */
.empty {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
}

/* ============================================
   Print Area (hidden on screen)
   ============================================ */
#print-area {
  display: none;
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
  body > * { display: none !important; }
  #print-area { display: block !important; }

  body {
    background: white;
    color: black;
    font-size: 11pt;
  }

  #print-area {
    padding: 0;
    margin: 0;
  }

  .print-header {
    border-bottom: 2px solid #333;
    padding-bottom: 12px;
    margin-bottom: 24px;
  }

  .print-header h1 {
    font-size: 18pt;
    margin: 0 0 4px;
  }

  .print-header p {
    margin: 0;
    color: #555;
    font-size: 12pt;
  }

  .print-entry {
    page-break-inside: avoid;
    margin-bottom: 24px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 16px;
  }

  .print-entry-date {
    font-size: 9pt;
    color: #555;
    margin-bottom: 4px;
  }

  .print-entry-title {
    font-size: 13pt;
    font-weight: 600;
    margin: 4px 0 8px;
  }

  .print-entry-body {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.7;
    margin: 4px 0;
  }

  .print-comments {
    margin-top: 12px;
    padding: 10px 12px;
    background: #f5f5f5;
    border-radius: 4px;
  }

  .print-comments-label {
    font-size: 9pt;
    color: #555;
    margin-bottom: 6px;
    font-weight: 600;
  }

  .print-comment {
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 4px;
  }

  @page {
    margin: 18mm 14mm;
  }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 600px) {
  .app-main { padding: 16px; }
  .card { padding: 16px; }
  .entry-card { padding: 16px; }
  .header-inner { padding: 12px 16px; }
  .header-title { font-size: 1rem; }
  .row { flex-direction: column; align-items: stretch; }
  .field { width: 100%; }
}
