/* --- Log screen --- */

body.wt-demo-mode #screen-log .log-card input,
body.wt-demo-mode #screen-log .log-card select,
body.wt-demo-mode #screen-log .log-card .chip,
body.wt-demo-mode #screen-log .reading-input-area,
body.wt-demo-mode #screen-log .send-btn,
body.wt-demo-mode #screen-log #meds-toggle {
  pointer-events: none;
  opacity: 0.72;
}

/* --- Card base --- */

.log-card {
  background: var(--bg-surface);
  border: 0.5px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  padding: 0;
  margin-bottom: 12px;
  transition: opacity 0.2s;
}

/* --- Card header --- */

.log-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.log-card--reading .log-card-header {
  background: rgba(0, 200, 150, 0.04);
}

.log-card--meal .log-card-header {
  background: rgba(93, 202, 165, 0.04);
}

.log-card:not(.collapsed) .log-card-header {
  border-bottom: 0.5px solid var(--border);
}

.log-card-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --- Icon container --- */

.log-card-icon-wrap {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.log-card-icon-wrap--reading {
  background: rgba(0, 200, 150, 0.1);
  border: 0.5px solid rgba(0, 200, 150, 0.18);
}

.log-card-icon-wrap--meal {
  background: rgba(93, 202, 165, 0.08);
  border: 0.5px solid rgba(93, 202, 165, 0.15);
}

/* --- Card type label --- */

.log-card-type-label {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
}

.log-card-type-label--reading {
  color: #00C896;
}

.log-card-type-label--meal {
  color: #5DCAA5;
}


/* --- Collapse / expand state --- */

.log-card.collapsed {
  opacity: 0.55;
  cursor: pointer;
}

.log-card.collapsed .log-card-header {
  border-bottom: none;
}

.log-card.collapsed .log-card-body {
  display: none;
}

.log-card-body {
  padding: 14px 16px 16px;
}

/* --- Timestamp row --- */

.ts-row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 8px;
  margin-bottom: 12px;
  width: 100%;
}

.ts-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background: var(--bg-raised);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--text-primary);
  min-height: 34px;
  -webkit-appearance: none;
  appearance: none;
}

.ts-input:focus {
  border: 0.5px solid var(--accent);
}

.ts-date { width: 100%; }
.ts-time { width: 100%; }

.ts-input::-webkit-calendar-picker-indicator {
  display: none;
  -webkit-appearance: none;
}

.ts-input::-webkit-clear-button,
.ts-input::-webkit-inner-spin-button,
.ts-input::-webkit-outer-spin-button {
  display: none;
  -webkit-appearance: none;
}

.ts-input::-webkit-date-and-time-value {
  text-align: center;
}

/* --- Reading input area --- */

.reading-input-area {
  position: relative;
  padding: 12px 0;
  margin-bottom: 0;
  cursor: text;
}

.reading-value-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.reading-display {
  font-family: 'DM Mono', monospace;
  font-size: 52px;
  font-weight: 700;
  color: var(--text-secondary);
  line-height: 1.1;
  min-height: 57px;
}

.reading-unit {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.2;
}

.reading-hidden-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  font-size: 52px;
  caret-color: transparent;
  appearance: textfield;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

/* Thin horizontal rule below unit */
.reading-underline {
  width: 48px;
  height: 1px;
  background: var(--border);
  margin: 10px auto 12px;
  opacity: 0.5;
}

/* Custom blinking cursor */
.reading-display.has-focus::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 44px;
  background: var(--accent);
  margin-left: 4px;
  vertical-align: middle;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* --- Chip row --- */

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--bg-raised);
  border: 0.5px solid var(--border);
  color: var(--text-muted);
  transition: all 0.15s;
  white-space: nowrap;
}

/* Reading card chips — green */
.log-card--reading .chip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Meal card chips — teal */
.log-card--meal .chip.active {
  background: rgba(93, 202, 165, 0.08);
  border-color: #5DCAA5;
  color: #5DCAA5;
}

/* --- Meal field label --- */

.meal-field-label {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  margin-bottom: 5px;
}

/* --- Meal link --- */

.meal-link-section {
  margin-bottom: 12px;
}

.field-label {
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.meal-link-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.meal-chip {
  flex-shrink: 0;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--bg-raised);
  border: 0.5px solid var(--border);
  color: var(--text-muted);
  transition: all 0.15s;
  white-space: nowrap;
  cursor: pointer;
}

.meal-chip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Meal textarea --- */

.meal-textarea {
  width: 100%;
  min-height: 72px;
  resize: none;
  background: var(--bg-raised);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 12px;
  transition: border-color 0.15s;
}
.meal-textarea::placeholder { color: var(--text-muted); }
.meal-textarea:focus { border-color: #5DCAA5; }

/* --- Meal divider --- */

.meal-divider {
  height: 0;
  border-top: 0.5px solid var(--border);
  margin-bottom: 12px;
}

/* --- Meds toggle --- */

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

.meds-label {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 13px;
  color: var(--text-secondary);
}

.toggle {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: var(--bg-raised);
  border: 0.5px solid var(--border);
  padding: 0;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  border: 0.5px solid var(--border);
  transition: transform 0.2s, background 0.2s, border-color 0.2s;
}

.toggle.on {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle.on .toggle-thumb {
  transform: translateX(14px);
  background: #0A0A0A;
  border-color: transparent;
}

.meds-hint {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* --- Send button --- */

.send-btn {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  background: var(--accent);
  color: #0A0A0A;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-top: 8px;
  transition: opacity 0.15s;
}

.send-btn--reading {
  background: #00C896;
  color: #0A0A0A;
}

.send-btn--meal {
  background: #0F6E56;
  color: #9FE1CB;
}

.send-btn:disabled {
  background: var(--bg-raised);
  color: var(--text-muted);
}

/* --- Last signal indicator --- */

.last-signal {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
  margin-bottom: 8px;
}

/* --- Toast --- */

.toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 54px);
  left: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 0.5px solid var(--accent);
  border-radius: 10px;
  padding: 10px 14px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px);
  transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s;
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.toast.error { border-color: var(--reading-red); }

.toast-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  flex-shrink: 0;
}

.toast.error .toast-dot {
  background: var(--reading-red);
  box-shadow: 0 0 8px rgba(226, 75, 74, 0.25);
}

.toast-text {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text-primary);
}

/* --- Reading colour states --- */
.reading-display.green { color: var(--reading-green); }
.reading-display.amber { color: var(--reading-amber); }
.reading-display.red   { color: var(--reading-red); }

/* --- Range indicator --- */

.range-indicator {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--bg-raised);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.range-pill {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 20px;
  transition: background 0.15s, box-shadow 0.15s;
}

.range-pill.green {
  background: var(--reading-green-bg);
  color: var(--reading-green);
  border: 0.5px solid var(--reading-green);
}
.range-pill.amber {
  background: var(--reading-amber-bg);
  color: var(--reading-amber);
  border: 0.5px solid var(--reading-amber);
}
.range-pill.red {
  background: var(--reading-red-bg);
  color: var(--reading-red);
  border: 0.5px solid var(--reading-red);
}

.range-pill.green.active-range {
  background: rgba(0, 200, 150, 0.2);
  box-shadow: 0 0 6px rgba(0, 200, 150, 0.25);
}
.range-pill.amber.active-range {
  background: rgba(245, 166, 35, 0.2);
  box-shadow: 0 0 6px rgba(245, 166, 35, 0.25);
}
.range-pill.red.active-range {
  background: rgba(226, 75, 74, 0.2);
  box-shadow: 0 0 6px rgba(226, 75, 74, 0.25);
}

:root.light .range-pill.green.active-range {
  background: rgba(10, 143, 104, 0.2);
  box-shadow: 0 0 6px rgba(10, 143, 104, 0.2);
}
:root.light .range-pill.amber.active-range {
  background: rgba(196, 127, 0, 0.2);
  box-shadow: 0 0 6px rgba(196, 127, 0, 0.2);
}
:root.light .range-pill.red.active-range {
  background: rgba(192, 57, 43, 0.2);
  box-shadow: 0 0 6px rgba(192, 57, 43, 0.2);
}
