:root{
  --bg:#ffffff;
  --text:#111827;
  --muted:#6b7280;
  --line:#e5e7eb;
  --card:#ffffff;
  --shadow: 0 8px 30px rgba(0,0,0,.08);
  --radius: 16px;

  --primary:#111827;
  --primaryText:#ffffff;

  --danger:#dc2626;
  --dangerBg:#fee2e2;

  --ghost:#ffffff;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Noto Sans Thai", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container{
  max-width: 980px;
  margin: 0 auto;
  padding: 0 14px;
}

.topbar{
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar__inner{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding: 14px 0;
}

.h1{font-size:18px;margin:0;font-weight:800;letter-spacing:.2px}
.h2{font-size:16px;margin:0;font-weight:800}
.h3{font-size:15px;margin:0;font-weight:800}
.sub{margin:6px 0 0;color:var(--muted);font-size:12px}

.topbar__right{display:flex;gap:10px;align-items:center}

.grid2{
  display:grid;
  grid-template-columns: 1fr;
  gap:12px;
  margin-top: 12px;
}
@media (min-width: 760px){
  .grid2{grid-template-columns: 1fr 1fr;}
}

.label{display:block;font-size:12px;color:var(--muted);margin-bottom:6px}
.input, .textarea{
  width:100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  outline:none;
  background:#fff;
  color: var(--text);
}
.input:focus, .textarea:focus{
  border-color:#9ca3af;
  box-shadow: 0 0 0 4px rgba(17,24,39,.08);
}
.textarea{min-height: 88px; resize: vertical;}
.help{font-size:12px;color:var(--muted);margin:0}
.muted{color:var(--muted);font-size:12px}

.list{
  display:grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 16px 0 90px;
}
@media (min-width: 760px){
  .list{grid-template-columns: 1fr 1fr;}
}

.card{
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 14px;
  position: relative; /* ✅ ให้ปุ่ม icon วาง absolute */
}

.card.deleted{
  opacity: .6;
  border-color: #fecaca;
  background: #fff;
}

.row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 10px;
}

.headline{
  font-weight: 800;
  font-size: 14px;
  line-height: 1.3;
  margin: 0;
  word-break: break-word;
}

.tags{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}
.tag{
  font-size:12px;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
}

.note{
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.btn{
  border: 1px solid var(--line);
  background: var(--ghost);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
}
.btn:disabled{opacity:.55;cursor:not-allowed}

.btn--ghost:hover{background:#f9fafb}
.btn--primary{
  background: var(--primary);
  color: var(--primaryText);
  border-color: var(--primary);
}
.btn--primary:hover{filter: brightness(1.05)}
.btn--danger{
  background: var(--dangerBg);
  border-color: #fecaca;
  color: var(--danger);
}
.btn--danger:hover{filter: brightness(0.98)}

.footerBar{
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}

.footerBar__inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 12px 0;
}
.footerBar__actions{display:flex;gap:10px}

.toast{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 74px;
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}
.toast.show{
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

.overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 14px;
}

.modal{
  width: min(560px, 100%);
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 14px;
}

.modal__head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap: 10px;
}

.modal__actions{
  display:flex;
  gap: 10px;
  justify-content:flex-end;
  flex-wrap:wrap;
}

.mt12{margin-top:12px}

.empty{
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 16px;
}

/* ✅ ปุ่ม icon ขวาล่าง */
.cardActions{
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
}

.iconBtn{
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s ease;
}

.iconBtn:hover{
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,.1);
}

.editBtn:hover{ background: #f3f4f6; }

.deleteBtn:hover{
  background: #fee2e2;
  border-color: #fecaca;
}