:root {
  --bg: #f9f7f2;
  --fg: #433422;
  --muted: #8b7355;
  --accent: #6d5d4b;
  --card: #ffffff;
  --border: #e2ddd3;
  --tab-bg: #e2ddd3;
  --tab-active-bg: #433422;
  --tab-active-fg: #ffffff;
  --success: #5c8bc0;
  /* Empathy Soft Medical Blue */
  --warning: #d97706;
  --left-blue: #4a69bd;
  --right-orange: #f39c12;
  --vv-top: 0px;
  --vv-height: 100vh;
  --streak-muted: #8b7355;
  --streak-accent: #6d5d4b;
}

html.theme-1,
body.theme-1 {
  --bg: #b5b0a1;
  --fg: #333029;
  --card: #c7c2b2;
  --border: #9a9586;
  --tab-bg: #9a9586;
  --muted: #5a544a;
  --accent: #433e36;
}

html.theme-2,
body.theme-2 {
  --bg: #1c1c1e;
  --fg: #e5e5e7;
  --card: #2c2c2e;
  --border: #3a3a3c;
  --tab-bg: #3a3a3c;
  --muted: #8e8e8e;
  --accent: #d1d1d6;
  --tab-active-bg: #e5e5e7;
  --tab-active-fg: #1c1c1e;
}

html.font-size-0 {
  font-size: 90%;
}

html.font-size-1 {
  font-size: 100%;
}

html.font-size-2 {
  font-size: 110%;
}

html.font-size-3 {
  font-size: 120%;
}

html.font-size-4 {
  font-size: 130%;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    sans-serif;
  transition:
    background-color 0.3s,
    color 0.3s;
  scroll-behavior: smooth;
  min-height: 100vh;
}

button {
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
  padding: 0;
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px 8px 16px;
}

.row.admin {
  display: grid;
  grid-template-columns: 44px 120px 1fr;
  grid-template-areas: "actions thumb select" "title title title";
  gap: 8px 6px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.row.admin .admin-actions {
  grid-area: actions;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.row.admin .thumbbtn {
  grid-area: thumb;
}

.row.admin .side-selector {
  grid-area: select;
  display: flex;
  flex-direction: row;
  gap: 4px;
  align-items: center;
  justify-content: center;
}

.row.admin .title-area {
  grid-area: title;
  font-weight: 700;
  font-size: 14px;
  padding-top: 4px;
}

.dir-btn {
  width: 30px;
  height: 28px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 14px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.dir-btn.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.dir-btn svg {
  width: 18px;
  height: 18px;
}

.dir-badge {
  display: inline-block;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
}

.dir-badge.left {
  background: var(--left-blue);
}

.dir-badge.right {
  background: var(--right-orange);
}

.admin-panel {
  background: var(--card);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--border);
}

.admin-panel.is-hidden {
  display: none;
}

.admin-panel label {
  font-size: 12px;
  font-weight: bold;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-panel input {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 6px;
  color: var(--fg);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.search-container {
  overflow: hidden;
  height: 0;
  transition: height 0.3s ease-out;
}

.search-container.is-show {
  height: 44px;
  margin-bottom: 4px;
}

.toolbar input#searchBox {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 10px;
  border-radius: 10px;
}

.toolbar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.toolbar-row {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 44px;
}

.len-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-left: 4px;
  gap: 2px;
}

.len-info {
  font-size: 10px;
  font-weight: bold;
  color: var(--muted);
  text-align: left;
  line-height: 1.2;
  white-space: nowrap;
}

.len-info.recommend {
  color: var(--success);
}

.gauge-wrap {
  width: 50px;
  height: 3px;
  background: var(--tab-bg);
  border-radius: 2px;
  overflow: hidden;
}

.gauge-bar {
  height: 100%;
  width: 0%;
  transition: width 0.3s;
}

.gauge-blue {
  background-color: var(--success);
}

.gauge-yellow {
  background-color: #f59e0b;
}

.gauge-red {
  background-color: #ef4444;
}

.tab-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card);
  margin-top: -3px;
  margin-bottom: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  background: var(--tab-bg);
  color: var(--fg);
  padding: 8px 4px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 60px;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--tab-active-bg);
  color: var(--tab-active-fg);
}

.tab-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row.admin.hide-title .title-area {
  display: none;
}

.thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--fg);
  border-radius: 8px;
  transition: all 0.2s;
  font-weight: bold;
  font-size: 13px;
}

.btn-icon.active {
  background-color: #b5b0a1 !important;
  color: #333029 !important;
}

.btn-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

.btn-icon.copy-success {
  background: #b5b0a1;
  color: var(--fg);
  transition: background 0.1s;
}

.lang-menu {
  position: absolute;
  top: 42px;
  left: 48px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  z-index: 100;
  display: none;
  flex-direction: column;
  min-width: 80px;
  overflow: hidden;
}

.lang-menu.is-show {
  display: flex;
}

.lang-item {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: bold;
  color: var(--fg);
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.lang-item:hover {
  background: var(--bg);
}

.modal {
  position: fixed;
  left: 0;
  width: 100vw;
  display: none;
  z-index: 1000;
  top: var(--vv-top, 0);
  height: var(--vv-height, 100vh);
}

.modal[aria-hidden="false"] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal .overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
}

.modal .dialog {
  position: relative;
  width: 95vw;
  height: 90%;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal .iconbtn {
  position: absolute;
  top: 3px;
  left: 3px;
  z-index: 1010;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #ffffff;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  font-size: 20px;
  font-weight: bold;
}

#modalBody {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.modal img.qr-img {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
  background: white;
  padding: 20px;
}

.patient-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0 4px 16px 4px;
}

.patient-main-title {
  flex: 1;
  font-size: 1.125rem;
  font-weight: 800;
  margin: 0;
  color: var(--fg);
  padding-right: 12px;
}

.patient-actions {
  display: flex;
  gap: 4px;
}

.folder-tabs {
  display: flex;
  gap: 4px;
  padding: 0;
  margin-bottom: -1px;
  position: relative;
  z-index: 10;
}

.folder-tab {
  padding: 10px 16px;
  font-size: 0.8125rem;
  font-weight: 800;
  border-radius: 12px 12px 0 0;
  background: var(--tab-bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-bottom: none;
  opacity: 0.6;
  transition: all 0.2s;
}

.folder-tab.active {
  background: var(--card);
  opacity: 1;
  padding-top: 12px;
  margin-top: -2px;
  border-bottom: 2px solid var(--card);
}

.folder-panel {
  display: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0 16px 16px 16px;
  padding: 16px;
  min-height: 400px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  margin-top: 0;
}

.folder-panel.is-show {
  display: block;
  animation: fadeIn 0.3s;
}

.row.patient {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.row.patient:last-child {
  border-bottom: none;
}

.row.patient .meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.row.patient .title {
  font-weight: 700;
  font-size: 0.875rem;
  line-height: 1.4;
}

.row.patient .note {
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: pre-wrap;
  margin-top: 4px;
}

.expl-container {
  grid-column: 1 / -1;
  margin-top: 8px;
}

.btn-expl {
  font-size: 0.75rem;
  font-weight: bold;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 8px 16px;
  background: var(--card);
}

.expl-content {
  display: none;
  background: var(--bg);
  border-radius: 12px;
  padding: 16px;
  margin-top: 8px;
  font-size: 0.875rem;
  line-height: 1.7;
  white-space: pre-wrap;
  border: 1px solid var(--border);
}

.expl-content.is-show {
  display: block;
  animation: fadeIn 0.3s;
}

.faq-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.faq-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.faq-cat-btn {
  padding: 8px 4px;
  font-size: 0.75rem;
  font-weight: 800;
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  opacity: 0.6;
}

.faq-cat-btn.active {
  opacity: 1;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.faq-group {
  display: none;
  flex-direction: column;
  gap: 8px;
}

.faq-group.is-show {
  display: flex;
  animation: fadeIn 0.3s;
}

.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
}

.faq-item:last-child {
  border-bottom: none;
}

.faq-q {
  padding: 12px 0;
  font-weight: 700;
  font-size: 0.875rem;
  line-height: 1.4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.faq-icon::after {
  content: "＋";
  font-size: 1rem;
  color: var(--muted);
}

.faq-item.active .faq-icon::after {
  content: "－";
}

.faq-a {
  max-height: 0;
  overflow: hidden;
  transition:
    max-height 0.25s ease-in-out,
    opacity 0.2s ease-in-out;
  opacity: 0;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--muted);
}

.faq-item.active .faq-a {
  max-height: 500px;
  opacity: 1;
}

.faq-a-inner {
  padding: 8px 0 16px 0;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Record Tab: Mini Calendar & Tiles v6.3 --- */
.mini-cal-card,
.tile-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 16px;
}

.mini-cal-card {
  max-width: 100%;
}

.mini-cal-head {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.mini-cal-month {
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--fg);
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.month-text {
  display: inline-block;
}

/* Streak placeholders (reserved slots for future implementation) */
.streak-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  padding: 0;
  line-height: 1;
  font-weight: 900;
  font-size: 0.85rem;
  background: transparent;
}

.theme-2 .streak-badge {
  background: transparent !important;
}

.streak-placeholder {
  opacity: 0.45;
}

.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.mini-cal-week {
  margin-bottom: 8px;
}

.mini-cal-wd {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 800;
  opacity: 0.8;
}

.mini-cal-cell {
  height: 42px;
  border: none;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: background 0.2s;
}

.mini-cal-cell.empty {
  opacity: 0;
  pointer-events: none;
}

.mini-cal-cell.is-today {
  background: rgba(0, 0, 0, 0.08);
}

.theme-2 .mini-cal-cell.is-today {
  background: rgba(255, 255, 255, 0.15);
}

.mini-cal-date {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--fg);
  line-height: 1;
}

.mini-cal-dots {
  height: 6px;
  margin-top: 4px;
  display: flex;
  align-items: center;
}

.mini-cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--success);
}

.past-tiles-section {
  margin-bottom: 16px;
}

.past-tiles-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 8px;
}

.btn-tiles-toggle {
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--card);
}

.btn-tiles-toggle:active {
  transform: scale(0.98);
}

.past-tiles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.tile-card {
  margin-bottom: 0;
  padding: 10px;
}

.tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 900;
  font-size: 0.85rem;
  color: var(--fg);
  letter-spacing: 0.04em;
}

.tile-month {
  display: inline-block;
}

.tile-streak {
  min-width: 52px;
}

.tile-body {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: flex-start;
}

.tile-cell {
  width: calc((100% - 18px) / 7);
  aspect-ratio: 1 / 1;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.05);
}

.theme-2 .tile-cell {
  background: rgba(255, 255, 255, 0.1);
}

.tile-cell.is-done {
  background: var(--success);
}

.tile-cell.is-void {
  opacity: 0;
  pointer-events: none;
}

.complete-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px;
  margin: 12px 0 16px;
  border-radius: 14px;
  background: var(--card);
  border: none;
}

.complete-metrics {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: 1 1 auto;
  min-width: 220px;
}

/* Step4: Streak ring badges (borderless, stable) */
.streak-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-width: 84px;
}

.streak-ring {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  position: relative;
  background: var(--streak-muted);
}

.streak-ring::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 999px;
  background: var(--card);
}

.streak-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.streak-num {
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1;
  color: var(--streak-accent);
}

.streak-unit {
  margin-top: 2px;
  font-size: 0.55rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--streak-accent);
}

.streak-caption {
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--streak-accent);
  white-space: pre-wrap;
  line-height: 1.2;
  text-align: center;
}

.metric-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  border-radius: 12px;
  background: transparent;
}

.metric-value {
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1;
  color: var(--fg);
}

.metric-unit {
  font-size: 0.75rem;
  font-weight: 900;
  margin-left: 4px;
  color: var(--muted);
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--muted);
  margin-top: 4px;
  white-space: nowrap;
}

.guide-note {
  font-size: 0.875rem;
  color: var(--muted);
  padding: 8px;
}

@media (max-width: 420px) {
  .mini-cal-grid {
    gap: 4px;
  }

  .mini-cal-cell {
    height: 38px;
  }
}

/* Step4.1: "Complete today's training" check-row button */
.complete-check {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 12px 14px;
  border: none;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--fg);
  font-weight: 800;
  text-align: left;
}

.complete-check .check-box {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.07);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.complete-check .check-icon {
  width: 18px;
  height: 18px;
  opacity: 0;
  transform: scale(0.7);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.complete-check.is-done .check-icon {
  opacity: 1;
  transform: scale(1);
}

.complete-check .check-text {
  flex: 1 1 auto;
  line-height: 1.25;
}

.complete-check:active {
  transform: translateY(1px);
}

/* Completion feedback */
.complete-check.done {
  box-shadow: 0 0 0 2px var(--success) inset;
  animation: completeCheckPulse 0.6s;
}

@keyframes completeCheckPulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(0.99);
  }

  100% {
    transform: scale(1);
  }
}

/* --- Step4.3: fixes & theme-tuned colors (safe overrides) --- */

/* 1) Legacy Done button removed (completion uses the check-style control) */
/* 2) Prevent past tiles grid from overflowing the card on small screens */
.past-tiles-section,
.past-tiles-wrap,
.past-tiles-grid {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.past-tiles-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.past-tile-card {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* The 31-cell mini heatmap should shrink within the card */
.tile-grid,
.tile-grid-row,
.tile-grid-cell {
  box-sizing: border-box;
}

/* 3) Streak badge: remove any backplate in all themes (especially theme-2) */
.streak-badge {
  background: transparent !important;
}

/* 4) Theme-tuned streak colors (ring + star bubble vs text) */
:root {
  --streak-ring: var(--muted);
  --streak-text: var(--accent);
  --complete-check-bg: rgba(0, 0, 0, 0.04);
  --complete-check-fg: var(--accent);
  --streak-gray: #d1d5db;
  /* Default pending gray */
}

.theme-0,
.theme-0 body {
  --streak-ring: #8b7355;
  --streak-text: #6d5d4b;
  --complete-check-bg: rgba(0, 0, 0, 0.04);
  --complete-check-fg: #6d5d4b;
  --streak-gray: #d1d5db;
}

.theme-1,
.theme-1 body {
  /* slightly higher contrast */
  --streak-ring: #9b856a;
  --streak-text: #7a6751;
  --complete-check-bg: rgba(0, 0, 0, 0.05);
  --complete-check-fg: #7a6751;
  --streak-gray: #9ca3af;
}

.theme-2,
.theme-2 body {
  /* dark (moon): lighter tones for visibility */
  --streak-ring: #cbb89d;
  --streak-text: #e7dccb;
  --complete-check-bg: rgba(255, 255, 255, 0.1);
  /* brighter than before */
  --complete-check-fg: #f2eadc;
  --streak-gray: #3a3a3c;
}

/* Apply streak theme variables */
.streak-ring {
  border-color: var(--streak-ring) !important;
}

.streak-star {
  background: var(--streak-ring) !important;
  color: #fff !important;
}

.streak-caption,
.streak-unit {
  color: var(--streak-text) !important;
}

.streak-num {
  color: var(--streak-text) !important;
}

/* Pending State Style for Streak Ring */
.streak-ring.is-pending {
  background: var(--streak-gray) !important;
  opacity: 0.8;
}

.streak-ring.is-pending .streak-num,
.streak-ring.is-pending .streak-unit {
  color: var(--streak-gray) !important;
  opacity: 0.8;
}

/* Completion check control */
.complete-check {
  background: var(--complete-check-bg) !important;
  color: var(--complete-check-fg) !important;
}

.complete-check .check-box {
  background: rgba(255, 255, 255, 0.35);
}

.theme-2 .complete-check .check-box {
  background: rgba(255, 255, 255, 0.18);
}

/* --- Step4.4: improve checkbox visibility in theme-0 (sun) --- */
.complete-check .check-box {
  border: 2px solid rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.1);
}

.theme-0 .complete-check .check-box,
.theme-0 body .complete-check .check-box {
  border-color: rgba(109, 93, 75, 0.35);
  /* accent-ish border */
  background: rgba(109, 93, 75, 0.12);
  /* slightly stronger fill */
}

/* --- Admin History Section --- */
.history-area {
  margin-top: 32px;
  border-top: 2px dashed var(--border);
  padding-top: 16px;
}

.history-title {
  font-weight: 800;
  font-size: 14px;
  margin: 0 0 12px 4px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Icon Size Fix */
.history-title svg {
  width: 18px;
  height: 18px;
}

.history-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.history-info {
  overflow: hidden;
}

.history-meta {
  font-size: 10px;
  color: var(--muted);
  font-weight: bold;
}

.history-name {
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Fix: streak badges centered (mobile & desktop) --- */
.complete-metrics {
  width: 100%;
  justify-content: center;
}

/* --- Backup Accordion Styles --- */
.backup-section {
  width: 100%;
}

.backup-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--muted);
  /* 控えめな色 */
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.backup-toggle-btn.active {
  background: rgba(0, 0, 0, 0.03);
  border-radius: 12px 12px 0 0;
  border-bottom-color: transparent;
  color: var(--fg);
  /* 開いたら少し強調 */
}

.backup-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.backup-icon {
  display: flex;
  align-items: center;
}

.backup-subtitle {
  font-size: 0.75rem;
  opacity: 0.8;
  font-weight: normal;
}

.toggle-icon {
  font-size: 0.75rem;
  transition: transform 0.3s;
}

.backup-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  border: 1px solid transparent;
  /* 変更: ここを transparent（透明）にする */
  border-top: none;
  border-radius: 0 0 12px 12px;
  background: var(--card);
  opacity: 0.6;
}

.backup-content.is-open {
  opacity: 1;
  border-color: var(--border);
  /* 追加: 開いた時だけ枠線に色をつける */
}

.backup-inner {
  padding: 16px;
  padding-top: 4px;
}

.admin-settings-panel {
  min-height: 72px;
  justify-content: center;
}

.admin-settings-placeholder {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  padding: 12px 8px;
}

/* --- Admin Tools Panel --- */
.admin-tools-section {
  width: 100%;
  margin-top: 12px;
}

.admin-tools-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-tools-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-tools-input-label {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--muted);
}

.admin-tools-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--fg);
  font-size: 0.95rem;
}

.admin-tools-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0 4px;
}

.admin-tools-label {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--muted);
}

.admin-tools-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
}

.admin-tools-status.is-off {
  color: var(--muted);
  background: rgba(0, 0, 0, 0.03);
}

.admin-tools-status.is-on {
  color: #fff;
  background: var(--success);
  border-color: var(--success);
}

.admin-tools-btn {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--fg);
  font-size: 0.95rem;
  font-weight: 800;
  text-align: center;
  transition: all 0.2s;
}

.admin-tools-btn.is-primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.admin-tools-btn.is-danger {
  background: rgba(217, 119, 6, 0.12);
  color: var(--fg);
  border-color: rgba(217, 119, 6, 0.35);
}

.admin-tools-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.update-notice-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin: 0 0 12px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);

  /* ===== Footer hidden build display ===== */
  footer.container.muted.small {
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  footer.container.muted.small.is-build-visible {
    white-space: normal;
    line-height: 1.6;
  }
}

.update-notice-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.5;
}

.update-notice-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.update-notice-btn {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  font-size: 0.875rem;
  font-weight: 700;
}

.update-notice-btn.primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

#adminUpdateNoticeMount,
#patientUpdateNoticeMount {
  margin-bottom: 8px;
}

#patientUpdateNoticeMount {
  padding: 0 4px 4px 4px;
}

@media (max-width: 640px) {
  .update-notice-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .update-notice-actions {
    width: 100%;
  }

  .update-notice-btn {
    flex: 1 1 auto;
    text-align: center;
  }
}

/* === 患者画面：長押し時のテキスト選択 / Google検索を抑止 === */
.patient-header,
.folder-tabs,
.folder-tab,
.folder-panel,
.row.patient,
.row.patient .meta,
.row.patient .title,
.row.patient .note,
.expl-container,
.btn-expl,
.expl-content,
.faq-container,
.faq-nav,
.faq-cat-btn,
.faq-group,
.faq-item,
.faq-q,
.faq-a,
.faq-a-inner,
.mini-cal-card,
.mini-cal-head,
.mini-cal-month,
.mini-cal-grid,
.mini-cal-cell,
.mini-cal-date,
.guide-note,
.complete-bar,
.complete-metrics,
.streak-badge,
.streak-caption,
.metric-block,
.metric-label,
.metric-value,
.metric-unit,
.past-tiles-section,
.past-tiles-toolbar,
.tile-card,
.tile-head,
.tile-month {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.folder-tab,
.faq-q,
.btn-expl,
.btn-tiles-toggle,
.complete-check {
  -webkit-tap-highlight-color: transparent;
}

/* 患者画面の動画サムネイル長押し対策 */
.row.patient .thumb,
.row.patient .thumbbtn img {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: transparent;
}
