:root {
  --orange: #e84e1b; --orange-d: #c93f12; --pale: #fdf0eb;
  --ink: #141414; --ink-2: #5b5b5b; --line: #e7e3df; --bg: #faf8f6; --card: #fff;
  --ok: #1f7a4d; --danger: #b3261e;
  --radius: 14px;
  --sans: 'Jost', system-ui, sans-serif; --serif: 'Lora', Georgia, serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--sans); background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.4; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.ic { flex: none; display: block; }
[hidden] { display: none !important; }

/* ---------- Barra superior ---------- */
.top { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); }
.top-in { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { font-family: var(--serif); font-weight: 700; font-size: 26px; color: var(--orange); letter-spacing: .5px; line-height: 1; }
.brand small { display: block; font-family: var(--sans); font-weight: 500; font-size: 10px; letter-spacing: 3px; color: var(--ink); margin-top: 3px; }
.search { flex: 1 1 220px; position: relative; min-width: 0; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-2); }
.search input { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 999px; padding: 0 16px 0 40px; background: var(--bg); }
.search input:focus { outline: 2px solid var(--orange); background: #fff; }
.top-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.primary:hover { background: var(--orange-d); }
.btn.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.icon { width: 44px; padding: 0; }
.btn.icon.sm { width: 36px; }
.btn:focus-visible, .tile:focus-visible, .chip:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

/* ---------- Contenido ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 80px; }
.hello { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.hello h1 { font-family: var(--serif); font-size: 26px; margin: 0; }
.hello p { margin: 0; color: var(--ink-2); font-size: 14px; }
.editbar { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 12px 16px; margin: 12px 0 4px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.editbar span { flex: 1 1 240px; }
.editbar .btn { background: transparent; color: #fff; border-color: #555; }
.editbar .btn:hover { border-color: #fff; }
.sec { margin-top: 28px; }
.sec-h { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; min-height: 36px; }
.sec-h h2 { font-size: 13px; letter-spacing: 2px; text-transform: uppercase; font-weight: 600; margin: 0; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.sec-h h2 .ic { color: var(--orange); }
.sec-h .line { flex: 1; height: 1px; background: var(--line); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }

/* ---------- Tarjetas ---------- */
.tile { position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: inherit; min-height: 88px; transition: transform .12s, box-shadow .12s, border-color .12s; }
a.tile:hover { border-color: var(--orange); box-shadow: 0 6px 18px rgba(232, 78, 27, .12); transform: translateY(-2px); }
.badge { width: 48px; height: 48px; border-radius: 12px; background: var(--pale); color: var(--orange); display: grid; place-items: center; flex: none; }
.tile-body { min-width: 0; flex: 1; }
.tile h3 { margin: 0; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.tile p { margin: 2px 0 0; font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--ink-2); margin-top: 6px; margin-right: 4px; }
.fav-mark { position: absolute; top: 10px; right: 10px; color: var(--orange); }
.tile.hidden-t { opacity: .55; border-style: dashed; }
.tile.dragging { opacity: .4; }
.tile.over { border-color: var(--orange); box-shadow: 0 0 0 2px var(--orange); }

/* Modo edición: acciones de cada tarjeta */
.tile-tools { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); }
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.on { background: var(--pale); border-color: var(--orange); color: var(--orange); }
.chip.danger:hover { color: var(--danger); border-color: var(--danger); }
.grip { cursor: grab; touch-action: none; }
.edit .tile { cursor: default; }
.add-tile { border-style: dashed; background: transparent; color: var(--ink-2); align-items: center; justify-content: center; cursor: pointer; font-weight: 500; gap: 8px; width: 100%; font-size: 16px; }
.add-tile:hover { border-color: var(--orange); color: var(--orange); }
.empty { padding: 40px 16px; text-align: center; color: var(--ink-2); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- Login / modal ---------- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 28px; width: 100%; max-width: 400px; }
.card .brand { font-size: 38px; text-align: center; margin-bottom: 6px; }
.card .brand small { font-size: 11px; }
.card h1 { font-family: var(--serif); font-size: 20px; text-align: center; margin: 18px 0 4px; }
.card .sub { text-align: center; color: var(--ink-2); font-size: 14px; margin: 0 0 18px; }
label.f { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
.in { width: 100%; height: 46px; border: 1px solid #cfc9c3; border-radius: 10px; padding: 0 12px; background: #fff; }
textarea.in { height: auto; padding: 10px 12px; }
.in:focus { outline: 2px solid var(--orange); border-color: var(--orange); }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin: 10px 0 0; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 22px 20px 20px; }
.modal h2 { font-family: var(--serif); margin: 0 0 6px; font-size: 21px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.icons button { height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); display: grid; place-items: center; }
.icons button.sel { background: var(--orange); border-color: var(--orange); color: #fff; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row .grow { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
.row small { color: var(--ink-2); display: block; }
.tabs { display: flex; gap: 6px; margin: 12px 0; }
.tabs button { flex: 1; min-height: 40px; border-radius: 999px; border: 1px solid var(--line); background: #fff; }
.tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 80; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 640px) {
  .overlay { align-items: center; }
  .modal { border-radius: 18px; }
  .brand { font-size: 30px; }
}
@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr; }
  .top-actions .lbl { display: none; }
  .top-actions .btn { padding: 0; width: 44px; }
  .hello h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
