@font-face { font-family: Raleway; font-weight: 400; font-display: swap; src: url("fonts/Raleway-400.ttf") format("truetype"); }
@font-face { font-family: Raleway; font-weight: 600; font-display: swap; src: url("fonts/Raleway-600.ttf") format("truetype"); }
@font-face { font-family: Raleway; font-weight: 700; font-display: swap; src: url("fonts/Raleway-700.ttf") format("truetype"); }
@font-face { font-family: Raleway; font-weight: 800; font-display: swap; src: url("fonts/Raleway-800.ttf") format("truetype"); }

/* Paleta vermelha (vinho, vermelho e um toque de dourado) */
:root {
  --dark: #7d0a1a;
  --brand: #d4001c;
  --brand-hover: #a8001a;
  --brand-soft: #fdecee;
  --accent: #ffc72c;
  --orange: #d9480f;
  --green: #168821;
  --amber: #c58b00;
  --red: #d83933;
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1b2433;
  --muted: #5d6b82;
  --line: #dfe4ec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(125, 10, 26, .06), 0 6px 20px rgba(125, 10, 26, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 Raleway, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: lining-nums; font-feature-settings: "lnum";
  min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; width: 100%; }
a { color: var(--brand); }
svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2;
      stroke-linecap: round; stroke-linejoin: round; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right)); }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .85em; }

/* ───────── topo ───────── */
.topbar { background: var(--dark); color: #fff; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.logo svg { width: 38px; height: 38px; stroke: none; }
.logo strong { display: block; font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.logo strong b { color: var(--accent); }
.logo small { display: block; font-size: .72rem; opacity: .8; font-weight: 600; letter-spacing: .02em; }
.stripe { display: flex; height: 4px; }
.stripe i { flex: 1; }
.stripe i:nth-child(1) { background: var(--brand); }
.stripe i:nth-child(2) { background: var(--accent); }
.stripe i:nth-child(3) { background: #fff; }

/* ───────── abas ───────── */
.tabs { display: flex; justify-content: center; gap: 8px; width: 100%; margin: 18px auto 16px; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 999px;
  text-decoration: none; color: var(--dark); font-weight: 700; background: #fff; border: 1px solid var(--line);
  transition: background .15s, color .15s;
}
.tab svg { width: 18px; height: 18px; }
.tab.active { background: var(--dark); color: #fff; border-color: var(--dark); }

/* ───────── cartões e campos ───────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
        box-shadow: var(--shadow); }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.aside { position: sticky; top: 16px; }

.step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.step-head h2 { margin: 0; font-size: 1.12rem; color: var(--dark); }
.num { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff;
       display: grid; place-items: center; font-weight: 800; font-size: .9rem; }

.field { display: block; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.lbl { display: block; font-weight: 700; font-size: .92rem; margin-bottom: 6px; color: var(--dark); }
.lbl em, summary em { font-style: normal; font-weight: 600; font-size: .75rem; color: var(--muted); margin-left: 4px; }
.hint { color: var(--muted); font-size: .84rem; }
.field .hint { display: block; margin-top: 6px; }

input[type=text], input[type=search], textarea {
  width: 100%; padding: 12px 14px; font: inherit; font-size: 1rem; color: inherit; background: #fff;
  border: 1.5px solid #c5cedd; border-radius: 10px; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(212, 0, 28, .18); }
.more summary { cursor: pointer; font-weight: 700; color: var(--brand); font-size: .92rem; padding: 4px 0; list-style: none; }
.more summary::before { content: "+ "; }
.more[open] summary::before { content: "− "; }
.more textarea { margin-top: 8px; }

/* modo foto / texto */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; background: var(--bg);
             border-radius: 12px; margin-bottom: 14px; }
.seg { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 8px; border: none;
       border-radius: 9px; background: transparent; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg.active { background: #fff; color: var(--dark); box-shadow: 0 1px 4px rgba(125, 10, 26, .15); }

.drop { display: block; position: relative; border: 2px dashed #b9c5d8; border-radius: 12px; background: #fafbfd;
        cursor: pointer; overflow: hidden; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 16px; text-align: center; color: var(--dark); }
.drop-empty svg { width: 40px; height: 40px; color: var(--brand); }
.drop-empty small { color: var(--muted); }
.drop img { display: block; width: 100%; max-height: 420px; object-fit: contain; background: #eef1f6; }
.drop.has-img .drop-empty { display: none; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }

.sheet-wrap { margin-top: 4px; }
.sheet-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap;
               font-weight: 800; color: var(--dark); text-transform: uppercase; letter-spacing: .06em; font-size: .78rem;
               margin-bottom: 6px; }
.sheet-title .hint { text-transform: none; letter-spacing: 0; font-weight: 600; }
.sheet { position: relative; display: block; border: 1.5px solid #c5cedd; border-radius: 10px; overflow: hidden; background: #fff; }
.sheet:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(212, 0, 28, .18); }
.gutter { position: absolute; top: 0; bottom: 0; left: 0; width: 38px; background: #f4f6fa; border-right: 1px solid #e2e7ef; color: #98a3b5;
          font-size: .72rem; text-align: right; padding: 10px 7px 0 0; line-height: 30px; overflow: hidden; user-select: none; }
.sheet textarea { display: block; margin-left: 38px; width: calc(100% - 38px); border: none; border-radius: 0; box-shadow: none !important; line-height: 30px; padding: 10px 14px 0;
                  min-height: 340px; resize: vertical; font-size: 1rem;
                  background: repeating-linear-gradient(to bottom, transparent 0 29px, #dbe2ee 29px 30px);
                  background-attachment: local; background-position: 0 10px; }

/* botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px;
       border-radius: 999px; border: 1.5px solid transparent; font: inherit; font-weight: 700; font-size: .95rem;
       cursor: pointer; text-decoration: none; transition: background .15s, transform .05s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn.ghost { background: #fff; color: var(--brand); border-color: var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.link { background: none; color: var(--brand); padding: 8px 6px; }
.btn.big { width: 100%; padding: 16px; font-size: 1.08rem; box-shadow: 0 4px 14px rgba(212, 0, 28, .3); }
.btn.danger { color: var(--red); }

.msg { margin: 0; min-height: 1.4em; font-weight: 600; }
.msg.error { color: var(--red); }
.msg.ok { color: var(--green); }
.spinner { display: inline-block; width: 15px; height: 15px; margin-right: 8px; vertical-align: -2px;
           border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* lateral: critérios */
.aside h3 { margin: 0 0 4px; color: var(--dark); font-size: 1rem; }
.crit { list-style: none; counter-reset: c; padding: 0; margin: 14px 0 0; }
.crit li { counter-increment: c; display: grid; grid-template-columns: 30px 1fr; column-gap: 10px; padding: 10px 0;
           border-top: 1px solid var(--line); font-size: .9rem; }
.crit li::before { content: "C" counter(c); grid-row: span 2; font-weight: 800; color: var(--brand); }
.crit b { color: var(--dark); }
.crit span { color: var(--muted); font-size: .82rem; }

/* ───────── espera ───────── */
.waiting { max-width: 560px; margin: 20px auto; text-align: center; padding: 34px 24px; }
.waiting h2 { color: var(--dark); margin: 14px 0 4px; }
.pen svg { width: 84px; height: 84px; stroke-width: 3; }
.pen path { stroke: var(--brand); stroke-dasharray: 28; stroke-dashoffset: 28; animation: write 2.4s ease-in-out infinite; }
.pen .w2 { animation-delay: .4s; }
.pen .w3 { animation-delay: .8s; }
@keyframes write { 0% { stroke-dashoffset: 28; } 40%, 70% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -28; } }
.timer { font-size: 2rem; font-weight: 800; color: var(--dark); margin: 8px 0 16px; font-variant-numeric: tabular-nums; }
.code-box { display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--bg);
            border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.code-box .lbl { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; margin: 0; }
.code-box code { font-size: .85rem; word-break: break-all; }

/* ───────── correções ───────── */
.search { margin-bottom: 16px; }
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92rem; }
.search .msg { margin-top: 10px; }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.list-head h2 { margin: 0; font-size: 1.12rem; color: var(--dark); }
.list-head input { max-width: 280px; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { border-top: 1px solid var(--line); display: flex; align-items: center; }
.history a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 14px 4px; color: inherit;
             text-decoration: none; border-radius: 10px; }
.h-theme { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history a:hover { background: #f8fafd; }
.badge { width: 58px; height: 58px; flex: none; border-radius: 14px; display: grid; place-items: center; color: #fff;
         font-weight: 800; font-size: 1.05rem; line-height: 1; text-align: center; }
.badge small { display: block; font-size: .6rem; font-weight: 600; opacity: .85; margin-top: 2px; }
.badge.wait { background: #e4e9f2; color: var(--muted); }
.h-main { flex: 1; min-width: 0; }
.h-title { display: block; font-weight: 700; color: var(--dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-sub { color: var(--muted); font-size: .84rem; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.h-sub svg { width: 15px; height: 15px; vertical-align: -3px; }
.h-del { background: none; border: none; color: #98a3b5; padding: 10px; border-radius: 10px; cursor: pointer; }
.h-del:hover { color: var(--red); background: #fdecec; }
.empty { color: var(--muted); padding: 26px 4px; text-align: center; }

/* ───────── resultado ───────── */
.result { display: flex; flex-direction: column; gap: 16px; }
.hero { display: flex; gap: 26px; align-items: center; background: linear-gradient(135deg, #ffffff 55%, #fff1f2); }
.ring { position: relative; width: 160px; height: 160px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); stroke-linecap: round; }
.ring-bg { stroke: #e6ebf3; stroke-width: 11; }
.ring-fg { stroke: var(--green); stroke-width: 11; stroke-dasharray: 326.73; stroke-dashoffset: 326.73;
           transition: stroke-dashoffset 1s ease-out; }
.ring-num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-num strong { font-size: 2.6rem; font-weight: 800; color: var(--dark); line-height: 1; }
.ring-num span { font-size: .8rem; color: var(--muted); font-weight: 600; }
.hero-info { flex: 1; min-width: 0; }
.chip { display: inline-block; padding: 3px 12px; border-radius: 999px; color: #fff; font-weight: 700; font-size: .8rem; }
.hero h2 { margin: 8px 0 10px; color: var(--dark); font-size: 1.3rem; line-height: 1.3; }
.meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; margin: 0 0 14px; }
.meta .wide { grid-column: 1 / -1; }
.meta dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.meta dd { margin: 0; font-weight: 600; word-break: break-word; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.result-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.side { position: sticky; top: 16px; }
.card-title { margin: 0 0 12px; color: var(--dark); font-size: 1.02rem; font-weight: 800; }
summary.card-title { margin: 0; cursor: pointer; }
.text-card[open] summary { margin-bottom: 10px; }

.scorecard { width: 100%; border-collapse: collapse; }
.scorecard th { font-size: .7rem; color: var(--muted); font-weight: 700; padding: 0 2px 8px; text-align: center; }
.scorecard th.l { text-align: left; }
.scorecard td { border-top: 1px solid var(--line); padding: 9px 2px; text-align: center; }
.scorecard td.l { text-align: left; font-weight: 700; color: var(--dark); }
.scorecard td.l small { display: block; font-weight: 500; color: var(--muted); font-size: .76rem; line-height: 1.3; }
.bubble { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #b4bfd0; }
.bubble.on { background: var(--dark); border-color: var(--dark); box-shadow: 0 0 0 3px rgba(125, 10, 26, .15); }

.general p { margin: 0; white-space: pre-wrap; }
.general { background: #fffbea; border-color: #ffe58a; }

.comp { padding: 0; overflow: hidden; }
.comp > summary { list-style: none; cursor: pointer; padding: 16px 20px; display: grid;
                  grid-template-columns: auto 1fr auto; gap: 4px 14px; align-items: center; }
.comp > summary::-webkit-details-marker { display: none; }
.comp-tag { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-soft); color: var(--brand);
            display: grid; place-items: center; font-weight: 800; grid-row: span 2; }
.comp-name { font-weight: 800; color: var(--dark); line-height: 1.3; }
.comp-pts { font-weight: 800; font-size: 1.25rem; white-space: nowrap; grid-row: span 2; text-align: right; }
.comp-pts small { font-size: .75rem; color: var(--muted); font-weight: 600; }
.bar { height: 7px; background: #e8edf4; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; width: 0; transition: width .9s ease-out; }
.comp-body { padding: 0 20px 18px; border-top: 1px solid var(--line); }
.comp-desc { color: var(--muted); font-size: .84rem; margin: 12px 0 4px; }
.fb h4 { margin: 14px 0 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; display: flex; align-items: center; gap: 6px; }
.fb h4::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.fb.fortes h4 { color: var(--green); }
.fb.melhoria h4 { color: var(--orange); }
.fb.sugestoes h4 { color: var(--dark); }
.fb ul { margin: 0; padding-left: 20px; }
.fb li { margin: 5px 0; }
.chev { transition: transform .2s; color: var(--muted); }
.comp[open] .chev { transform: rotate(180deg); }

.photo-btn { display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
             cursor: zoom-in; background: #eef1f6; margin-bottom: 6px; }
.photo-btn img { display: block; width: 100%; max-height: 460px; object-fit: contain; }
.essay-body p { margin: 0 0 10px; text-indent: 1.6em; font-size: .95rem; }

dialog#lightbox { padding: 0; border: none; background: transparent; max-width: 100vw; max-height: 100vh; }
dialog#lightbox::backdrop { background: rgba(10, 20, 40, .85); }
dialog#lightbox img { display: block; max-width: 96vw; max-height: 92vh; object-fit: contain; border-radius: 6px; }
dialog#lightbox .close { position: fixed; top: 12px; right: 14px; width: 44px; height: 44px; border-radius: 50%;
                         border: none; background: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer; }

.foot { width: 100%; color: var(--muted); font-size: .78rem; text-align: center; padding-top: 28px; padding-bottom: 28px; }

/* ───────── tablet ───────── */
@media (max-width: 960px) {
  .layout, .result-grid { grid-template-columns: minmax(0, 1fr); }
  .aside, .side { position: static; }
  .aside { order: -1; }
  .crit { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 16px; }
}

/* ───────── celular ───────── */
@media (max-width: 600px) {
  body { font-size: 15.5px; }
  .topbar-inner { min-height: 56px; }
  .logo svg { width: 32px; height: 32px; }
  .logo small { display: none; }
  .tabs { margin: 12px auto; }
  .tab { flex: 1; justify-content: center; padding: 10px 8px; font-size: .92rem; }
  .card { padding: 16px; border-radius: 12px; }
  .aside { display: none; }
  .hero { flex-direction: column; text-align: center; gap: 14px; }
  .meta { text-align: left; }
  .hero-actions { justify-content: center; }
  .hero-actions .btn.primary { width: 100%; }
  .ring { width: 140px; height: 140px; }
  .search-row { flex-direction: column; }
  .list-head input { max-width: none; }
  .scorecard th { font-size: .62rem; }
  .bubble { width: 14px; height: 14px; border-width: 1.5px; }
  .scorecard td.l small { display: none; }
  .comp > summary { padding: 14px 16px; gap: 4px 10px; }
  .comp-tag { width: 38px; height: 38px; }
  .comp-body { padding: 0 16px 16px; }
  .badge { width: 52px; height: 52px; }
  .gutter { width: 30px; padding-right: 5px; }
  .sheet textarea { margin-left: 30px; width: calc(100% - 30px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .topbar, .tabs, .foot, .hero-actions, .view:not(#view-resultado) { display: none !important; }
  body, .card { background: #fff; box-shadow: none; }
}
