/* TelegramToMD — minimalist light theme, single accent (Telegram blue) */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --ink: #1a1d21;
  --muted: #6b7280;
  --border: #e3e4e0;
  --accent: #2aabee;
  --accent-ink: #ffffff;
  --accent-soft: #e8f6fd;
  --danger: #d4574e;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
code { font-family: var(--mono); font-size: 0.92em; background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.wrap { max-width: 680px; margin: 0 auto; padding: 48px 20px 40px; }

/* header */
.head { margin-bottom: 28px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  font-family: var(--mono); font-weight: 700; font-size: 13px;
  background: var(--accent); color: #fff;
  border-radius: 8px; padding: 8px 10px; letter-spacing: 0.5px;
}
h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.3px; }
.sub { color: var(--muted); margin: 10px 0 0; font-size: 14px; }
.sub strong { color: var(--ink); }

/* dropzone */
.dropzone {
  background: var(--surface);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 44px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  outline: none;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: #fdfeff; }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.busy { cursor: progress; border-style: solid; }
.dz-ic { font-size: 26px; color: var(--accent); margin-bottom: 8px; }
.dz-title { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.dz-hint { color: var(--muted); font-size: 13px; margin: 0; }

.spinner {
  width: 28px; height: 28px; margin: 0 auto 10px;
  border: 3px solid var(--accent-soft); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } }

/* error */
.error {
  background: #fdf1f0; color: var(--danger);
  border: 1px solid #f3d2cf; border-radius: var(--radius);
  padding: 10px 14px; font-size: 14px; margin: 14px 0 0;
}

/* result */
.result { margin-top: 14px; }
.res-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; flex-wrap: wrap;
}
.res-meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.check {
  width: 22px; height: 22px; border-radius: 50%;
  background: #e6f7ee; color: #1f9d61; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex: none;
}
#res-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-sub { color: var(--muted); font-size: 13px; flex: none; }
.res-actions { display: flex; gap: 8px; margin-left: auto; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; padding: 8px 14px; font-size: 14px; font-weight: 600;
  text-decoration: none; cursor: pointer; border: 1px solid transparent;
  font-family: var(--sans);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

.preview {
  margin: 10px 0 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; font-family: var(--mono); font-size: 12.5px;
  line-height: 1.55; max-height: 260px; overflow: auto; white-space: pre-wrap;
  word-break: break-word; color: #333;
}

/* ttl row */
.ttl { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; }
.ttl-label { color: var(--muted); flex: none; }
.ttl-bar { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.ttl-bar-fill { display: block; height: 100%; width: 100%; background: var(--accent); border-radius: 2px; transition: width 1s linear; }
.ttl-count { color: var(--ink); min-width: 72px; text-align: right; }

/* library */
.library { margin-top: 36px; }
.lib-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.lib-head h2 { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0; }
.lib-note { font-size: 12px; color: var(--muted); }
.lib-list { list-style: none; margin: 0; padding: 0; }
.lib-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 8px; font-size: 14px;
}
.lib-item .fi-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-item .fi-sub { color: var(--muted); font-size: 12.5px; flex: none; }
.lib-item .fi-actions { margin-left: auto; display: flex; gap: 6px; flex: none; }
.lib-item .fi-btn {
  border: 1px solid var(--border); background: transparent; color: var(--ink);
  border-radius: 6px; padding: 4px 10px; font-size: 12.5px; cursor: pointer;
  text-decoration: none; font-family: var(--sans); font-weight: 600;
}
.lib-item .fi-btn:hover { border-color: var(--accent); color: var(--accent); }
.lib-item .fi-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.lib-item .ttl-mini { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.lib-item .ttl-mini .bar { flex: 1; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.lib-item .ttl-mini .bar span { display: block; height: 100%; background: var(--accent); }
.lib-item .ttl-mini .left { font-family: var(--mono); font-size: 12px; color: var(--muted); min-width: 60px; text-align: right; }
.lib-empty { color: var(--muted); font-size: 13.5px; border: 1px dashed var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }

/* footer */
.foot { margin-top: 40px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); padding-top: 14px; }

@media (max-width: 560px) {
  .wrap { padding-top: 32px; }
  .res-top { flex-direction: column; align-items: stretch; }
  .res-actions { margin-left: 0; }
  .res-actions .btn { flex: 1; }
}
