@font-face { font-family: "Playfair"; src: url(fonts/Playfair.ttf) format("truetype"); font-weight: 400 900; }
@font-face { font-family: "Playfair"; src: url(fonts/Playfair-Italic.ttf) format("truetype"); font-style: italic; font-weight: 400 900; }
@font-face { font-family: "Montserrat"; src: url(fonts/Montserrat.ttf) format("truetype"); font-weight: 100 900; }

:root { --purple: #6b4c9a; --purple-2: #8d6cc0; --deep: #2b2140; --cream: #f8f3ec; --lav: #efe7f7; --gold: #c9a86a;
  --ink: #2a2236; --muted: #7a6d8a; --line: #e6dcef; --ok: #2e7d4f; --bad: #b3261e; }
* { box-sizing: border-box; }
body { margin: 0; font-family: Montserrat, system-ui, sans-serif; color: var(--ink); background: var(--cream); font-size: 15px; }
a { color: var(--purple); }
h1 { font-family: Playfair; font-size: 34px; margin: 0 0 6px; color: var(--deep); }
h2 { font-family: Playfair; font-size: 22px; margin: 0 0 14px; color: var(--deep); }
.muted { color: var(--muted); } .small { font-size: 13px; }
code { background: var(--lav); padding: 2px 6px; border-radius: 6px; font-size: 12px; word-break: break-all; }

.top { display: flex; align-items: center; gap: 24px; padding: 14px 28px; background: var(--deep); color: #fff; position: sticky; top: 0; z-index: 20; }
.brand { font-family: Playfair; font-style: italic; font-size: 26px; color: #fff; text-decoration: none; }
.brand span { font-family: Montserrat; font-style: normal; font-size: 11px; letter-spacing: 3px; color: var(--gold); text-transform: uppercase; margin-left: 6px; }
.top nav { display: flex; gap: 6px; flex: 1; }
.top nav a { color: rgba(255,255,255,.75); text-decoration: none; padding: 8px 14px; border-radius: 20px; font-weight: 600; }
.top nav a.on, .top nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.me { font-size: 13px; color: rgba(255,255,255,.7); } .me a { color: var(--gold); }
.badge { background: var(--gold); color: var(--deep); border-radius: 10px; padding: 1px 7px; font-size: 11px; }
main { max-width: 1240px; margin: 0 auto; padding: 28px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 24px; border: 1.5px solid var(--purple);
  background: #fff; color: var(--purple); font: 600 14px Montserrat, sans-serif; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--lav); }
.btn.primary { background: var(--purple); color: #fff; } .btn.primary:hover { background: #5a3e85; }
.btn.big { padding: 14px 26px; font-size: 15px; }
.btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover { background: var(--lav); }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.chip { border: 1.5px solid var(--line); background: #fff; color: var(--purple); border-radius: 18px; padding: 7px 14px; font: 600 13px Montserrat, sans-serif; cursor: pointer; }
.chip:hover { border-color: var(--purple); } .chip.gold { border-color: var(--gold); color: #8a6a2f; } .chip.busy { opacity: .6; cursor: progress; }

.card { background: #fff; border-radius: 22px; padding: 24px; box-shadow: 0 6px 24px rgba(43,33,64,.06); margin-bottom: 18px; }
label { display: block; font-weight: 600; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input, textarea, select { display: block; width: 100%; margin-top: 6px; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  font: 400 15px Montserrat, sans-serif; color: var(--ink); background: #fff; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--purple-2); }
textarea { resize: vertical; line-height: 1.5; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.ai-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.ai-row select, .ai-row input { width: auto; margin: 0; flex: 1; min-width: 160px; }
.sub-block { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.sub-block summary { cursor: pointer; font-weight: 600; color: var(--purple); margin-bottom: 10px; }

.head-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.empty { text-align: center; padding: 60px 20px; background: #fff; border-radius: 22px; }
.empty .logo { font-family: Playfair; font-style: italic; font-size: 44px; color: var(--purple); }
.gift-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.gift-card { display: flex; gap: 14px; background: #fff; border-radius: 20px; padding: 16px; text-decoration: none; color: inherit; box-shadow: 0 6px 24px rgba(43,33,64,.06); transition: .2s; }
.gift-card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(43,33,64,.12); }
.gift-card .qr { width: 86px; height: 86px; border-radius: 10px; }
.gift-card h3 { font-family: Playfair; margin: 6px 0 4px; font-size: 19px; }
.gift-card p { margin: 0 0 3px; font-size: 13px; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .5px; padding: 3px 10px; border-radius: 12px; background: var(--lav); color: var(--purple); }
.st-disponible { background: #e3f4ea; color: var(--ok); } .st-borrador { background: #f1eee8; color: #8a7e6a; }
.st-desactivado, .st-vencido { background: #fbe7e5; color: var(--bad); } .st-programado { background: #fff3dc; color: #8a6a2f; }
.st-agotado { background: #ece7f3; color: var(--muted); }

.back { display: inline-block; margin-bottom: 14px; text-decoration: none; font-weight: 600; }
.edit-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.sticky { position: sticky; top: 84px; text-align: center; }
.qr-big { width: 100%; max-width: 240px; margin: 14px auto; display: block; border-radius: 14px; border: 1px solid var(--line); }
.link-box { display: flex; gap: 6px; } .link-box input { margin: 0; font-size: 12px; } .link-box .btn { padding: 8px 12px; }
.side-actions { display: grid; gap: 8px; margin-top: 14px; } .side-actions form { margin: 0; } .side-actions form .btn { width: 100%; }
.small-actions { border-top: 1px dashed var(--line); padding-top: 12px; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; text-align: left; font-size: 13px; margin: 16px 0 0; }
.stats dt { color: var(--muted); } .stats dd { margin: 0; font-weight: 600; }
.save-bar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--cream) 30%); padding: 18px 0 14px; display: flex; gap: 10px; z-index: 5; }

.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.mode { border: 1.5px solid var(--line); border-radius: 16px; padding: 14px; cursor: pointer; margin: 0; color: var(--ink); }
.mode input { width: auto; display: inline; margin: 0 6px 0 0; }
.mode span { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 6px; }
.mode:has(input:checked) { border-color: var(--purple); background: var(--lav); }
.vence-box { display: none; } form:has(input[value="vence"]:checked) .vence-box { display: grid; }
.unlock { background: #fffaf0; border: 1.5px dashed var(--gold); border-radius: 16px; padding: 14px; color: #8a6a2f; }

.drop { position: relative; border: 2px dashed var(--purple-2); border-radius: 18px; padding: 30px; text-align: center; background: var(--lav); cursor: pointer; transition: .2s; }
.drop.over { background: #e2d5f2; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop p { margin: 0; }
.progress { height: 8px; background: #fff; border-radius: 4px; margin-top: 14px; overflow: hidden; } .progress div { height: 100%; width: 0; background: var(--purple); transition: width .2s; }
.items { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.item { display: flex; gap: 12px; align-items: center; border: 1.5px solid var(--line); border-radius: 16px; padding: 10px; background: #fff; }
.item.dragging { opacity: .4; }
.handle { cursor: grab; color: var(--muted); letter-spacing: -3px; padding: 0 4px; user-select: none; }
.thumb { flex: 0 0 76px; height: 76px; border-radius: 12px; overflow: hidden; background: var(--lav); display: flex; align-items: center; justify-content: center; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb .ico { font-size: 26px; color: var(--purple); font-weight: 700; }
.meta { flex: 1; min-width: 0; } .meta .row { display: flex; gap: 10px; align-items: center; }
.meta select { width: auto; margin: 0; padding: 6px 10px; font-size: 13px; } .meta .caption { margin-top: 6px; padding: 7px 12px; font-size: 13px; }
.meta audio { width: 100%; height: 34px; margin-top: 6px; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.del { border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; padding: 8px; border-radius: 50%; } .del:hover { background: #fbe7e5; color: var(--bad); }

.notice { background: #fff3dc; border-radius: 16px; padding: 16px 18px; margin: 14px 0 20px; line-height: 1.6; }
.chat-layout { display: grid; grid-template-columns: 300px 1fr; gap: 18px; min-height: 60vh; }
.conv-list { list-style: none; margin: 0; padding: 8px; background: #fff; border-radius: 20px; }
.conv-list a { display: block; padding: 12px; border-radius: 14px; text-decoration: none; color: var(--ink); }
.conv-list a.on, .conv-list a:hover { background: var(--lav); } .conv-list span.small { display: block; } .pad { padding: 14px; }
.chat { background: #fff; border-radius: 20px; display: flex; flex-direction: column; overflow: hidden; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); gap: 10px; flex-wrap: wrap; }
.chat-head form { margin: 0; }
.msgs { flex: 1; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: #f6f1fa; overflow-y: auto; max-height: 68vh; }
.msg { max-width: 72%; background: #fff; border-radius: 16px; padding: 10px 12px; align-self: flex-start; box-shadow: 0 2px 6px rgba(0,0,0,.05); }
.msg.out { align-self: flex-end; background: #e6dcf5; }
.msg img, .msg video { max-width: 100%; max-height: 320px; border-radius: 10px; display: block; }
.msg p { margin: 6px 0 0; white-space: pre-line; } .msg .time { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.to-gift { display: flex; gap: 6px; margin-top: 8px; } .to-gift select { margin: 0; padding: 5px 8px; font-size: 12px; }
.reply { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); } .reply input { margin: 0; }

body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: radial-gradient(circle at 50% 0, #fff7ea, var(--lav)); }
.login-card { background: #fff; padding: 40px 34px; border-radius: 28px; width: min(380px, 92vw); box-shadow: 0 30px 80px rgba(43,33,64,.15); text-align: center; }
.login-card .logo { font-family: Playfair; font-style: italic; font-size: 48px; color: var(--purple); }
.login-card .sub { font-size: 11px; letter-spacing: 4px; color: var(--gold); font-weight: 700; margin-bottom: 26px; }
.login-card label { text-align: left; } .login-card .btn { width: 100%; margin-top: 8px; }
.err { color: var(--bad); font-weight: 600; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px); background: var(--deep); color: #fff; padding: 12px 20px; border-radius: 24px;
  font-weight: 600; font-size: 14px; transition: .3s; z-index: 50; max-width: 90vw; }
#toast.on { transform: translateX(-50%); }

@media (max-width: 900px) {
  .edit-layout, .chat-layout { grid-template-columns: 1fr; }
  .col-side { order: -1; } .sticky { position: static; }
  .modes { grid-template-columns: 1fr; }
  main { padding: 16px; } .top { padding: 12px 16px; gap: 10px; flex-wrap: wrap; } .me { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .msg { max-width: 90%; }
}
