/* Memory Core UI (shared) */
html, body { overflow: auto; }
body { padding: 24px; }

.shell { position: relative; z-index: 1; max-width: 980px; margin: 0 auto; }

a { color:#7fe0e5; text-decoration:none; font-weight:700; }
a:hover { text-shadow: 0 0 5px #a2ffff; }

.item {
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 12px;
  padding: 14px;
  margin: 14px 0;
  background: rgba(0,0,0,.18);
}

.meta { color:#b9c7de; font-size: 12px; margin-bottom: 8px; }

pre { white-space: pre-wrap; word-break: break-word; margin: 0; color:#fff; }

.hint { color:#b9c7de; margin-top: 14px; }
.error { margin-top: 12px; color: #ffb4b4; }

.rerank-status{
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.16);
  color: #b9c7de;
  font-size: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.rerank-status-main{
  color: #ffcf8a;
  font-weight: 900;
}
.rerank-status.is-on .rerank-status-main{
  color: #7fe0e5;
}
.rerank-status.is-error .rerank-status-main{
  color: #ffb3b3;
}

label { display:block; margin-top: 12px; font-weight: 700; }

input, textarea, select {
  width: 100%;
  padding: 10px;
  margin-top: 6px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.25);
  color: #fff;
}

textarea { height: 220px; }

/* Buttons */
button, .btn {
  display:inline-block;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(127,224,229,.12);
  color:#fff;
  cursor:pointer;
  text-decoration:none;
  font-weight: 700;
}

button:hover, .btn:hover { background: rgba(127,224,229,.2); }

.btn-danger, button.btn-danger {
  background: rgba(255,80,80,.15);
  border-color: rgba(255,120,120,.35);
}
.btn-danger:hover, button.btn-danger:hover { background: rgba(255,80,80,.25); }

/* Action row */
.actions { margin-top:10px; display:flex; gap:10px; align-items:center; flex-wrap:wrap; }

/* Index page: topbar + search */
.topbar{ display:flex; gap:12px; align-items:center; flex-wrap:wrap; }

/* One “toolbar row” feel */
.search{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  margin-top: 14px;
}

.search input{
  width:auto;
  min-width: 200px;
}

.search input[name="q"]{ min-width: 260px; }
.search input[name="tag"]{ min-width: 200px; }

.search button{ padding: 8px 12px; }

/* Keep the Semantic switch visually attached to the Search button */
.search .semantic-toggle{ margin-left: 6px; }

/* Add/Edit page: layout helpers */
.row { display:flex; gap: 12px; flex-wrap:wrap; }
.row > div { flex: 1 1 240px; }

.btns { margin-top: 16px; display:flex; gap: 10px; align-items:center; flex-wrap:wrap; }

/* View page */
.card {
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 12px;
  padding: 14px;
  background: rgba(0,0,0,.18);
  margin-top: 14px;
}

/* Clickable tags */
.tag {
  display: inline-block;
  padding: 2px 8px;
  margin-right: 6px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(127,224,229,.08);
  color: #7fe0e5;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
}

.tag:hover {
  background: rgba(127,224,229,.18);
  text-shadow: none;
}

/* Echoes reading library */
.echoes-shell { max-width: 1040px; }

.echoes-head { margin-top: 22px; }

.echoes-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.echoes-item {
  margin: 0;
}

.echoes-item h3 {
  margin: 6px 0 10px;
  line-height: 1.25;
}

.echoes-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.echoes-reader h2 {
  margin: 4px 0 10px;
}

.echoes-markdown {
  margin-top: 18px;
  line-height: 1.65;
  color: #f4fbff;
}

.filter-pill {
  margin-top: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  color: #b9c7de;
  font-size: 12px;
}

.tag-active {
  background: rgba(127,224,229,.22);
  border-color: rgba(127,224,229,.45);
}

.btn-ghost {
  background: transparent;
  border-color: rgba(255,255,255,.18);
}
.btn-ghost:hover {
  background: rgba(255,255,255,.06);
}

/* Bulk bar alignment */
.bulk-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.bulk-left { display:flex; gap:10px; align-items:center; }

/* Selected count pill */
.count-pill{
  margin-left:auto;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  background: rgba(0,0,0,.18);
  color: #b9c7de;
  font-size: 12px;
}

/* Memory list row layout: checkbox outside the card */
.mem-row{
  display:flex;
  gap:12px;
  align-items:flex-start;
  margin-top:14px;
}

.mem-row .item { margin: 0; }

.row-select{
  flex: 0 0 22px;
  display:flex;
  justify-content:center;
  padding-top: 16px; /* align with meta row */
}

.row-select input{
  transform: translateY(2px);
}

/* Bulk quick actions */
.bulk-controls .btn { white-space: nowrap; }

/* Hide legacy in-card checkbox, if any */
.bulk-check { display: none; }

/* Ensure checkboxes are visible (override global input styles) */
.row-select input[type="checkbox"],
.bulk-selectall input[type="checkbox"],
input.rowCheck[type="checkbox"]{
  width: auto;
  padding: 0;
  margin: 0;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(0,0,0,.35);
  accent-color: #7fe0e5;
}

.row-select{
  align-items: center;
}

/* Make the checkbox easier to see/click */
.row-select input[type="checkbox"],
.bulk-selectall input[type="checkbox"]{
  transform: scale(1.05);
}

/* Selected memory highlight */
.mem-row.selected .item{
  border-color: rgba(127,224,229,.55);
  box-shadow:
    0 0 0 1px rgba(127,224,229,.12),
    0 0 18px rgba(127,224,229,.12);
  background: rgba(127,224,229,.06);
}

/* Semantic panel */
.semantic-panel{
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.18);
}
.semantic-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.semantic-title{
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .2px;
  color: rgba(255,255,255,.92);
}
.semantic-empty{
  color: rgba(255,255,255,.65);
  padding: 8px 2px;
}

/* Semantic cards */
.semantic-results{
  display: grid;
  gap: 10px;
}
.semantic-card{
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.18);
  padding: 12px;
}
.semantic-row{
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}
.semantic-name{
  font-weight: 900;
  color: rgba(255,255,255,.92);
}
.semantic-meta{
  font-size: 12px;
  color: rgba(255,255,255,.55);
}
.semantic-tags{
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.semantic-snippet{
  margin-top: 8px;
  color: rgba(255,255,255,.75);
  line-height: 1.45;
  font-size: 13px;
}
.semantic-actions{
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

/* ===== Semantic toggle (switch) ===== */
.semantic-toggle{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  position: relative;
  color: rgba(255,255,255,.75);
  font-weight: 800;
  letter-spacing: .2px;
}

/* Hide the native checkbox */
.semantic-toggle input{
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Make the text a container for our switch */
.semantic-toggle span{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

/* Track */
.semantic-toggle span::before{
  content: "";
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25);
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}

/* Knob */
.semantic-toggle span::after{
  content: "";
  position: absolute;
  /* knob position relative to label */
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(255,255,255,.85);
  box-shadow: 0 8px 18px rgba(0,0,0,.35);
  transition: transform .18s ease, background .18s ease;
  /* align vertically */
  transform: translateY(0);
}

/* When checked: green track + knob moves right */
.semantic-toggle input:checked + span::before{
  background: rgba(90, 255, 210, .22);           /* “logo 绿”氛围 */
  border-color: rgba(90, 255, 210, .45);
  box-shadow: 0 0 0 3px rgba(90, 255, 210, .12), inset 0 0 0 1px rgba(0,0,0,.25);
}

.semantic-toggle input:checked + span::after{
  transform: translateX(20px);
  background: rgba(180, 255, 235, .95);
}

/* Hover */
.semantic-toggle:hover span::before{
  border-color: rgba(255,255,255,.25);
}

/* Keyboard focus */
.semantic-toggle input:focus-visible + span::before{
  box-shadow: 0 0 0 4px rgba(120, 200, 255, .18), inset 0 0 0 1px rgba(0,0,0,.25);
}

/* Semantic tag buttons should look like pills, not default buttons */
.tag.sem-tag{
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(127,224,229,.08);
  color: #7fe0e5;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.tag.sem-tag:hover{
  background: rgba(127,224,229,.18);
  filter: brightness(1.12);
}

.index-pill{
  margin-left: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06);
  opacity: .9;
}
.index-pill.ok{
  color: #7fe0e5;
  border-color: rgba(127,224,229,.35);
  background: rgba(127,224,229,.10);
}
.index-pill.bad{
  color: #ffb3b3;
  border-color: rgba(255,179,179,.35);
  background: rgba(255,179,179,.10);
}


.guardbar{
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.05);
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}
.guardbar.warn{
  border-color: rgba(255,205,100,.35);
  background: rgba(255,205,100,.10);
}
.guardbar.bad{
  border-color: rgba(255,140,140,.35);
  background: rgba(255,140,140,.10);
}
