/* AIWA Drafts (20260824f1) — in-tool panel + library page.
   Everything is built from the shared tokens, so dark mode needs almost no
   overrides: only the surfaces that are hardcoded light are restated. */

/* ===================== in-tool entry button ===================== */
.aiwa-drafts-btn {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 13px; border: 1px solid var(--aiwa-line); border-radius: 999px;
  background: var(--aiwa-card); color: var(--aiwa-text); font: inherit; font-size: 12.5px; font-weight: 650;
  white-space: nowrap; cursor: pointer; transition: border-color 140ms, background-color 140ms, color 140ms;
}
.aiwa-drafts-btn:hover { border-color: #9bc7aa; background: var(--aiwa-brand-soft); color: var(--aiwa-brand-dark); }
.aiwa-drafts-btn .aiwa-ui-icon { width: 14px; height: 14px; flex: 0 0 auto; }
.aiwa-drafts-badge {
  min-width: 18px; height: 18px; padding: 0 5px; display: inline-grid; place-items: center;
  border-radius: 999px; background: var(--aiwa-brand); color: #fff; font-size: 10.5px; font-weight: 800;
}

/* ===================== slide-over panel ===================== */
/* above the sticky header and the tools rail — a drawer that slides under the
   header reads as broken, and its own title row disappears behind it */
.aiwa-drafts-panel { position: fixed; inset: 0; z-index: 1400; }
.aiwa-drafts-panel[hidden] { display: none; }
.aiwa-drafts-scrim { position: absolute; inset: 0; background: rgba(9, 20, 14, .38); opacity: 0; transition: opacity 200ms ease; }
.aiwa-drafts-panel.is-open .aiwa-drafts-scrim { opacity: 1; }
.aiwa-drafts-sheet {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 100%);
  display: flex; flex-direction: column;
  border-left: 1px solid var(--aiwa-line); background: var(--aiwa-bg);
  box-shadow: -18px 0 48px rgba(9, 20, 14, .18);
  transform: translateX(100%); transition: transform 220ms cubic-bezier(.22,.61,.36,1);
}
.aiwa-drafts-panel.is-open .aiwa-drafts-sheet { transform: translateX(0); }

.aiwa-drafts-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px; border-bottom: 1px solid var(--aiwa-line); }
.aiwa-drafts-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.aiwa-drafts-title .aiwa-ui-icon { width: 17px; height: 17px; }
.aiwa-drafts-title b { color: var(--aiwa-ink); font-size: 15px; font-weight: 750; }
.aiwa-drafts-count { padding: 2px 8px; border-radius: 999px; background: var(--aiwa-soft, #eef2ef); color: var(--aiwa-muted); font-size: 11.5px; font-weight: 700; }
.aiwa-drafts-close {
  margin-left: auto; width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; border-radius: 9px; background: transparent; color: var(--aiwa-muted); font-size: 21px; line-height: 1; cursor: pointer;
}
.aiwa-drafts-close:hover { background: rgba(0,0,0,.06); color: var(--aiwa-ink); }

.aiwa-drafts-search { position: relative; padding: 12px 16px 6px; }
.aiwa-drafts-search .aiwa-ui-icon { position: absolute; top: 50%; left: 28px; width: 15px; height: 15px; margin-top: -4px; opacity: .5; pointer-events: none; }
.aiwa-drafts-search input {
  width: 100%; height: 38px; padding: 0 12px 0 34px; border: 1px solid var(--aiwa-line); border-radius: 10px;
  background: var(--aiwa-card); color: var(--aiwa-ink); font: inherit; font-size: 13px;
}
.aiwa-drafts-search input:focus-visible { outline: 2px solid var(--aiwa-focus, #2563eb); outline-offset: 1px; }

.aiwa-drafts-list { flex: 1; overflow-y: auto; padding: 10px 16px 16px; display: flex; flex-direction: column; gap: 10px; }

.aiwa-drafts-foot {
  display: flex; align-items: center; gap: 12px; padding: 11px 16px;
  border-top: 1px solid var(--aiwa-line); background: var(--aiwa-card);
}
.aiwa-drafts-note { color: var(--aiwa-muted); font-size: 11.5px; }
.aiwa-drafts-all { margin-left: auto; color: var(--aiwa-brand-dark); font-size: 12.5px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.aiwa-drafts-all:hover { text-decoration: underline; }

/* ===================== draft card ===================== */
.aiwa-draft-card {
  position: relative; padding: 13px 14px; border: 1px solid var(--aiwa-line); border-radius: 14px;
  background: var(--aiwa-card); transition: border-color 140ms, box-shadow 140ms, transform 140ms;
}
.aiwa-draft-card:hover { border-color: var(--aiwa-line-strong); box-shadow: 0 8px 22px rgba(15,42,26,.08); }
.aiwa-draft-card.is-pinned { border-color: var(--aiwa-brand); }
.aiwa-draft-card.is-pinned::before {
  content: ""; position: absolute; top: -1px; left: 14px; width: 26px; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--aiwa-brand);
}
.aiwa-draft-top { display: flex; align-items: flex-start; gap: 8px; }
.aiwa-draft-title { margin: 0; color: var(--aiwa-ink); font-size: 14px; font-weight: 750; line-height: 1.35; overflow-wrap: anywhere; }
.aiwa-draft-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 6px; color: var(--aiwa-muted); font-size: 11.5px; font-weight: 600; }
.aiwa-draft-tag { padding: 2px 8px; border-radius: 999px; background: var(--aiwa-brand-soft); color: var(--aiwa-brand-dark); font-weight: 700; text-transform: capitalize; }
.aiwa-draft-preview {
  margin: 9px 0 0; color: var(--aiwa-text); font-size: 12.5px; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.aiwa-draft-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.aiwa-draft-act {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px;
  border: 1px solid var(--aiwa-line); border-radius: 9px; background: transparent; color: var(--aiwa-text);
  font: inherit; font-size: 12px; font-weight: 650; cursor: pointer;
  transition: border-color 130ms, background-color 130ms, color 130ms;
}
.aiwa-draft-act .aiwa-ui-icon { width: 13px; height: 13px; }
.aiwa-draft-act:hover { border-color: var(--aiwa-brand); background: var(--aiwa-brand-soft); color: var(--aiwa-brand-dark); }
.aiwa-draft-act.is-primary { border-color: var(--aiwa-brand); background: var(--aiwa-brand); color: #fff; }
.aiwa-draft-act.is-primary:hover { background: var(--aiwa-brand-dark); border-color: var(--aiwa-brand-dark); color: #fff; }
.aiwa-draft-act.is-danger:hover { border-color: #d92d20; background: #fdeceb; color: #b42318; }
/* on narrow panels the labels drop away and the icons carry the meaning */
@media (max-width: 520px) { .aiwa-draft-act span { display: none; } .aiwa-draft-act { padding: 0 9px; } }

.aiwa-draft-confirm {
  display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 9px 10px;
  border: 1px solid var(--aiwa-line); border-radius: 10px; background: var(--aiwa-soft, #f7f9f7);
  color: var(--aiwa-text); font-size: 12.5px; font-weight: 650;
}
.aiwa-draft-confirm button { height: 27px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--aiwa-line); background: transparent; color: var(--aiwa-text); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.aiwa-draft-confirm-yes { margin-left: auto; border-color: #d92d20 !important; background: #d92d20 !important; color: #fff !important; }
.aiwa-draft-confirm-no:hover { border-color: var(--aiwa-line-strong); }

.aiwa-drafts-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 44px 20px; text-align: center; }
.aiwa-drafts-empty .aiwa-ui-icon { width: 30px; height: 30px; padding: 7px; border-radius: 11px; background: var(--aiwa-brand-soft); box-sizing: content-box; }
.aiwa-drafts-empty b { color: var(--aiwa-ink); font-size: 14px; font-weight: 750; }
.aiwa-drafts-empty span { max-width: 260px; color: var(--aiwa-muted); font-size: 12.5px; line-height: 1.55; }

/* ===================== library page ===================== */
.drafts-page main { padding-bottom: 60px; }
.drafts-hero { width: min(100% - 32px, 1080px); margin: 26px auto 0; }
.drafts-hero h1 { margin: 0 0 6px; color: var(--aiwa-ink); font-size: clamp(1.5rem, 3vw, 2.05rem); font-weight: 800; letter-spacing: -.02em; }
.drafts-hero p { margin: 0; max-width: 620px; color: var(--aiwa-muted); font-size: 14px; line-height: 1.6; }

.drafts-privacy {
  display: flex; align-items: flex-start; gap: 10px; width: min(100% - 32px, 1080px); margin: 16px auto 0;
  padding: 12px 14px; border: 1px solid var(--aiwa-line); border-radius: 12px; background: var(--aiwa-brand-soft);
  color: var(--aiwa-text); font-size: 12.5px; line-height: 1.55;
}
.drafts-privacy .aiwa-ui-icon { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; }
.drafts-privacy b { color: var(--aiwa-ink); font-weight: 750; }

.drafts-controls { width: min(100% - 32px, 1080px); margin: 20px auto 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.drafts-search { position: relative; flex: 1 1 260px; min-width: 0; }
.drafts-search .aiwa-ui-icon { position: absolute; top: 50%; left: 13px; width: 16px; height: 16px; transform: translateY(-50%); opacity: .5; pointer-events: none; }
.drafts-search input { width: 100%; height: 42px; padding: 0 14px 0 38px; border: 1px solid var(--aiwa-line); border-radius: 12px; background: var(--aiwa-card); color: var(--aiwa-ink); font: inherit; font-size: 14px; }
.drafts-sort { height: 42px; padding: 0 12px; border: 1px solid var(--aiwa-line); border-radius: 12px; background: var(--aiwa-card); color: var(--aiwa-ink); font: inherit; font-size: 13px; font-weight: 650; cursor: pointer; }

.drafts-filters { width: min(100% - 32px, 1080px); margin: 14px auto 0; display: flex; flex-wrap: wrap; gap: 8px; }
.drafts-filter {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 13px;
  border: 1px solid var(--aiwa-line); border-radius: 999px; background: var(--aiwa-card); color: var(--aiwa-text);
  font: inherit; font-size: 12.5px; font-weight: 650; cursor: pointer;
  transition: border-color 130ms, background-color 130ms, color 130ms;
}
.drafts-filter .aiwa-ui-icon { width: 14px; height: 14px; }
.drafts-filter:hover { border-color: var(--aiwa-line-strong); }
.drafts-filter[aria-pressed="true"] { border-color: var(--aiwa-brand); background: var(--aiwa-brand); color: #fff; }
.drafts-filter i { font-style: normal; opacity: .72; font-weight: 700; }

.drafts-grid { width: min(100% - 32px, 1080px); margin: 18px auto 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.drafts-grid .aiwa-draft-card { padding: 16px; border-radius: 16px; }
.drafts-grid .aiwa-draft-title { font-size: 15px; }
.drafts-grid .aiwa-draft-preview { -webkit-line-clamp: 4; }
.draft-tool-chip { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 9px; padding: 3px 9px 3px 6px; border-radius: 999px; background: var(--aiwa-soft, #eef2ef); color: var(--aiwa-text); font-size: 11.5px; font-weight: 700; }
.draft-tool-chip .aiwa-ui-icon { width: 13px; height: 13px; }

.drafts-empty { width: min(100% - 32px, 640px); margin: 44px auto; padding: 40px 24px; border: 1px dashed var(--aiwa-line-strong); border-radius: 18px; text-align: center; }
.drafts-empty .aiwa-ui-icon { width: 34px; height: 34px; padding: 9px; border-radius: 13px; background: var(--aiwa-brand-soft); box-sizing: content-box; }
.drafts-empty h2 { margin: 14px 0 6px; color: var(--aiwa-ink); font-size: 18px; font-weight: 750; }
.drafts-empty p { margin: 0 auto 18px; max-width: 400px; color: var(--aiwa-muted); font-size: 13.5px; line-height: 1.6; }
.drafts-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.drafts-empty-actions a { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 15px; border: 1px solid var(--aiwa-line); border-radius: 999px; background: var(--aiwa-card); color: var(--aiwa-text); font-size: 13px; font-weight: 650; text-decoration: none; }
.drafts-empty-actions a:hover { border-color: var(--aiwa-brand); color: var(--aiwa-brand-dark); }
.drafts-empty-actions a .aiwa-ui-icon { width: 14px; height: 14px; }

.drafts-footbar { width: min(100% - 32px, 1080px); margin: 26px auto 0; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 16px; border-top: 1px solid var(--aiwa-line); color: var(--aiwa-muted); font-size: 12.5px; }
.drafts-danger { margin-left: auto; height: 34px; padding: 0 13px; border: 1px solid var(--aiwa-line); border-radius: 9px; background: transparent; color: var(--aiwa-text); font: inherit; font-size: 12.5px; font-weight: 650; cursor: pointer; }
.drafts-danger:hover { border-color: #d92d20; color: #b42318; background: #fdeceb; }

@media (max-width: 720px) {
  .drafts-grid { grid-template-columns: 1fr; }
  .aiwa-drafts-sheet { width: 100%; }
}


/* ===================== dark mode ===================== */
/* --aiwa-brand is a LIGHT green in dark mode, so anything filled with it needs
   dark ink rather than white — same rule as the rest of the app. */
html[data-theme="dark"] .drafts-filter[aria-pressed="true"] { background: var(--aiwa-brand); border-color: var(--aiwa-brand); color: #08130c; }
html[data-theme="dark"] .aiwa-draft-act.is-primary { background: var(--aiwa-brand); border-color: var(--aiwa-brand); color: #08130c; }
html[data-theme="dark"] .aiwa-draft-act.is-primary:hover { background: var(--aiwa-brand-dark); border-color: var(--aiwa-brand-dark); color: #08130c; }
html[data-theme="dark"] .aiwa-draft-act.is-primary .aiwa-ui-icon { filter: brightness(0); }
html[data-theme="dark"] .aiwa-drafts-badge { background: var(--aiwa-brand); color: #08130c; }

html[data-theme="dark"] .drafts-filter { background: #1b241f; border-color: #28332c; color: #cfdad2; }
html[data-theme="dark"] .drafts-filter:hover { border-color: #3a473f; }
html[data-theme="dark"] .aiwa-drafts-btn { background: #1b241f; border-color: #28332c; color: #cfdad2; }
html[data-theme="dark"] .aiwa-drafts-btn:hover { border-color: var(--aiwa-brand); background: rgba(47,174,99,.16); color: #4cc47c; }
html[data-theme="dark"] .aiwa-drafts-count { background: #1b241f; }
html[data-theme="dark"] .aiwa-drafts-scrim { background: rgba(0,0,0,.58); }
html[data-theme="dark"] .aiwa-drafts-sheet { box-shadow: -18px 0 48px rgba(0,0,0,.5); }
html[data-theme="dark"] .aiwa-drafts-close:hover { background: rgba(255,255,255,.08); }
html[data-theme="dark"] .aiwa-draft-card:hover { box-shadow: 0 10px 26px rgba(0,0,0,.36); }
html[data-theme="dark"] .aiwa-draft-tag { background: rgba(47,174,99,.16); color: #4cc47c; }
html[data-theme="dark"] .draft-tool-chip { background: #1b241f; color: #cfdad2; }
html[data-theme="dark"] .aiwa-draft-act:hover { background: rgba(47,174,99,.16); color: #4cc47c; }
html[data-theme="dark"] .aiwa-draft-act.is-danger:hover { border-color: #ef8079; background: rgba(239,128,121,.14); color: #ef8079; }
html[data-theme="dark"] .aiwa-draft-confirm { background: #1b241f; }
html[data-theme="dark"] .aiwa-draft-confirm-yes { border-color: #ef8079 !important; background: #ef8079 !important; color: #08130c !important; }
html[data-theme="dark"] .aiwa-drafts-empty .aiwa-ui-icon,
html[data-theme="dark"] .drafts-empty .aiwa-ui-icon { background: rgba(47,174,99,.16); }
html[data-theme="dark"] .drafts-privacy { background: rgba(47,174,99,.12); border-color: #2f5f43; }
html[data-theme="dark"] .drafts-empty-actions a:hover { color: #4cc47c; }
html[data-theme="dark"] .drafts-danger:hover { border-color: #ef8079; background: rgba(239,128,121,.14); color: #ef8079; }
