/* ============ TherapyPartner — Stylesheet ============ */
/* 溫暖療育配色:沙色背景、鼠尾草綠主色、暖灰文字 */

:root {
  --bg: #f7f3ec;
  --bg-card: #ffffff;
  --bg-soft: #efe9dd;
  --bg-deep: #2a3138;

  --primary: #7a8fa6;       /* 鼠尾草藍 */
  --primary-deep: #5b7286;
  --primary-soft: #d3dde6;

  --accent: #c89774;        /* 陶土橘 */
  --accent-soft: #f0dccc;

  --success: #6b8a72;       /* 鼠尾草綠 */
  --success-soft: #d4e0d6;
  --warn: #c89968;
  --warn-soft: #f0dfc9;
  --danger: #b76e6e;
  --danger-soft: #efd4d4;

  --text: #2f3640;
  --text-soft: #6a7280;
  --text-mute: #98a0a8;
  --border: #e2dcd0;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(60, 50, 30, 0.06), 0 4px 12px rgba(60, 50, 30, 0.04);
  --shadow-lg: 0 6px 24px rgba(60, 50, 30, 0.12);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
               "Heiti TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

code {
  background: var(--bg-soft);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ============ Layout ============ */
#app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: calc(76px + var(--safe-bottom));
}

.app-header {
  background: linear-gradient(135deg, #7a8fa6 0%, #5b7286 100%);
  color: #f7f3ec;
  padding: 18px 20px 22px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

.app-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  font-size: 32px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.app-header h1 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.app-header .subtitle {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
}

.badge-streak {
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

main {
  padding: 16px 16px 24px;
}

.page {
  display: none;
  animation: fadeIn 0.25s ease;
}

.page-active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ Hero ============ */
.hero {
  text-align: center;
  padding: 28px 16px 20px;
}

.hero-icon {
  font-size: 44px;
  margin-bottom: 10px;
}

.hero h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.hero p {
  font-size: 14px;
  color: var(--text-soft);
}

.page-header {
  margin-bottom: 16px;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.muted {
  font-size: 13px;
  color: var(--text-soft);
}

/* ============ Quick cards (today) ============ */
.today-quick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.quick-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.quick-card:active {
  transform: scale(0.96);
  background: var(--bg-soft);
}

.quick-emoji {
  font-size: 28px;
}

.quick-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-soft);
}

/* ============ Cards ============ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-result {
  border-color: var(--success);
  background: linear-gradient(135deg, #fffefb 0%, var(--success-soft) 100%);
}

.card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

/* ============ Form ============ */
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
  margin: 12px 0 6px;
}

label:first-child { margin-top: 0; }

input[type="text"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 15px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(122, 143, 166, 0.15);
}

textarea {
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

.row {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-top: 12px;
}

.row .col {
  flex: 1;
}

.row > button { flex: 1; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

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

.btn-primary:hover { background: var(--primary-deep); }

.btn-secondary {
  background: var(--bg-soft);
  color: var(--text);
}

.btn-secondary:hover { background: var(--border); }

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  margin-top: 12px;
}

.btn-danger:hover { background: var(--danger); color: white; }

.btn-icon {
  background: transparent;
  border: none;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--text-soft);
  border-radius: 6px;
  font-size: 14px;
}

.btn-icon:hover { background: var(--bg-soft); color: var(--text); }

/* ============ Filter tabs ============ */
.filter-tabs {
  display: flex;
  gap: 6px;
  margin: 16px 0 12px;
  flex-wrap: wrap;
}

.filter-tab {
  background: var(--bg-soft);
  border: none;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-tab.active {
  background: var(--primary);
  color: white;
  font-weight: 500;
}

/* ============ Entry lists ============ */
.entry {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

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

.entry-title {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.entry-meta {
  font-size: 12px;
  color: var(--text-mute);
  display: flex;
  gap: 8px;
  align-items: center;
}

.entry-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.entry-body p { margin-bottom: 4px; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-soft);
  color: var(--text-soft);
}

.tag-parent { background: var(--accent-soft); color: #8c5f3a; }
.tag-teacher { background: var(--success-soft); color: #4a6850; }
.tag-therapist { background: var(--primary-soft); color: var(--primary-deep); }
.tag-active { background: var(--primary); color: white; }
.tag-review { background: var(--warn-soft); color: #7a5430; }
.tag-achieved { background: var(--success); color: white; }
.tag-week { background: var(--warn-soft); color: #7a5430; }

.empty {
  text-align: center;
  padding: 30px 16px;
  color: var(--text-mute);
  font-size: 14px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

/* ============ Tab bar ============ */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 0 calc(8px + var(--safe-bottom));
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.04);
}

.tab {
  flex: 1;
  background: none;
  border: none;
  padding: 6px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-mute);
  cursor: pointer;
  transition: color 0.15s;
}

.tab.active {
  color: var(--primary-deep);
}

.tab-icon {
  font-size: 20px;
}

.tab-label {
  font-size: 10px;
  font-weight: 500;
}

.tab.active .tab-label {
  font-weight: 600;
}

/* ============ Modal ============ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius);
  width: calc(100% - 40px);
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.2s ease;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: calc(100px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-deep);
  color: white;
  padding: 10px 18px;
  border-radius: 22px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  animation: toastIn 0.25s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============ Summary output ============ */
.summary-paper {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  font-family: -apple-system, "PingFang TC", sans-serif;
  color: #1a1a1a;
  line-height: 1.7;
}

.summary-paper h2 {
  font-size: 18px;
  text-align: center;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 8px;
  margin-bottom: 12px;
  color: var(--primary-deep);
}

.summary-paper h3 {
  font-size: 15px;
  margin-top: 14px;
  margin-bottom: 6px;
  color: var(--primary-deep);
  border-left: 3px solid var(--primary);
  padding-left: 8px;
}

.summary-paper ul {
  margin-left: 20px;
  margin-bottom: 6px;
}

.summary-paper li {
  margin-bottom: 3px;
  font-size: 14px;
}

.summary-paper p {
  font-size: 14px;
  margin-bottom: 6px;
}

.summary-bar {
  display: flex;
  height: 18px;
  border-radius: 9px;
  overflow: hidden;
  margin: 4px 0 10px;
  background: var(--bg-soft);
}

.summary-bar-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: white;
  font-weight: 600;
}

.bar-good { background: var(--success); }
.bar-ok { background: var(--warn); }
.bar-bad { background: var(--danger); }

@media print {
  body { background: white; }
  .tabbar, .app-header, .page-header, .btn, .filter-tabs { display: none !important; }
  #app { padding-bottom: 0; max-width: none; }
  .summary-paper { box-shadow: none; border: none; padding: 0; }
}

/* ============ Parsed book result ============ */
.parsed-section {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}

.parsed-section:last-child {
  border-bottom: none;
}

.parsed-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-deep);
  margin-bottom: 4px;
}

.parsed-section ul {
  margin-left: 18px;
  font-size: 14px;
}

.parsed-section li {
  margin-bottom: 2px;
}