/* ═══════════════════════════════════════════════════════
   FILELY — Design System & Global Styles
   Target aesthetic: Linear / Notion / Vercel
   ═══════════════════════════════════════════════════════ */

/* ── RESET & ROOT ──────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* Surfaces */
  --bg:        #F7F6F3;
  --surface:   #FFFFFF;
  --surface-2: #F0EFE9;
  --surface-3: #E8E6DF;

  /* Borders */
  --border:    #E2DFD6;
  --border-2:  #C8C4B8;

  /* Text */
  --tx:        #18181B;
  --tx-2:      #52524E;
  --tx-3:      #8C8B84;

  /* Accent */
  --accent:    #18181B;
  --accent-hv: #2D2D2D;
  --accent-fg: #FFFFFF;

  /* Status colors */
  --green:     #166534;
  --green-bg:  #DCFCE7;
  --green-bd:  #BBF7D0;
  --blue:      #1E40AF;
  --blue-bg:   #DBEAFE;
  --blue-bd:   #BFDBFE;
  --amber:     #92400E;
  --amber-bg:  #FEF3C7;
  --amber-bd:  #FDE68A;
  --red:       #991B1B;
  --red-bg:    #FEE2E2;

  /* Radii */
  --r:   8px;
  --rl:  12px;
  --rxl: 16px;

  /* Transitions */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Geist', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--tx);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── TYPOGRAPHY ────────────────────────────────────────── */
h1, h2, .serif { font-family: 'Instrument Serif', Georgia, serif; font-weight: 400; }

/* ── NAVBAR ────────────────────────────────────────────── */
#navbar {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(247, 246, 243, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 8px;
}

.logo {
  font-family: 'Instrument Serif', serif;
  font-size: 21px;
  letter-spacing: -0.3px;
  color: var(--tx);
  cursor: pointer;
  margin-right: auto;
  user-select: none;
}
.logo em { font-style: italic; opacity: 0.45; }

.nav-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 400;
  font-family: 'Geist', sans-serif;
  color: var(--tx-2);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav-btn:hover  { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.nav-btn.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 500; }

/* ── PAGES ─────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 28px;
}

/* ── HOME ──────────────────────────────────────────────── */
.hero {
  padding: 56px 0 44px;
  border-bottom: 1px solid var(--border);
}
.hero h1 {
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.07;
  letter-spacing: -1.2px;
  margin-bottom: 10px;
}
.hero h1 em { font-style: italic; color: var(--tx-3); }
.hero p {
  font-size: 16px;
  color: var(--tx-2);
  font-weight: 300;
  margin-bottom: 26px;
}
.hero-ctas { display: flex; gap: 10px; flex-wrap: wrap; }

.btn-primary {
  height: 42px; padding: 0 22px;
  background: var(--accent); color: var(--accent-fg);
  border: none; border-radius: var(--r);
  font-size: 14px; font-weight: 500; font-family: 'Geist', sans-serif;
  cursor: pointer; transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--accent-hv); transform: translateY(-1px); }

.btn-secondary {
  height: 42px; padding: 0 22px;
  background: var(--surface); color: var(--tx);
  border: 1px solid var(--border-2); border-radius: var(--r);
  font-size: 14px; font-family: 'Geist', sans-serif;
  cursor: pointer; transition: border-color 0.15s, transform 0.1s;
}
.btn-secondary:hover { border-color: var(--tx); transform: translateY(-1px); }

/* ── HOME CARDS ────────────────────────────────────────── */
.home-cards {
  padding: 36px 0 52px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 16px;
}

.home-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 26px;
  cursor: pointer;
  transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease), border-color 0.2s;
}
.home-card:hover {
  box-shadow: 0 8px 28px rgba(0,0,0,0.09);
  transform: translateY(-3px);
  border-color: var(--border-2);
}

.card-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: var(--r);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
}
.chip-image { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-bd); }
.chip-pdf   { background: var(--blue-bg);  color: var(--blue);  border: 1px solid var(--blue-bd);  }
.chip-doc   { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-bd); }

.home-card h3 {
  font-family: 'Geist', sans-serif;
  font-size: 17px; font-weight: 600;
  letter-spacing: -0.3px; margin-bottom: 6px;
}
.home-card p {
  font-size: 13.5px; color: var(--tx-2);
  line-height: 1.6; margin-bottom: 16px;
}

.feature-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.feature-pill {
  font-size: 12px; padding: 3px 9px;
  border-radius: 20px;
  background: var(--surface-2); color: var(--tx-2);
  border: 1px solid var(--border);
}

/* ── TOOL PAGE HEADER ──────────────────────────────────── */
.tool-header {
  padding: 38px 0 26px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 26px;
}
.tool-header h1 {
  font-size: clamp(24px, 3.5vw, 38px);
  letter-spacing: -0.5px;
  margin-bottom: 5px;
}
.tool-header p { font-size: 14.5px; color: var(--tx-2); font-weight: 300; }

/* ── TABS ──────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 3px;
  margin-bottom: 26px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: var(--r);
  width: fit-content;
  border: 1px solid var(--border);
}
.tab-btn {
  height: 30px; padding: 0 14px;
  border-radius: 6px;
  font-size: 13px; font-weight: 400;
  font-family: 'Geist', sans-serif;
  color: var(--tx-2);
  background: transparent; border: none;
  cursor: pointer; transition: all 0.15s;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--tx); }
.tab-btn.active {
  background: var(--surface); color: var(--tx); font-weight: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}

/* ── TOOL PANELS ───────────────────────────────────────── */
.tool-panel { display: none; }
.tool-panel.active { display: block; }

/* ── UPLOAD ZONE ───────────────────────────────────────── */
.drop-zone {
  border: 1.5px dashed var(--border-2);
  border-radius: var(--rl);
  background: var(--surface);
  padding: 40px 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 16px;
  position: relative;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--tx);
  background: var(--surface-2);
}
.drop-zone input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}
.dz-icon {
  width: 40px; height: 40px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 12px; font-size: 17px;
}
.dz-title { font-size: 14.5px; font-weight: 500; margin-bottom: 3px; }
.dz-subtitle { font-size: 13px; color: var(--tx-3); }
.dz-filename {
  font-size: 13.5px; font-weight: 500; color: var(--green);
  margin-top: 5px; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── SETTINGS CARD ─────────────────────────────────────── */
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.settings-title {
  font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--tx-3); margin-bottom: 14px;
}
.settings-row { margin-bottom: 12px; }
.settings-row:last-child { margin-bottom: 0; }
.settings-label {
  font-size: 13px; color: var(--tx-2);
  margin-bottom: 6px;
  display: flex; justify-content: space-between;
}
.settings-label strong { font-weight: 600; color: var(--tx); font-size: 13px; }

/* ── OPTION PILLS ──────────────────────────────────────── */
.opts { display: flex; gap: 5px; flex-wrap: wrap; }
.opt {
  height: 30px; padding: 0 13px;
  border-radius: 20px; font-size: 13px;
  font-family: 'Geist', sans-serif;
  color: var(--tx-2);
  background: var(--surface-2); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.15s;
}
.opt:hover { border-color: var(--border-2); color: var(--tx); }
.opt.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 500; }

/* ── FORM INPUTS ───────────────────────────────────────── */
input[type="range"] {
  width: 100%; accent-color: var(--accent);
  cursor: pointer; outline: none; border: none;
}
input[type="number"], input[type="text"] {
  height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--r);
  font-size: 13.5px; background: var(--surface); color: var(--tx);
  font-family: 'Geist', sans-serif; outline: none;
  transition: border-color 0.15s;
}
input[type="number"]:focus,
input[type="text"]:focus { border-color: var(--border-2); }
input[type="checkbox"] { accent-color: var(--accent); }

/* ── FILE LIST ─────────────────────────────────────────── */
.file-list { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.file-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); font-size: 13px;
}
.file-item .fi-name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .fi-size { color: var(--tx-3); font-size: 11.5px; flex-shrink: 0; }
.file-item .fi-del {
  background: none; border: none; cursor: pointer;
  color: var(--tx-3); padding: 2px 5px; border-radius: 4px;
  transition: color 0.15s, background 0.15s; font-size: 14px;
}
.file-item .fi-del:hover { color: var(--red); background: var(--red-bg); }

/* ── RUN BUTTON ────────────────────────────────────────── */
.btn-run {
  width: 100%; height: 42px;
  background: var(--accent); color: var(--accent-fg);
  border: none; border-radius: var(--r);
  font-size: 14.5px; font-weight: 500;
  font-family: 'Geist', sans-serif;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  margin-top: 2px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-run:hover:not(:disabled) { background: var(--accent-hv); transform: translateY(-1px); }
.btn-run:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

/* ── PROGRESS ──────────────────────────────────────────── */
.progress-wrap { margin: 14px 0; display: none; }
.progress-wrap.visible { display: block; }
.progress-label { font-size: 12.5px; color: var(--tx-2); margin-bottom: 5px; }
.progress-bar { height: 3px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s ease; width: 0%; }

/* ── RESULT PANEL ──────────────────────────────────────── */
.result-panel {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 20px 22px;
  display: none;
}
.result-panel.visible { display: block; }

.result-header { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.result-title { font-weight: 600; font-size: 14.5px; }

.badge {
  font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px; letter-spacing: 0.02em;
}
.badge-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-bd); }
.badge-warn    { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-bd); }

.result-file {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px;
  background: var(--surface-2); border-radius: var(--r);
  margin-bottom: 12px; border: 1px solid var(--border);
}
.result-file-icon {
  width: 34px; height: 34px;
  background: var(--surface); border-radius: 6px;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.result-file-info { flex: 1; overflow: hidden; }
.result-file-name { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-file-meta { font-size: 11.5px; color: var(--tx-3); margin-top: 1px; }

.result-actions { display: flex; gap: 7px; flex-wrap: wrap; }

.btn-download {
  height: 36px; padding: 0 16px;
  background: var(--accent); color: var(--accent-fg);
  border: none; border-radius: var(--r);
  font-size: 13px; font-weight: 500;
  font-family: 'Geist', sans-serif; cursor: pointer;
  transition: background 0.15s;
}
.btn-download:hover { background: var(--accent-hv); }

.btn-share {
  height: 36px; padding: 0 16px;
  background: var(--surface); color: var(--tx);
  border: 1px solid var(--border-2); border-radius: var(--r);
  font-size: 13px; font-family: 'Geist', sans-serif;
  cursor: pointer; transition: border-color 0.15s;
}
.btn-share:hover { border-color: var(--tx); }

.btn-reset {
  height: 36px; padding: 0 12px;
  background: none; color: var(--tx-2);
  border: none; border-radius: var(--r);
  font-size: 13px; cursor: pointer;
  font-family: 'Geist', sans-serif; transition: color 0.15s;
}
.btn-reset:hover { color: var(--tx); }

/* ── IMAGE PREVIEW ─────────────────────────────────────── */
.img-preview {
  max-width: 100%; max-height: 200px;
  border-radius: var(--r); border: 1px solid var(--border);
  display: block; margin-bottom: 12px; object-fit: contain;
}
.checker-bg {
  background: repeating-conic-gradient(#e0e0e0 0% 25%, white 0% 50%) 0 0/18px 18px;
}

/* ── DOCS EDITOR ───────────────────────────────────────── */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.editor-pane label {
  display: block;
  font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--tx-3); margin-bottom: 7px;
}
textarea {
  width: 100%; padding: 13px;
  border: 1px solid var(--border); border-radius: var(--r);
  font-size: 13.5px; font-family: 'Geist', sans-serif;
  color: var(--tx); background: var(--surface);
  resize: vertical; min-height: 240px; outline: none;
  line-height: 1.7; transition: border-color 0.15s;
}
textarea:focus { border-color: var(--border-2); }
textarea[readonly] { background: var(--surface-2); }

.editor-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 12px; }

.btn-editor {
  height: 34px; padding: 0 14px;
  background: var(--surface); color: var(--tx);
  border: 1px solid var(--border-2); border-radius: var(--r);
  font-size: 13px; font-family: 'Geist', sans-serif;
  cursor: pointer; transition: border-color 0.15s;
}
.btn-editor:hover { border-color: var(--tx); }
.btn-editor.primary {
  background: var(--accent); color: var(--accent-fg); border-color: var(--accent);
}
.btn-editor.primary:hover { background: var(--accent-hv); }

/* ── ERROR MESSAGE ─────────────────────────────────────── */
.error-msg {
  background: var(--red-bg); border: 1px solid #FECACA;
  border-radius: var(--r); padding: 10px 14px;
  font-size: 13px; color: var(--red);
  margin-bottom: 12px; display: none;
}
.error-msg.visible { display: block; }

/* ── INLINE DOWNLOAD BTN (in lists) ───────────────────── */
.btn-dl-sm {
  height: 26px; padding: 0 10px;
  background: var(--accent); color: var(--accent-fg);
  border: none; border-radius: 5px;
  font-size: 12px; font-weight: 500;
  font-family: 'Geist', sans-serif;
  cursor: pointer; transition: background 0.15s;
  flex-shrink: 0;
}
.btn-dl-sm:hover { background: var(--accent-hv); }

/* ── AD SLOT ───────────────────────────────────────────── */
.ad-slot {
  margin: 28px 0 6px;
  padding: 10px 18px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--r);
  text-align: center;
  font-size: 11.5px; color: var(--tx-3);
  letter-spacing: 0.05em;
}

/* ── TOAST ─────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 22px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--accent); color: var(--accent-fg);
  padding: 9px 18px; border-radius: var(--r);
  font-size: 13px; font-weight: 500;
  z-index: 999; opacity: 0;
  transition: opacity 0.22s, transform 0.22s;
  pointer-events: none; white-space: nowrap;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── SPACER ────────────────────────────────────────────── */
.page-end { height: 40px; }

/* ── RESPONSIVE ────────────────────────────────────────── */
@media (max-width: 640px) {
  .wrap            { padding: 0 16px; }
  .nav-inner       { padding: 0 16px; }
  .hero            { padding: 32px 0 28px; }
  .tabs            { flex-wrap: wrap; width: 100%; }
  .editor-grid     { grid-template-columns: 1fr; }
  .result-actions  { flex-direction: column; }
  .result-actions button { width: 100%; justify-content: center; }
}
