/* SATSMARKT — warm orange, soft & rounded. Self-contained, no framework. */
:root {
  --orange: #F7931A;
  --orange-bright: #FF8C00;
  --orange-soft: #ffe9cf;
  --cream: #fff8f0;
  --card: #ffffff;
  --ink: #2b2622;
  --muted: #8a7f74;
  --line: #f0e3d4;
  --danger: #e0533d;
  --ok: #2e9e6b;
  --radius: 16px;
  --radius-lg: 20px;
  --shadow: 0 6px 24px rgba(247, 147, 26, 0.10), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-hover: 0 10px 30px rgba(247, 147, 26, 0.18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Nunito", system-ui, sans-serif;
}
* { box-sizing: border-box; }
/* The `hidden` attribute must always win, even over class display rules
   (.modal-backdrop{display:grid}, .user-chip{display:flex}, etc.). Without
   this, author styles override the UA `[hidden]{display:none}` and elements
   like the login modal stay visible despite being marked hidden. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--cream) 0%, #fff 60%);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--orange); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.85em; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.center { text-align: center; }
hr.soft { border: none; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---- header ---- */
#topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: rgba(255, 248, 240, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.25rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(135deg, var(--orange), var(--orange-bright));
  color: #fff;
}
.brand-name { letter-spacing: 0.5px; background: linear-gradient(135deg, var(--orange), var(--orange-bright)); -webkit-background-clip: text; background-clip: text; color: transparent; }
#mainnav { display: flex; gap: 4px; margin-left: 8px; flex: 1; }
#mainnav a {
  position: relative; color: var(--ink); padding: 8px 12px; border-radius: 12px; font-weight: 600; font-size: 0.95rem;
  transition: background 0.15s;
}
#mainnav a:hover { background: var(--orange-soft); text-decoration: none; }
#mainnav a.active { background: var(--orange); color: #fff; }
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 0.7rem; font-weight: 700; }
#authbox { display: flex; align-items: center; }
.user-chip { position: relative; }
.chip-btn {
  display: flex; align-items: center; gap: 7px; cursor: pointer;
  background: #fff; border: 1px solid var(--line); padding: 7px 11px; border-radius: 999px;
  box-shadow: var(--shadow); font-family: inherit; color: var(--ink);
}
.chip-btn:hover { border-color: var(--orange); }
.chip-btn .caret { font-size: 0.7rem; color: var(--muted); }
.chip-btn[aria-expanded="true"] .caret { color: var(--orange); }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 200px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-hover); padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.user-menu a, .user-menu button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  font-family: inherit; font-size: 0.92rem; color: var(--ink); cursor: pointer;
  padding: 9px 11px; border-radius: 9px; text-decoration: none;
}
.user-menu a:hover, .user-menu button:hover { background: var(--orange-soft); }
.user-menu #logoutBtn { color: var(--danger); }

/* ---- buttons ---- */
.btn {
  font-family: inherit; font-weight: 700; font-size: 0.92rem; cursor: pointer;
  border: none; border-radius: 12px; padding: 10px 16px;
  transition: transform 0.08s, box-shadow 0.15s, background 0.15s, opacity 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--orange), var(--orange-bright)); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { box-shadow: var(--shadow-hover); }
.btn-secondary { background: var(--orange-soft); color: #a85d00; }
.btn-secondary:hover { background: #ffdcb0; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: #fff; border-color: var(--orange); }
.btn-danger { background: #fdecea; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 0.82rem; border-radius: 10px; }
.btn.block { width: 100%; display: block; margin-top: 10px; }

/* ---- layout ---- */
#app { max-width: 1080px; margin: 0 auto; padding: 22px 18px 60px; }
.view { animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow); }
.panel.center { text-align: center; max-width: 460px; margin: 40px auto; }
.panel.center .btn { margin: 10px auto 0; }
.loading { text-align: center; color: var(--muted); padding: 60px; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 50px 20px; }

/* ---- hint banner ---- */
.hint-banner {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: linear-gradient(135deg, #fff3e2, #ffe9cf);
  border: 1px solid var(--orange-soft); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 16px; font-size: 0.92rem;
}
.hint-banner .x { margin-left: auto; background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--muted); }

/* ---- toolbar ---- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.toolbar input { flex: 1; min-width: 120px; }
input, textarea, select {
  font-family: inherit; font-size: 0.95rem; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 13px; outline: none;
  transition: border 0.15s, box-shadow 0.15s; width: 100%;
}
input:focus, textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(247,147,26,0.14); }
textarea { resize: vertical; }

/* ---- grid / cards ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; cursor: pointer; box-shadow: var(--shadow); transition: transform 0.12s, box-shadow 0.15s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.thumb { width: 100%; aspect-ratio: 4 / 3; background-size: cover; background-position: center; background-color: var(--orange-soft); }
.thumb-empty { display: grid; place-items: center; font-size: 2.6rem; color: var(--orange); }
.thumb-empty.big { aspect-ratio: 16/10; font-size: 4rem; border-radius: var(--radius-lg); }
.card-body { padding: 12px 14px 14px; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-title { margin: 0 0 4px; font-size: 1.02rem; line-height: 1.3; }
.detail-title { margin: 0; }
.price { font-weight: 800; color: var(--orange); font-size: 1.05rem; }
.price.big { font-size: 1.6rem; margin: 6px 0; }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 8px; }
.rep { font-size: 0.8rem; font-weight: 700; color: #b8860b; white-space: nowrap; }

/* ---- my listings ---- */
.view-head { margin: 0; }
.toolbar .spacer { flex: 1; }
.mine-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.btn-ghost.danger { color: var(--danger); }
.btn-ghost.danger:hover { border-color: var(--danger); background: #fdecea; }

/* ---- profile & settings ---- */
.view-settings { max-width: 620px; margin: 0 auto; }
.settings-panel { margin-bottom: 16px; }
.settings-panel h3 { margin: 0 0 12px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.setting-row:first-of-type { border-top: none; }
.setting-label { color: var(--muted); font-size: 0.9rem; flex-shrink: 0; }
.copy-box { display: flex; align-items: center; gap: 8px; min-width: 0; }
.copy-box .ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; background: var(--orange-soft); padding: 5px 9px; border-radius: 8px; }
.settings-panel .field { margin: 8px 0 12px; }
.settings-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.warn { color: var(--danger); }
@media (max-width: 560px) { .copy-box .ellip { max-width: 180px; } }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 800; background: var(--line); color: var(--muted); letter-spacing: 0.5px; }
.tag-sold { background: #ffe0db; color: var(--danger); }
.tag-ok { background: #dff4e9; color: var(--ok); }

/* ---- profiles (avatar / header / seller storefront) ---- */
.avatar {
  width: 56px; height: 56px; border-radius: 50%; flex: none;
  background-size: cover; background-position: center;
  background-color: var(--orange-soft); border: 2px solid #fff; box-shadow: var(--shadow);
}
.avatar-empty { display: grid; place-items: center; font-size: 1.5rem; color: var(--orange); }

.profile-head { margin: 0 0 4px; }
.profile-banner {
  height: 120px; border-radius: var(--radius); background-size: cover; background-position: center;
  background-color: var(--orange-soft); margin-bottom: -34px;
}
.profile-banner-empty { background: linear-gradient(135deg, var(--orange-soft), #fff3e2); }
.profile-id { display: flex; align-items: flex-end; gap: 14px; padding: 0 6px; }
.profile-id .avatar { width: 72px; height: 72px; }
.profile-meta { padding-bottom: 4px; min-width: 0; }
.profile-name { font-weight: 800; font-size: 1.15rem; line-height: 1.2; }
.profile-npub { max-width: 260px; display: inline-block; }
.profile-about { white-space: pre-wrap; margin: 12px 6px 0; color: var(--ink); }
.profile-preview { margin: 6px 0 14px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.profile-form-actions { display: flex; gap: 10px; margin-top: 4px; }

.profile-panel { margin-bottom: 18px; }
.profile-panel .btn { margin-top: 14px; }
.seller-head { margin: 4px 0 14px; }

/* seller card on a listing detail */
.seller-card {
  display: flex; align-items: center; gap: 12px; margin: 12px 0;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fffdf9; cursor: pointer; transition: border 0.12s, box-shadow 0.12s;
}
.seller-card:hover { border-color: var(--orange); box-shadow: var(--shadow); text-decoration: none; }
.seller-card .avatar { width: 46px; height: 46px; }
.seller-card-body { min-width: 0; }
.seller-card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seller-card-name { font-weight: 700; color: var(--ink); }
.seller-card-link { display: block; color: var(--orange); margin-top: 2px; }

/* ---- form ---- */
.view-form .panel, .view-help .panel { max-width: 680px; margin: 0 auto; }
.field { display: block; margin-bottom: 14px; }
.field.tight { margin: 8px 0; }
.field > span { display: block; font-weight: 700; font-size: 0.85rem; margin-bottom: 5px; color: #6b5f53; }
.img-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.img-row { display: flex; gap: 8px; }
.img-row input { flex: 1; }

/* ---- detail ---- */
.detail-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 22px; align-items: start; }
.gallery { display: flex; flex-direction: column; gap: 10px; }
.gallery img { width: 100%; border-radius: var(--radius-lg); border: 1px solid var(--line); box-shadow: var(--shadow); object-fit: cover; }
.detail-info .desc { white-space: pre-wrap; margin: 14px 0; }
.seller-line { margin: 6px 0; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ---- messages ---- */
.msg-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; min-height: 60vh; }
.conv-list { display: flex; flex-direction: column; gap: 8px; }
.conv-item { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; transition: border 0.12s, box-shadow 0.12s; }
.conv-item:hover { border-color: var(--orange); }
.conv-item.active { border-color: var(--orange); box-shadow: var(--shadow); background: #fffdfa; }
.conv-title-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.conv-title { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.conv-item.unread { border-color: var(--orange); background: #fffaf2; }
.conv-item.unread .conv-title { color: var(--orange); }
.conv-preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.chat-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); display: flex; min-height: 60vh; }
.chat-inner { display: flex; flex-direction: column; width: 100%; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; max-height: 46vh; }
.bubble { max-width: 75%; padding: 8px 12px; border-radius: 14px; }
.bubble-text { white-space: pre-wrap; word-break: break-word; }
.bubble-time { font-size: 0.68rem; opacity: 0.6; margin-top: 3px; }
.bubble.mine { align-self: flex-end; background: linear-gradient(135deg, var(--orange), var(--orange-bright)); color: #fff; border-bottom-right-radius: 4px; }
.bubble.theirs { align-self: flex-start; background: #f5ede2; color: var(--ink); border-bottom-left-radius: 4px; }
.system-msg { align-self: center; font-size: 0.78rem; color: var(--muted); background: #faf3ea; padding: 4px 12px; border-radius: 999px; }
.composer { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.composer .chat-input { flex: 1; }
.reveal-box { padding: 12px 16px; border-top: 1px solid var(--line); background: #fffdf9; }
.reveal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.reveal-card { background: #f3fbf6; border: 1px solid #cdeddc; border-radius: var(--radius); padding: 12px 14px; }
.reveal-title { font-weight: 800; margin-bottom: 6px; }
.kv { margin: 3px 0; word-break: break-all; }
.rating-widget { margin-top: 12px; background: #fff8ef; border: 1px solid var(--orange-soft); border-radius: var(--radius); padding: 12px 14px; }
.stars { font-size: 1.7rem; cursor: pointer; margin: 6px 0; user-select: none; }
.star { color: #d9b98a; padding: 0 1px; }
.star.on { color: var(--orange); }
.rating-comment { margin: 6px 0; }
.contact-preview { margin: 4px 0 14px; }
.contact-list { list-style: none; margin: 4px 0; padding: 0; }
.contact-list li { margin: 2px 0; word-break: break-all; }
.share-preview { background: #fffdf9; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0; }
.share-preview-head { font-weight: 700; margin-bottom: 4px; }
.share-preview a { display: inline-block; margin-top: 6px; }

/* ---- modal ---- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(43, 38, 34, 0.5); display: grid; place-items: center; padding: 16px; backdrop-filter: blur(3px); }
.modal { position: relative; width: 100%; max-width: 440px; max-height: 92vh; overflow-y: auto; background: var(--card); border-radius: var(--radius-lg); padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,0.25); animation: pop 0.18s ease; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h2 { margin-top: 0; }
.modal-close { position: absolute; top: 12px; right: 14px; background: none; border: none; font-size: 1.6rem; cursor: pointer; color: var(--muted); line-height: 1; }
.login-tabs { display: flex; gap: 6px; margin: 14px 0 16px; background: #f6eee3; padding: 4px; border-radius: 12px; }
.login-tab { flex: 1; border: none; background: transparent; padding: 8px; border-radius: 9px; font-weight: 700; cursor: pointer; color: var(--muted); font-family: inherit; }
.login-tab.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.hint { font-size: 0.8rem; color: var(--muted); margin: 6px 0 0; }
.error { background: #fdecea; color: var(--danger); border-radius: 10px; padding: 9px 12px; font-size: 0.86rem; margin-top: 12px; }

/* ---- email login (log in vs create) ---- */
.seg { display: flex; gap: 4px; margin: 4px 0 14px; background: #f6eee3; padding: 4px; border-radius: 10px; }
.seg-btn { flex: 1; border: none; background: transparent; padding: 7px; border-radius: 8px; font-weight: 700; font-size: 0.86rem; cursor: pointer; color: var(--muted); font-family: inherit; }
.seg-btn.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.npub-fp { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; word-break: break-all; background: var(--cream); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; color: var(--ink); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 0.82rem; color: var(--muted); margin: 12px 0; cursor: pointer; line-height: 1.4; }
.check input { margin-top: 2px; flex: none; }
.confirm-row { display: flex; gap: 10px; margin-top: 8px; }
.confirm-row .btn-ghost { flex: none; }
.confirm-row .btn-primary { flex: 1; }

/* ---- toast ---- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: 0.9rem; box-shadow: 0 8px 30px rgba(0,0,0,0.3); max-width: 90vw; }
.toast-error { background: var(--danger); }

/* ---- help ---- */
.help h1 { margin-top: 0; }
.help h2 { margin-top: 24px; color: #a85d00; font-size: 1.1rem; }
.help code { background: #f6eee3; padding: 1px 6px; border-radius: 6px; font-size: 0.85em; }
.help ul { padding-left: 20px; }
.help li { margin: 7px 0; }

/* ---- responsive ---- */
@media (max-width: 760px) {
  #mainnav { order: 3; width: 100%; margin-left: 0; justify-content: space-between; }
  .detail-grid { grid-template-columns: 1fr; }
  .msg-layout { grid-template-columns: 1fr; }
  .conv-list { flex-direction: row; overflow-x: auto; }
  .conv-item { min-width: 200px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
}
