/* Redesigned Structured Reminder Studio Styles (aligned with global theme & font scaling tokens) */
.rem-shell {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: clamp(0.85rem, 2.2vw, 1.35rem) clamp(0.75rem, 2.4vw, 1.45rem) calc(2rem + env(safe-area-inset-bottom, 0px));
  background: var(--bg-base);
  container: rem / inline-size;
}

.rem-container {
  max-width: 82rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.rem-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.rem-title-wrap h2 {
  font-size: 1.24rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 3px;
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rem-subtitle {
  font-size: 0.84rem;
  color: var(--text-dim);
}

.rem-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rem-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
}

.rem-status-chip.ready {
  border-color: rgba(52, 211, 153, 0.36);
  background: var(--success-soft);
  color: var(--success);
}

.rem-wechat-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  padding: var(--pad-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-card);
}

.rem-wechat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.rem-wechat-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.55;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 11px;
}

/* Two-Column Workspace */
.rem-workspace {
  display: grid;
  grid-template-columns: minmax(min(100%, 20.5rem), 26.5rem) minmax(0, 1fr);
  gap: 1.125rem;
  align-items: start;
}

/* Left Structured Form Composer / Editor Card */
.rem-mobile-compose-toggle {
  display: none;
}

.rem-compose {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  position: sticky;
  top: 0;
}

.rem-compose.editing-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-soft);
}

.rem-compose-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.rem-compose-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
}

.rem-form-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border);
}

.rem-form-section:last-of-type {
  padding-bottom: 0;
  border-bottom: none;
}

.rem-section-kicker {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rem-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rem-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.rem-input,
.rem-textarea,
.rem-dt-input,
.rem-select,
.rem-num-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 6px 10px;
  font-size: 0.86rem;
  outline: none;
  color-scheme: var(--color-scheme, dark);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.rem-input {
  min-height: 35px;
  font-weight: 500;
}

.rem-textarea {
  min-height: 54px;
  resize: vertical;
  line-height: var(--ui-line-height, 1.5);
}

.rem-dt-input,
.rem-select,
.rem-num-input {
  min-height: 33px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.rem-raw-dt {
  font-size: 0.76rem;
  color: var(--text-dim);
}
.rem-raw-dt summary {
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
}
.rem-raw-dt[open] summary {
  margin-bottom: 5px;
  color: var(--text-muted);
}

.rem-input:focus,
.rem-textarea:focus,
.rem-dt-input:focus,
.rem-select:focus,
.rem-num-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.rem-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

/* Priority Segmented Control */
.rem-prio-group {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.rem-prio-btn {
  min-height: 34px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: border-color 0.14s ease, background-color 0.14s ease, color 0.14s ease;
}

.rem-prio-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-main);
}

.rem-prio-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rem-prio-btn.active {
  background: var(--bg-elevated);
  color: var(--text-main);
  border-color: var(--primary);
}

/* Custom Time Grid (Date + Hour + Min) */
.rem-time-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.75fr) minmax(0, 0.75fr);
  gap: 6px;
}

.rem-rel-box {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.rem-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.rem-preset-btn,
.rem-chip-btn {
  min-height: 31px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: border-color 0.14s ease, color 0.14s ease, background-color 0.14s ease;
}

.rem-preset-btn:hover,
.rem-chip-btn:hover {
  border-color: var(--border-hover);
  background: var(--bg-subtle);
  color: var(--text-main);
}

.rem-chip-btn.active {
  background: var(--text-main);
  border-color: var(--text-main);
  color: var(--bg-base);
}

.rem-schedule-preview {
  padding: 9px 11px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.rem-schedule-preview strong {
  color: var(--primary-ink);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.rem-submit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
}

/* Right Feed Column */
.rem-feed-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.rem-stats-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.rem-mini-stat {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.rem-mini-stat .k {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 600;
}

.rem-mini-stat .v {
  font-family: var(--font-mono);
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.rem-toolbar {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.rem-toolbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.rem-view-tabs {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}

.rem-search-input {
  flex: 1 1 180px;
  max-width: 280px;
  min-height: 33px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 0.82rem;
  outline: none;
}

.rem-search-input:focus {
  border-color: var(--primary);
}

.rem-cat-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.rem-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-dim);
  padding: 2px;
}

.rem-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.rem-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: inset 3px 0 0 var(--border-hover);
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.rem-item.prio-high {
  box-shadow: inset 3px 0 0 var(--warning);
}

.rem-item.prio-urgent {
  box-shadow: inset 3px 0 0 var(--danger);
}

.rem-item.prio-low {
  box-shadow: inset 3px 0 0 var(--text-dim);
}

.rem-item.is-editing {
  border-color: var(--primary);
  background: var(--bg-elevated);
}

.rem-item:hover {
  border-color: var(--border-hover);
}

.rem-item.overdue {
  border-color: rgba(251, 191, 36, 0.45);
}

.rem-item.done {
  opacity: 0.62;
  box-shadow: inset 3px 0 0 var(--success);
}

.rem-item-left {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  flex: 1 1 auto;
  min-width: 0;
}

.rem-check {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border-radius: 50%;
  border: 2px solid var(--border-hover);
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--on-primary);
  padding: 0;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.rem-check:hover {
  border-color: var(--primary);
}

.rem-check.checked {
  background: var(--success);
  border-color: var(--success);
  color: #ffffff;
}

.rem-item-body {
  flex: 1 1 auto;
  min-width: 0;
}

.rem-item-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-word;
  line-height: var(--ui-line-height, 1.5);
}

.rem-item.done .rem-item-title {
  text-decoration: line-through;
  color: var(--text-dim);
}

.rem-item-note {
  margin-top: 5px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 0.84rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: var(--ui-line-height, 1.5);
}

.rem-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-dim);
}

.rem-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
}

.rem-badge.due-soon {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary-ink);
}

.rem-badge.overdue {
  background: var(--warning-soft);
  border-color: rgba(251, 191, 36, 0.38);
  color: var(--warning);
}

.rem-badge.err {
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.40);
  color: var(--danger);
}

.rem-badge.urgent {
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.38);
  color: var(--danger);
}

.rem-item-ops {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}

.rem-item-op-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.rem-empty {
  text-align: center;
  padding: 32px 18px;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border);
  background: var(--bg-surface);
  color: var(--text-dim);
  font-size: 0.88rem;
}

@container rem (inline-size < 58rem) {
  .rem-workspace {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .rem-mobile-compose-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }
  .rem-compose {
    position: static;
    display: none;
  }
  .rem-compose.mobile-open,
  .rem-compose.editing-active {
    display: flex;
  }
}

@media (max-width: 1060px) {
  .rem-workspace {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .rem-mobile-compose-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }
  .rem-compose {
    position: static;
    display: none;
  }
  .rem-compose.mobile-open,
  .rem-compose.editing-active {
    display: flex;
  }
}

@container rem (inline-size < 38rem) {
  .rem-stats-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.375rem;
  }
  .rem-mini-stat {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.125rem;
    padding: 0.5rem 0.625rem;
  }
  .rem-item {
    flex-direction: column;
    gap: 0.625rem;
  }
  .rem-item-ops {
    width: 100%;
    flex-direction: row;
    justify-content: flex-end;
  }
  .rem-two-col {
    grid-template-columns: 1fr;
  }
  .rem-time-grid {
    grid-template-columns: 1fr 1fr;
  }
  .rem-time-grid .rem-dt-date-wrap {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .rem-shell {
    padding: 14px 12px calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .rem-compose {
    padding: 13px;
  }
  .rem-stats-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .rem-mini-stat {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 8px 10px;
  }
  .rem-item {
    flex-direction: column;
    gap: 10px;
  }
  .rem-item-ops {
    width: 100%;
    flex-direction: row;
    justify-content: flex-end;
  }
  .rem-two-col {
    grid-template-columns: 1fr;
  }
  .rem-time-grid {
    grid-template-columns: 1fr 1fr;
  }
  .rem-time-grid .rem-dt-date-wrap {
    grid-column: 1 / -1;
  }
}
