.rt-record-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
}

.rt-record-modal[hidden] {
  display: none;
}

.rt-record-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.42);
}

.rt-record-card {
  position: relative;
  z-index: 1;
  width: min(460px, 100%);
  max-height: min(620px, calc(100vh - 36px));
  display: grid;
  gap: 14px;
  overflow: auto;
  padding: 18px;
  border-radius: 8px;
  background: var(--paper, #fff);
  border: 1px solid var(--line, #d9dee8);
  box-shadow: var(--shadow, 0 18px 48px rgba(15, 23, 42, 0.08));
}

body.rt-record-modal-open {
  overflow: hidden;
}

.rt-record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.rt-record-head h2 {
  margin: 0;
  font-size: 18px;
}

.rt-record-close {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--muted, #667085);
}

.rt-record-empty {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line, #d9dee8);
}

.rt-record-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.rt-record-clear {
  color: #991b1b;
  background: #fee2e2;
}

.rt-record-list {
  display: grid;
  gap: 10px;
}

.rt-record-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  background: var(--paper, #fff);
  border: 1px solid var(--line, #d9dee8);
}

.rt-record-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.rt-record-text small {
  color: var(--muted, #667085);
  font-size: 13px;
  font-weight: 600;
}

.rt-record-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.rt-record-open {
  padding: 8px 10px;
  border-radius: 999px;
  background: #eef4ff;
  color: #1d4ed8;
}

.rt-record-delete {
  padding: 8px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #991b1b;
}

.rt-record-count {
  text-align: right;
}

.history-toolbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.history-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(99, 102, 241, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: #4338ca;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.08);
}

.history-btn:disabled {
  opacity: 1;
  cursor: default;
}

.history-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: linear-gradient(135deg, #6366f1, #d946ef);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.history-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
}

.history-modal.hidden {
  display: none;
}

.history-modal::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.history-panel {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: min(76vh, 740px);
  display: grid;
  gap: 16px;
  overflow: auto;
  padding: 20px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.18);
}

.history-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.history-kicker {
  color: #7c3aed;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.history-panel-head h2 {
  margin: 6px 0 0;
  color: #0f172a;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.history-icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #475569;
  flex: 0 0 auto;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.history-item:hover {
  transform: translateY(-1px);
  border-color: rgba(99, 102, 241, 0.22);
  box-shadow: 0 16px 32px rgba(79, 70, 229, 0.08);
}

.history-item strong {
  display: block;
  color: #0f172a;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.35;
}

.history-item span {
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}

.history-item em {
  flex: 0 0 auto;
  color: #4f46e5;
  font-size: 12px;
  font-weight: 900;
  font-style: normal;
}

.history-empty {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 26px 18px;
  border-radius: 18px;
  border: 1px dashed rgba(148, 163, 184, 0.36);
  background: rgba(248, 250, 252, 0.7);
  color: #64748b;
  text-align: center;
  font-size: 13px;
  font-weight: 650;
}

.history-empty.hidden {
  display: none;
}

@media (max-width: 640px) {
  .history-panel {
    max-height: calc(100vh - 28px);
    padding: 16px;
    border-radius: 20px;
  }

  .history-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-item em {
    align-self: flex-end;
  }
}
