/* ==========================================================================
   FreeToolHub Design System — Exact Stylesheet Match
   ========================================================================== */

:root {
  --bg: #F4F6F3;
  --surface: #FFFFFF;
  --surface-2: #EBEFEA;
  --ink: #12211A;
  --ink-2: #33463B;
  --muted: #61736A;
  --line: #DCE3DC;
  --accent: #0B7A55;
  --accent-dark: #065C40;
  --accent-soft: #E1F1E8;
  --amber: #D98E1B;
  --amber-soft: #FBF0DA;
  --danger: #B3261E;
  --danger-soft: #FBE9E7;
  --chip: #FFFFFF;
  --shadow: 0 1px 2px rgba(18, 33, 26, .05), 0 8px 24px -12px rgba(18, 33, 26, .12);
  --radius: 16px;
}

:root[data-theme="dark"] {
  --bg: #0D130F;
  --surface: #151D17;
  --surface-2: #1C261E;
  --ink: #EAF2EC;
  --ink-2: #C4D4C8;
  --muted: #93A89A;
  --line: #27352A;
  --accent: #2FBF8F;
  --accent-dark: #2FBF8F;
  --accent-soft: #173427;
  --amber: #E8A83E;
  --amber-soft: #33270F;
  --danger: #F0807A;
  --danger-soft: #3A1D1B;
  --chip: #151D17;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .5);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: "Sora", sans-serif;
  line-height: 1.15;
  margin: 0;
}

button, [role="button"], select, summary, input:not([type="checkbox"]) {
  min-height: 2.75rem;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
}

.mono {
  font-family: "JetBrains Mono", monospace;
}

a {
  color: var(--accent-dark);
  text-decoration: none;
}

:root[data-theme="dark"] a {
  color: var(--accent);
}

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Top Bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-in {
  max-width: 1180px;
  margin: 0 auto;
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  color: var(--ink);
  margin-right: auto;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent);
  display: grid;
  place-items: center;
  flex: none;
}

.brand-mark svg {
  width: 22px;
  height: 22px;
  stroke: #fff;
}

.brand b {
  font-family: "Sora", sans-serif;
  font-size: 1.15rem;
  letter-spacing: -.01em;
}

.brand b span {
  color: var(--accent);
}

.topnav {
  display: none;
  gap: .25rem;
}

.topnav a {
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 600;
  font-size: .92rem;
  padding: .55rem .7rem;
  border-radius: 9px;
}

.topnav a:hover {
  background: var(--surface-2);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  color: var(--ink);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

@media(min-width: 760px) {
  .topnav {
    display: flex;
  }
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ---------- Ad Slots ---------- */
.adslot {
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  text-align: center;
  padding: 1rem;
  margin: 1.4rem 0;
}

.adslot small {
  font-size: .68rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 700;
}

.adslot span {
  font-size: .85rem;
  font-weight: 600;
}

.adslot.leader {
  min-height: 110px;
}

.adslot.box {
  min-height: 250px;
  margin: 0;
}

/* ---------- Tool Header ---------- */
.tool-head {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin: 1.5rem 0 1.2rem;
}

.tool-head .ic {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  flex: none;
}

.tool-head .ic svg {
  width: 28px;
  height: 28px;
  stroke: var(--accent-dark);
}

:root[data-theme="dark"] .tool-head .ic svg {
  stroke: var(--accent);
}

.tool-head h2 {
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  letter-spacing: -.01em;
}

.tool-head p {
  color: var(--muted);
  margin: .3rem 0 0;
  font-weight: 500;
  max-width: 60ch;
}

/* ---------- Tool Layout ---------- */
.tool-layout {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: 1fr;
  padding-bottom: 1rem;
}

@media(min-width: 920px) {
  .tool-layout {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.3rem;
  box-shadow: var(--shadow);
}

.rail .panel {
  margin-bottom: 1.1rem;
}

.rail h3 {
  font-size: .98rem;
  margin-bottom: .55rem;
}

.rail p, .rail li {
  color: var(--muted);
  font-size: .9rem;
  font-weight: 500;
}

.rail ol, .rail ul {
  margin: .3rem 0;
  padding-left: 1.15rem;
}

.rail li {
  margin: .35rem 0;
}

.relbtn {
  display: flex;
  width: 100%;
  align-items: center;
  gap: .6rem;
  background: var(--surface-2);
  border: 0;
  border-radius: 10px;
  padding: .6rem .75rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: .45rem;
  text-align: left;
}

.relbtn:hover {
  background: var(--accent-soft);
}

/* ---------- Form & Inputs ---------- */
label.flabel {
  display: block;
  font-weight: 700;
  font-size: .86rem;
  margin: 0 0 .35rem;
  color: var(--ink-2);
}

.field {
  margin-bottom: 1rem;
}

.tin, .tsel {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  padding: .65rem .8rem;
  color: var(--ink);
}

.tin:focus, .tsel:focus {
  border-color: var(--accent);
  outline: none;
}

.controls-row {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}

@media(min-width: 580px) {
  .controls-row {
    grid-template-columns: 1fr 1fr;
  }
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  min-height: 2rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  border-radius: 11px;
  border: 0;
  padding: .7rem 1.25rem;
  font-weight: 800;
  font-size: .95rem;
  background: var(--accent);
  color: #fff;
}

.btn:hover:not(:disabled) {
  background: var(--accent-dark);
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

:root[data-theme="dark"] .btn {
  color: #08130D;
}

:root[data-theme="dark"] .btn:hover:not(:disabled) {
  background: #57D6AB;
}

.btn.ghost {
  background: var(--surface-2);
  color: var(--ink);
}

.btn.ghost:hover:not(:disabled) {
  background: var(--accent-soft);
}

.btn.amber {
  background: var(--amber);
  color: #221503;
}

.btnrow {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin-top: .4rem;
}

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 2.75rem 1.2rem;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all .15s ease;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dz-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto .75rem;
  color: var(--accent);
}

.dz-icon svg {
  width: 100%;
  height: 100%;
}

.dz-text {
  font-family: "Sora", sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: .25rem;
}

.dz-sub {
  color: var(--muted);
  font-size: .88rem;
  margin: 0;
}

/* ---------- File Queue Cards ---------- */
.file-queue {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-top: 1.4rem;
}

.file-item {
  display: grid;
  grid-template-columns: 68px 1fr auto;
  gap: 1rem;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .75rem 1rem;
}

.file-thumb {
  width: 68px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
}

.file-meta-col {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  overflow: hidden;
}

.file-meta-header {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.file-title {
  font-weight: 700;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-tag {
  font-size: .72rem;
  font-weight: 800;
  padding: .15rem .5rem;
  border-radius: 6px;
  letter-spacing: .02em;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-clean {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

:root[data-theme="dark"] .badge-clean {
  color: var(--accent);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  font-size: .78rem;
  color: var(--muted);
}

.meta-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .1rem .45rem;
}

.file-actions-col {
  display: flex;
  align-items: center;
  gap: .45rem;
}

@media(max-width: 640px) {
  .file-item {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .file-thumb {
    margin: 0 auto;
  }
  .file-meta-header {
    justify-content: center;
  }
  .file-actions-col {
    justify-content: center;
  }
}

/* ---------- Sections & FAQ ---------- */
section.block {
  padding: 2.4rem 0 .4rem;
}

.sec-head {
  margin-bottom: 1.1rem;
}

.sec-head h2 {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  letter-spacing: -.01em;
}

.sec-head p {
  color: var(--muted);
  margin: .4rem 0 0;
  max-width: 62ch;
  font-weight: 500;
}

details.faq {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: .6rem;
}

details.faq summary {
  cursor: pointer;
  font-weight: 700;
  padding: .95rem 1.1rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

details.faq summary::-webkit-details-marker {
  display: none;
}

details.faq summary::after {
  content: "+";
  font-size: 1.3rem;
  color: var(--accent);
  font-weight: 800;
}

details.faq[open] summary::after {
  content: "–";
}

details.faq p {
  margin: 0;
  padding: 0 1.1rem 1rem;
  color: var(--muted);
  font-weight: 500;
  font-size: .94rem;
}

/* ---------- Modal Dialog ---------- */
.modal-dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  max-width: 620px;
  width: 90%;
  margin: auto;
  padding: 0;
  box-shadow: var(--shadow);
}

.modal-dialog::backdrop {
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(4px);
}

.modal-content {
  padding: 1.3rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: .85rem;
  margin-bottom: .85rem;
}

.modal-body {
  max-height: 55vh;
  overflow-y: auto;
}

table.mini {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  margin-top: .6rem;
}

table.mini th, table.mini td {
  padding: .55rem .6rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

table.mini th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  width: 40%;
}

table.mini td {
  font-family: "JetBrains Mono", monospace;
  font-size: .88rem;
}

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  padding: 1.6rem 0 2.4rem;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 500;
}

footer .cols {
  display: grid;
  gap: 1.2rem;
}

@media(min-width: 760px) {
  footer .cols {
    grid-template-columns: 2fr 1fr 1fr;
  }
}

footer b {
  color: var(--ink);
  font-family: "Sora", sans-serif;
}

footer ul {
  list-style: none;
  margin: .5rem 0 0;
  padding: 0;
}

footer li {
  margin: .3rem 0;
}

footer a.linklike {
  color: var(--muted);
  font-weight: 600;
  padding: .2rem 0;
  text-align: left;
  font-size: .9rem;
}

footer a.linklike:hover {
  color: var(--accent-dark);
}

:root[data-theme="dark"] footer a.linklike:hover {
  color: var(--accent);
}

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translate(-50%, 140%);
  background: var(--ink);
  color: var(--bg);
  padding: .75rem 1.2rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: .92rem;
  z-index: 99;
  transition: transform .25s;
  box-shadow: var(--shadow);
  max-width: 92vw;
  text-align: center;
}

#toast.show {
  transform: translate(-50%, 0);
}
