:root {
  --bg: #0c0e14;
  --bg-elevated: #12151d;
  --surface: #181c26;
  --surface-hover: #1e2330;
  --input-bg: #11141c;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #f4f5f7;
  --text-muted: #7d8596;
  --text-dim: #555d6d;
  --primary: #e4002b;
  --primary-soft: rgba(228, 0, 43, 0.14);
  --primary-glow: rgba(228, 0, 43, 0.35);
  --success: #2ecc87;
  --success-soft: rgba(46, 204, 135, 0.12);
  --error: #ff5a67;
  --error-soft: rgba(255, 90, 103, 0.12);
  --warning: #f5a623;
  --warning-soft: rgba(245, 166, 35, 0.12);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 20px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.25);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --bottom-bar-h: calc(82px + var(--safe-bottom));
  --summary-h: 0px;
  --dock-gap: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
  background-color: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background-color: var(--bg);
  overscroll-behavior: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 120% 80% at 50% -30%, rgba(228, 0, 43, 0.07), transparent 55%),
    radial-gradient(ellipse 80% 50% at 100% 100%, rgba(30, 35, 48, 0.5), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  background: transparent;
}

/* ── Header ── */

.header {
  position: relative;
  flex-shrink: 0;
}

.header-accent {
  height: 3px;
  background: linear-gradient(90deg, #a8001f 0%, var(--primary) 50%, #ff4d6d 100%);
}

.header-inner {
  padding: 16px 16px 12px;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.logo-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(145deg, #ff1a3d 0%, #b8001f 100%);
  box-shadow: 0 4px 16px var(--primary-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-num {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

.header-titles h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.2;
}

.subtitle {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Profile card ── */

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.profile-main {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2a3140 0%, #1a1f2b 100%);
  border: 1.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  letter-spacing: -0.3px;
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.profile-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.profile-name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.2px;
}

.profile-job {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.35;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.status-pill.online {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(46, 204, 135, 0.2);
}

.status-pill.offline {
  background: var(--error-soft);
  color: var(--error);
  border-color: rgba(255, 90, 103, 0.2);
}

.status-pill__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.work-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.work-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.work-title {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.work-values {
  font-size: 14px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.work-values strong {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.work-sep {
  margin: 0 3px;
  opacity: 0.4;
}

.progress-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #c40024, var(--primary));
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 0;
}

.progress-fill.over {
  background: linear-gradient(90deg, var(--warning), #ff6b35);
}

.work-over {
  margin-left: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--warning);
}

.work-last {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--text-dim);
}

.btn-briefings {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(46, 204, 135, 0.35);
  border-radius: var(--radius-sm);
  background: var(--success-soft);
  color: var(--success);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-briefings:active {
  transform: scale(0.98);
}

.btn-briefings__count {
  min-width: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(46, 204, 135, 0.18);
  font-size: 12px;
  line-height: 1.2;
}

.modal-note {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* ── Session banner ── */

.session-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 16px 8px;
  max-width: 488px;
  margin-left: auto;
  margin-right: auto;
  padding: 12px 14px;
  background: var(--error-soft);
  border: 1px solid rgba(255, 90, 103, 0.3);
  border-radius: var(--radius);
  animation: slideUp 0.3s ease;
}

.session-banner[hidden] {
  display: none !important;
}

.session-banner__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  color: var(--error);
}

.session-banner__text strong {
  font-size: 14px;
}

.btn-banner {
  flex-shrink: 0;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 90, 103, 0.2);
  color: var(--error);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

/* ── Content ── */

.content {
  flex: 1;
  padding: 4px 16px calc(var(--bottom-bar-h) + 16px);
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  transition: padding-bottom 0.25s ease;
}

.app.has-summary .content {
  padding-bottom: calc(var(--bottom-bar-h) + var(--summary-h) + var(--dock-gap) + 16px);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 2px 12px;
  gap: 8px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-text {
  border: none;
  background: none;
  color: #ff6b82;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  padding: 4px 0;
  cursor: pointer;
  white-space: nowrap;
}

.btn-text:active {
  opacity: 0.7;
}

.section-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.section-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 10px;
  border-radius: 20px;
  font-variant-numeric: tabular-nums;
}

.remarks-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Remark cards ── */

.remark-wrap {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
}

.remark-swipe-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 20px;
  background: var(--error);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.remark-wrap:has(.remark-card--swiping) .remark-swipe-hint {
  opacity: 1;
}

.remark-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, transform 0.15s ease-out;
}

.remark-card:focus-within {
  border-color: rgba(228, 0, 43, 0.25);
}

.remark-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.remark-card__left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.remark-num {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: #ff6b82;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.remark-card__title {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.remark-card__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.remark-card__body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field-input,
.field-select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 16px;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field-select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%237d8596' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.field-input:focus,
.field-select:focus {
  outline: none;
  border-color: rgba(228, 0, 43, 0.45);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.field-input.invalid,
.field-select.invalid {
  border-color: rgba(255, 90, 103, 0.5);
  box-shadow: 0 0 0 3px var(--error-soft);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.field-row .field-input {
  text-align: center;
  padding: 0 6px;
  font-variant-numeric: tabular-nums;
}

/* Status badges */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-pending {
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
}

.badge-sending {
  color: var(--warning);
  background: var(--warning-soft);
}

.badge-ok {
  color: var(--success);
  background: var(--success-soft);
}

.badge-error {
  color: var(--error);
  background: var(--error-soft);
}

.btn-remove {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.btn-remove svg {
  width: 16px;
  height: 16px;
}

.btn-remove:active {
  background: var(--error-soft);
  color: var(--error);
}

.btn-icon-sm {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-icon-sm svg {
  width: 15px;
  height: 15px;
}

.btn-icon-sm:active {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

/* ── Confirm modal ── */

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--safe-top) var(--safe-right) calc(var(--safe-bottom) + 8px) var(--safe-left);
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 75dvh;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 16px 16px;
  box-shadow: var(--shadow);
  animation: sheetUp 0.3s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-title {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
}

.confirm-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.confirm-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-muted);
}

.confirm-list li:last-child {
  border-bottom: none;
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.btn-block {
  flex: 1;
}

/* ── History ── */

.history-panel {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.history-panel summary {
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
}

.history-panel summary::-webkit-details-marker {
  display: none;
}

.history-list {
  padding: 0 14px 12px;
  border-top: 1px solid var(--border);
}

.history-empty {
  margin: 12px 0;
  font-size: 13px;
  color: var(--text-dim);
}

.history-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.history-item:last-child {
  border-bottom: none;
}

.history-item__head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.history-item__stat {
  font-weight: 700;
  color: var(--text);
}

.history-item__list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12px;
  line-height: 1.45;
}

.history-item__list li {
  padding: 2px 0;
  color: var(--text-dim);
}

.history-item__list li.ok {
  color: var(--success);
}

.history-item__list li.fail {
  color: var(--error);
}

/* ── Bottom bar ── */

.bottom-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: var(--dock-gap);
  padding: 0 16px calc(12px + var(--safe-bottom));
  pointer-events: none;
  background: linear-gradient(to top, var(--bg) 45%, transparent);
}

.bottom-bar {
  pointer-events: auto;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  padding: 10px;
  background: rgba(18, 21, 29, 0.92);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 50px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.15s;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary {
  flex: 1;
  padding: 0 16px;
  background: linear-gradient(180deg, #ff1a3d 0%, #c40024 100%);
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-ghost {
  flex: 0 0 auto;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-icon {
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  opacity: 0.8;
}

/* ── Summary & overlay ── */

.summary {
  pointer-events: auto;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 14px;
  background: rgba(18, 21, 29, 0.95);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  text-align: left;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
  flex-shrink: 0;
}

.summary-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.summary-detail {
  margin: 5px 0 0;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--text-muted);
}

.summary.ok .summary-title { color: var(--success); }
.summary.partial .summary-title { color: var(--warning); }
.summary.fail .summary-title { color: var(--error); }

.summary.ok { border-color: rgba(46, 204, 135, 0.25); }
.summary.partial { border-color: rgba(245, 166, 35, 0.25); }
.summary.fail { border-color: rgba(255, 90, 103, 0.25); }

.summary.fail .summary-detail,
.summary.partial .summary-detail {
  color: var(--text-muted);
}

.summary-detail[hidden] {
  display: none !important;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.summary[hidden],
.overlay[hidden] {
  display: none !important;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

.overlay-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 28px 36px;
  text-align: center;
  box-shadow: var(--shadow);
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border: 2.5px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#overlay-text {
  margin: 14px 0 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ── Empty state ── */

.empty-hint {
  padding: 48px 24px;
  text-align: center;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}

.empty-hint__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: var(--primary-soft);
  position: relative;
  opacity: 0.7;
}

.empty-hint__icon::after {
  content: "+";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 300;
  color: #ff6b82;
}

.empty-hint p {
  margin: 0 0 16px;
  font-size: 14px;
}
