:root{
  --surface:rgba(255,252,247,.78);
  --text:#403a35;
  --muted:#91867c;
  --line:rgba(101,78,59,.12);
  --sage:#cbdccc;
  --sage-deep:#526f5a;
  --blue:#d3e1ea;
  --radius-card:20px;
  --radius-control:13px;
  --radius-small:9px;
  --shadow:0 14px 42px rgba(86,63,46,.065);
}
*{box-sizing:border-box}
html,body{min-height:100%;background:transparent}
body{
  margin:0;
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Display","SF Pro Text","PingFang SC","Microsoft YaHei",Arial,sans-serif;
  -webkit-font-smoothing:antialiased;
  background:transparent;
}
button,input,textarea{font:inherit}
button{cursor:pointer}
button:disabled{cursor:not-allowed;opacity:.43}
button:focus-visible,input:focus-visible,textarea:focus-visible{outline:2px solid rgba(82,111,90,.28);outline-offset:2px}
.hidden{display:none!important}
body.dialog-open{overflow:hidden}

.library-page{min-height:100vh;padding:16px 18px 22px}
.library-card{
  position:relative;
  min-height:calc(100vh - 38px);
  overflow:hidden;
  border:1px solid rgba(255,255,255,.74);
  border-radius:var(--radius-card);
  background:var(--surface);
  box-shadow:var(--shadow),inset 0 1px 0 rgba(255,255,255,.90);
  backdrop-filter:blur(18px);
  -webkit-backdrop-filter:blur(18px);
}
.library-card::before{
  content:"";
  position:absolute;
  z-index:0;
  top:-100px;
  left:-120px;
  width:230px;
  height:230px;
  border-radius:50%;
  pointer-events:none;
  opacity:.48;
  background:radial-gradient(circle,rgba(203,220,204,.18),rgba(203,220,204,0) 70%);
}
.library-toolbar,.result-summary,.term-grid,.pagination{position:relative;z-index:1}
.library-toolbar{
  min-height:78px;
  display:grid;
  grid-template-columns:minmax(250px,1fr) minmax(320px,520px) minmax(250px,1fr);
  align-items:center;
  gap:18px;
  padding:16px 18px;
  border-bottom:1px solid var(--line);
}
.library-meta{
  min-width:0;
  display:flex;
  align-items:center;
  gap:10px;
  white-space:nowrap;
  justify-self:start;
}
.count-line{display:flex;align-items:baseline;gap:4px;color:#776e66;font-size:12px}
.count-line strong{color:#4d4741;font-size:16px;font-weight:680}
.source-meta{
  margin-left:7px;
  padding-left:11px;
  border-left:1px solid rgba(102,79,61,.10);
  color:#9d938a;
  font-size:11px;
}
.live-state{
  display:inline-flex;
  align-items:center;
  gap:6px;
  flex:0 0 auto;
  padding:5px 8px;
  border:1px solid rgba(82,111,90,.10);
  border-radius:999px;
  color:#738378;
  background:rgba(203,220,204,.23);
  font-size:10.5px;
  line-height:1;
}
.live-dot{
  position:relative;
  width:6px;
  height:6px;
  flex:0 0 6px;
  border-radius:50%;
  background:#6f9277;
  animation:liveBreathe 5.6s ease-in-out infinite;
}
.live-dot::after{
  content:"";
  position:absolute;
  inset:-4px;
  border:1px solid rgba(111,146,119,.14);
  border-radius:50%;
  opacity:0;
  animation:liveRipple 5.6s ease-out infinite;
}
.count-number{display:inline-block;min-width:34px;transform-origin:center}
.count-number.count-updated{animation:countSoftPulse .72s cubic-bezier(.2,.78,.25,1)}
.live-state.updated{animation:liveStateUpdated 1.15s cubic-bezier(.2,.78,.25,1)}

.search-box{
  width:100%;
  height:42px;
  justify-self:center;
  display:flex;
  align-items:center;
  gap:9px;
  padding:0 12px;
  border:1px solid var(--line);
  border-radius:var(--radius-control);
  background:rgba(255,253,249,.78);
  transition:border-color .18s ease,box-shadow .18s ease,background .18s ease;
}
.search-box:focus-within{border-color:rgba(82,111,90,.29);background:rgba(255,253,249,.94);box-shadow:0 0 0 4px rgba(203,220,204,.22)}
.search-icon{width:14px;height:14px;position:relative;flex:0 0 14px;border:1.5px solid #9d938a;border-radius:50%}
.search-icon::after{content:"";position:absolute;width:6px;height:1.5px;right:-5px;bottom:-2px;transform:rotate(45deg);border-radius:2px;background:#9d938a}
.search-box input{min-width:0;flex:1;border:0;outline:0;color:var(--text);background:transparent;font-size:12.5px}
.search-box input::placeholder{color:#aaa097}
.clear-search{visibility:hidden;width:26px;height:26px;border:0;border-radius:8px;color:#a2968c;background:transparent;font-size:16px;line-height:1}
.clear-search.visible{visibility:visible}
.clear-search:hover{color:#655c55;background:rgba(101,78,59,.06)}
.header-actions{display:flex;gap:9px;flex-wrap:nowrap;justify-self:end}
.button{
  min-height:42px;
  padding:0 15px;
  border:1px solid transparent;
  border-radius:var(--radius-control);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  font-size:12px;
  font-weight:650;
  white-space:nowrap;
  transition:transform .18s ease,box-shadow .18s ease,background .18s ease;
}
.button:hover:not(:disabled){transform:translateY(-1px)}
.button.primary{color:#fff;background:linear-gradient(180deg,#667f6c,#536b59);box-shadow:0 9px 22px rgba(78,105,85,.16)}
.button.secondary{color:#6e655d;border-color:var(--line);background:rgba(255,253,249,.68)}
.button.secondary:hover:not(:disabled){background:rgba(255,253,249,.94);box-shadow:0 8px 18px rgba(86,63,46,.06)}
.button-icon{font-size:15px;font-weight:400;line-height:1}

.result-summary{
  min-height:36px;
  display:flex;
  align-items:center;
  padding:0 20px;
  border-bottom:1px solid rgba(102,79,61,.07);
  color:#958b82;
  background:rgba(255,253,249,.20);
  font-size:12px;
}
.term-grid{
  min-height:calc(100vh - 224px);
  padding:16px 18px 18px;
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(145px,1fr));
  gap:9px;
  align-content:start;
}
.term-item{
  position:relative;
  min-height:46px;
  padding:10px 12px;
  display:flex;
  align-items:center;
  justify-content:center;
  border:1px solid rgba(255,255,255,.78);
  border-radius:12px;
  color:#625a53;
  background:rgba(255,253,249,.62);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.84);
  font-size:12px;
  line-height:1.45;
  text-align:center;
  word-break:break-word;
  transition:transform .16s ease,background .16s ease,border-color .16s ease;
}
.term-item:hover{transform:translateY(-1px);border-color:rgba(82,111,90,.14);background:rgba(255,253,249,.94)}
.term-item.custom{padding-right:42px;background:rgba(203,220,204,.30)}
.custom-tag{
  position:absolute;
  top:7px;
  right:7px;
  padding:2px 5px;
  border-radius:5px;
  color:#617a66;
  background:rgba(203,220,204,.76);
  font-size:9px;
  line-height:1.3;
}
.empty-state{grid-column:1/-1;min-height:430px;display:flex;flex-direction:column;align-items:center;justify-content:center;color:var(--muted);text-align:center}
.empty-state strong{margin-bottom:7px;color:#635b54;font-size:14px}
.empty-state span{font-size:12px}
.term-item.fresh{animation:freshTermIn 1.15s cubic-bezier(.18,.78,.23,1) both}
.term-item.fresh::after{
  content:"";
  position:absolute;
  inset:0;
  border-radius:inherit;
  pointer-events:none;
  box-shadow:0 0 0 1px rgba(82,111,90,.13),0 8px 22px rgba(82,111,90,.08);
  animation:freshGlow 1.3s ease both;
}

.pagination{
  min-height:64px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  padding:12px 18px;
  border-top:1px solid var(--line);
}
.pagination button{height:34px;padding:0 12px;border:1px solid var(--line);border-radius:var(--radius-small);color:#756b63;background:rgba(255,253,249,.64);font-size:11px}
.pagination button:hover:not(:disabled){background:rgba(255,253,249,.96)}
.pagination span{min-width:112px;color:var(--muted);font-size:12px;text-align:center}

.dialog-backdrop{
  position:fixed;
  inset:0;
  z-index:100;
  display:grid;
  place-items:center;
  padding:20px;
  background:rgba(59,50,43,.22);
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
}
.dialog-card{
  width:min(590px,100%);
  overflow:hidden;
  border:1px solid rgba(255,255,255,.78);
  border-radius:var(--radius-card);
  background:rgba(253,250,245,.97);
  box-shadow:0 30px 84px rgba(66,49,38,.22),inset 0 1px 0 #fff;
}
.dialog-card.small{width:min(430px,100%)}
.dialog-header{padding:22px 23px 17px;display:flex;align-items:flex-start;justify-content:space-between;gap:16px;border-bottom:1px solid var(--line)}
.dialog-header h2{margin:0 0 7px;font-size:17px;font-weight:680}
.dialog-header p{margin:0;color:var(--muted);font-size:12px;line-height:1.65}
.dialog-close{width:30px;height:30px;flex:0 0 30px;border:0;border-radius:var(--radius-small);color:#968b82;background:rgba(101,78,59,.05);font-size:18px}
.dialog-close:hover{color:#625a53;background:rgba(101,78,59,.09)}
.dialog-body{padding:20px 23px}
.input-label{display:block;margin-bottom:8px;color:#665e57;font-size:12px;font-weight:650}
.text-input,.batch-input{
  width:100%;
  border:1px solid var(--line);
  border-radius:var(--radius-control);
  outline:0;
  color:var(--text);
  background:rgba(255,253,249,.82);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.94);
  font-size:12px;
}
.text-input{height:43px;padding:0 12px}
.batch-input{min-height:230px;resize:vertical;padding:12px;line-height:1.65}
.text-input:focus,.batch-input:focus{border-color:rgba(82,111,90,.30);box-shadow:0 0 0 4px rgba(203,220,204,.23),inset 0 1px 0 #fff}
.feedback{min-height:20px;margin-top:9px;color:var(--muted);font-size:11px;line-height:1.5}
.feedback.error{color:#a65550}.feedback.success{color:#54725b}
.batch-stats{margin-top:11px;display:grid;grid-template-columns:repeat(3,1fr);gap:7px}
.batch-stats div{min-height:57px;padding:10px;border:1px solid rgba(255,255,255,.72);border-radius:12px;background:rgba(244,238,230,.66)}
.batch-stats span{display:block;margin-bottom:5px;color:var(--muted);font-size:10px}
.batch-stats strong{font-size:14px;font-weight:680}
.dialog-footer{min-height:65px;padding:12px 22px;display:flex;align-items:center;justify-content:flex-end;gap:8px;border-top:1px solid var(--line)}
.dialog-footer .button{min-width:82px}

.module-toast{
  position:fixed;
  left:50%;
  bottom:24px;
  z-index:150;
  max-width:min(520px,calc(100vw - 32px));
  padding:10px 15px;
  border:1px solid rgba(255,255,255,.7);
  border-radius:12px;
  color:#fff;
  background:rgba(65,58,52,.93);
  box-shadow:0 15px 40px rgba(49,40,33,.2);
  font-size:11px;
  opacity:0;
  visibility:hidden;
  pointer-events:none;
  transform:translate(-50%,9px);
  transition:.2s ease;
}
.module-toast.show{opacity:1;visibility:visible;transform:translate(-50%,0)}

@keyframes liveBreathe{
  0%,100%{transform:scale(.9);opacity:.72;box-shadow:0 0 0 0 rgba(111,146,119,.10)}
  50%{transform:scale(1.02);opacity:1;box-shadow:0 0 0 4px rgba(111,146,119,.06)}
}
@keyframes liveRipple{
  0%,55%{transform:scale(.75);opacity:0}
  66%{opacity:.32}
  90%,100%{transform:scale(1.28);opacity:0}
}
@keyframes countSoftPulse{
  0%{transform:translateY(0);color:#4d4741}
  36%{transform:translateY(-2px) scale(1.045);color:#52705a}
  100%{transform:none;color:#4d4741}
}
@keyframes freshTermIn{
  0%{opacity:0;transform:translateY(5px) scale(.985);background:rgba(203,220,204,.16)}
  42%{opacity:1;transform:translateY(-1px) scale(1.008);background:rgba(203,220,204,.48)}
  100%{transform:none;background:rgba(203,220,204,.30)}
}
@keyframes freshGlow{0%{opacity:0}36%{opacity:1}100%{opacity:0}}
@keyframes liveStateUpdated{
  0%{transform:translateY(0);background:rgba(203,220,204,.23)}
  38%{transform:translateY(-1px);background:rgba(203,220,204,.58);box-shadow:0 6px 16px rgba(82,111,90,.08)}
  100%{transform:none;background:rgba(203,220,204,.23);box-shadow:none}
}
@media(prefers-reduced-motion:reduce){
  .live-dot,.live-dot::after,.term-item.fresh,.term-item.fresh::after,.count-number.count-updated,.live-state.updated{animation:none!important}
}

@media(max-width:1180px){
  .library-toolbar{grid-template-columns:minmax(220px,1fr) minmax(280px,1.3fr);gap:12px}
  .header-actions{grid-column:1/-1;justify-self:end}
}
@media(max-width:720px){
  .library-page{padding:10px}
  .library-card{min-height:calc(100vh - 20px)}
  .library-toolbar{grid-template-columns:1fr;align-items:stretch;padding:13px;gap:10px}
  .library-meta{justify-content:space-between;flex-wrap:wrap}
  .search-box{max-width:none}
  .header-actions{grid-column:auto;width:100%;justify-self:stretch}
  .header-actions .button{flex:1}
  .result-summary{padding:0 14px}
  .term-grid{min-height:480px;padding:12px;grid-template-columns:repeat(auto-fill,minmax(132px,1fr))}
  .pagination{gap:4px;padding:10px 7px}
  .pagination button{padding:0 8px}
  .pagination span{min-width:92px}
}
@media(max-width:430px){
  .library-meta{align-items:flex-start;flex-direction:column;gap:7px}
  .source-meta{margin-left:5px}
  .term-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .dialog-header,.dialog-body{padding-left:17px;padding-right:17px}
  .dialog-footer{padding-left:16px;padding-right:16px}
}


/* Quiet infringement library refinement */
.library-card,.term-item,.dialog{
  box-shadow:none;
}

.library-card{
  border-radius:16px;
  background:#fbf9f5;
}

.term-item{
  border:1px solid transparent;
  border-radius:8px;
  background:rgba(255,255,255,.35);
  transition:background-color .16s ease,border-color .16s ease;
}

.term-item:hover{
  transform:none;
  border-color:var(--quiet-line);
  background:#fffdfa;
}

