:root {
  --brand: #ff5a1f;
  --brand-dark: #e0440d;
  --brand-light: #fff1ea;
  --ink: #1f2430;
  --ink-soft: #5b6472;
  --bg: #fafafa;
  --card: #ffffff;
  --border: #e8e8ee;
  --ok: #16a34a;
  --err: #dc2626;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}
header { background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.nav { max-width: 1180px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.logo { font-size: 25px; font-weight: 800; letter-spacing: -0.5px; }
.logo .i { color: var(--ink); }
.logo .eat { color: var(--brand); }
.logo-emoji { font-size: 25px; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
[dir="rtl"] .nav-right { margin-left: 0; margin-right: auto; }
.nav-tag { font-size: 12.5px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; flex: none; }
#langSel { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 13.5px; cursor: pointer; }

/* ---------- Agent Mode ---------- */
.agent-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(120deg, #ff5a1f, #ff2e7e, #7c3aed);
  background-size: 220% 220%;
  color: #fff; border: none; padding: 10px 20px; border-radius: 999px;
  font-size: 14.5px; font-weight: 700; cursor: pointer;
  animation: agentGradient 5s ease infinite;
  box-shadow: 0 4px 16px rgba(255, 90, 31, .35);
  transition: transform .15s;
}
.agent-btn:hover { transform: scale(1.05); }
@keyframes agentGradient { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

.agent-view { max-width: 880px; margin: 0 auto; padding: 28px 20px 80px; display: none; }
.agent-view.open { display: block; }
@property --agent-angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
.agent-zone {
  position: relative; text-align: center; padding: 80px 30px; cursor: pointer;
  border-radius: 22px; border: 3px solid transparent;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    conic-gradient(from var(--agent-angle, 0deg), #ff5a1f, #ff2e7e, #7c3aed, #2563eb, #ff5a1f) border-box;
  animation: agentEnter .45s cubic-bezier(.2, .9, .3, 1.2) both, agentSpin 3.5s linear infinite;
}
@keyframes agentSpin { to { --agent-angle: 360deg; } }
@keyframes agentEnter { from { opacity: 0; transform: scale(.85) translateY(24px); } to { opacity: 1; transform: none; } }
.agent-zone.dragover {
  background:
    linear-gradient(var(--brand-light), var(--brand-light)) padding-box,
    conic-gradient(from var(--agent-angle, 0deg), #ff5a1f, #ff2e7e, #7c3aed, #2563eb, #ff5a1f) border-box;
}
.agent-zone h3 { font-size: 24px; margin-top: 18px; }
.agent-zone p { color: var(--ink-soft); margin-top: 8px; font-size: 15px; }
.agent-orb {
  width: 86px; height: 86px; margin: 0 auto; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 34px; color: #fff;
  background: linear-gradient(135deg, #ff5a1f, #ff2e7e, #7c3aed);
  background-size: 200% 200%;
  animation: agentGradient 4s ease infinite, agentBob 2.4s ease-in-out infinite;
  box-shadow: 0 10px 30px rgba(124, 58, 237, .35);
}
@keyframes agentBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.agent-zone.thinking .agent-orb { animation: agentGradient 1s ease infinite, agentPulse .7s ease-in-out infinite; }
@keyframes agentPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }

.agent-result { margin-top: 26px; }
.agent-badge {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 6px; animation: agentEnter .4s ease both;
}
.agent-badge .pill {
  background: var(--ink); color: #fff; padding: 7px 16px; border-radius: 999px;
  font-size: 13.5px; font-weight: 700;
}
.agent-badge .fname { font-size: 13.5px; color: var(--ink-soft); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-result h4 { text-align: center; font-size: 17px; margin: 14px 0 16px; }
.agent-result .grid { margin: 0; padding: 0; }
.agent-result .card { animation: agentEnter .4s ease both; }

.hero { text-align: center; padding: 46px 20px 20px; }
.hero h1 { font-size: clamp(28px, 5vw, 42px); font-weight: 800; letter-spacing: -1px; }
.hero h1 span { color: var(--brand); }
.hero p { margin-top: 12px; color: var(--ink-soft); font-size: 16.5px; max-width: 680px; margin-left: auto; margin-right: auto; }

.chips { max-width: 1180px; margin: 22px auto 0; padding: 0 20px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip {
  border: 1px solid var(--border); background: var(--card); color: var(--ink-soft);
  padding: 8px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer; transition: .12s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.grid {
  max-width: 1180px; margin: 24px auto 60px; padding: 0 20px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 14px;
}
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 18px; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(0,0,0,.08); border-color: var(--brand); }
.card .ico { font-size: 26px; width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.card .ico svg { width: 28px; height: 28px; }
.card h3 { margin-top: 12px; font-size: 16px; }
.card p { margin-top: 5px; font-size: 13px; color: var(--ink-soft); line-height: 1.45; }

/* per-category icon tints */
.tint-organize { background: #fff1ea; color: #ff5a1f; }
.tint-optimize { background: #e9f9ef; color: #16a34a; }
.tint-convertto { background: #eaf2ff; color: #2563eb; }
.tint-convertfrom { background: #f3eaff; color: #7c3aed; }
.tint-edit { background: #fdeef5; color: #db2777; }
.tint-security { background: #eef6f8; color: #0e7490; }

.tool-view { max-width: 780px; margin: 0 auto; padding: 28px 20px 80px; display: none; }
.back-btn { background: none; border: none; color: var(--brand); font-size: 15px; font-weight: 600; cursor: pointer; padding: 6px 0; margin-bottom: 10px; }
.tool-head { text-align: center; margin-bottom: 22px; }
.tool-head .ico { font-size: 36px; width: 76px; height: 76px; border-radius: 18px; margin: 0 auto; display: flex; align-items: center; justify-content: center; }
.tool-head .ico svg { width: 40px; height: 40px; }
.tool-head h2 { font-size: 27px; margin-top: 12px; }
.tool-head p { color: var(--ink-soft); margin-top: 6px; }

.dropzone {
  border: 2.5px dashed #d8d8e2; border-radius: var(--radius); background: var(--card);
  padding: 50px 24px; text-align: center; cursor: pointer; transition: .15s;
}
.dropzone.dragover { border-color: var(--brand); background: var(--brand-light); }
.dropzone .big { font-size: 38px; color: var(--brand); }
.dropzone h4 { margin-top: 12px; font-size: 18px; }
.dropzone p { color: var(--ink-soft); font-size: 14px; margin-top: 6px; }
.dz-btn {
  display: inline-block; margin-top: 18px; background: var(--brand); color: #fff;
  padding: 13px 34px; border-radius: 10px; font-weight: 700; font-size: 16px; border: none; cursor: pointer;
}
.dz-btn:hover { background: var(--brand-dark); }

.filelist { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.file-row {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; display: flex; align-items: center; gap: 10px; font-size: 14px;
}
.file-row .ficon { color: var(--brand); }
.file-row .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-row .fsize { color: var(--ink-soft); font-size: 12.5px; }
.file-row button { border: 1px solid var(--border); background: #fff; border-radius: 7px; width: 28px; height: 28px; cursor: pointer; font-size: 12px; color: var(--ink-soft); }
.file-row button:hover { border-color: var(--brand); color: var(--brand); }

.custom-box { margin-top: 18px; display: none; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.sig-pad { border: 1.5px dashed #ccc; border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; display: block; width: 100%; max-width: 460px; margin: 10px auto; }
.cam-video { width: 100%; max-width: 460px; border-radius: 10px; display: block; margin: 10px auto; background: #000; }
.shots { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.shots img { height: 70px; border-radius: 8px; border: 1px solid var(--border); }
.mini-btn {
  background: var(--ink); color: #fff; border: none; padding: 9px 18px; border-radius: 8px;
  font-weight: 600; font-size: 13.5px; cursor: pointer; margin: 4px;
}
.mini-btn.alt { background: #fff; color: var(--ink); border: 1px solid var(--border); }
.mini-btn:hover { opacity: .88; }

.options { margin-top: 18px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: none; }
.options h4 { font-size: 15px; margin-bottom: 12px; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 0; flex-wrap: wrap; }
.opt-row label { font-size: 14px; font-weight: 500; max-width: 55%; }
.opt-row .hint { display: block; font-size: 12px; color: var(--ink-soft); font-weight: 400; margin-top: 2px; }
.opt-row select, .opt-row input[type=text], .opt-row input[type=password], .opt-row input[type=number] {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; min-width: 180px; background: #fff;
}
.opt-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
.opt-row textarea {
  width: 100%; min-height: 130px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; font-family: ui-monospace, Menlo, monospace; resize: vertical;
}

.process-btn {
  margin-top: 20px; width: 100%; background: var(--brand); color: #fff; border: none;
  padding: 16px; border-radius: 12px; font-size: 17px; font-weight: 800; cursor: pointer; display: none;
}
.process-btn:hover { background: var(--brand-dark); }
.process-btn:disabled { opacity: .6; cursor: wait; }

.status { margin-top: 14px; text-align: center; font-size: 14.5px; color: var(--ink-soft); min-height: 22px; }
.status.err { color: var(--err); font-weight: 600; }

.result {
  margin-top: 20px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px 22px; text-align: center; display: none;
}
.result .big { font-size: 40px; color: var(--ok); }
.result h3 { margin-top: 10px; font-size: 20px; }
.result p { color: var(--ink-soft); font-size: 14px; margin-top: 6px; }
.dl-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.dl-btn {
  display: inline-flex; align-items: center; gap: 8px; background: var(--ok); color: #fff;
  padding: 12px 28px; border-radius: 10px; font-weight: 700; font-size: 15px; border: none; cursor: pointer; text-decoration: none;
}
.dl-btn:hover { filter: brightness(.94); }
.again-btn { margin-top: 14px; background: none; border: none; color: var(--brand); font-weight: 600; cursor: pointer; font-size: 14px; }

footer { border-top: 1px solid var(--border); padding: 24px 20px; text-align: center; color: var(--ink-soft); font-size: 13.5px; background: var(--card); line-height: 1.8; }
footer b { color: var(--ink); }

.spinner {
  display: inline-block; width: 16px; height: 16px; border: 2.5px solid var(--brand-light);
  border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; margin-right: 8px;
}
[dir="rtl"] .spinner { margin-right: 0; margin-left: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .nav-tag { display: none; }
  .opt-row label { max-width: 100%; }
}
