@import url("/shared/xiaoke-ui.css");
@import url("/shared/login.css");

body { background: var(--bg); }

#app { display: grid; grid-template-columns: 200px 1fr; }
.sidebar {
  border-right: 1px solid var(--surface-line); padding: 16px 12px; background: var(--panel);
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar button {
  text-align: left; background: transparent; border: 0; color: var(--muted);
  padding: 8px 12px; min-height: var(--control-h-menu); border-radius: var(--radius); cursor: pointer; font: inherit;
  outline: none; box-shadow: none;
}
.sidebar button:hover, .sidebar button.active {
  background: var(--ix-bg); color: var(--ix-fg); text-shadow: none; box-shadow: none;
}
.sidebar button:focus-visible { box-shadow: var(--focus-ring-on-light); }

main { padding: 16px 28px; min-width: 0; }
body.auth-ok main {
  width: 100%;
  max-width: 80rem;
  margin-inline: auto;
}
@media (min-width: 1480px) {
  body.auth-ok:not(.community-view,.social-view) #app {
    grid-template-columns: minmax(0, 1fr) 200px minmax(0, 80rem) minmax(0, 1fr);
  }
  body.auth-ok:not(.community-view,.social-view) .sidebar { grid-column: 2; }
  body.auth-ok:not(.community-view,.social-view) main { grid-column: 3; }
}
.bar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: var(--panel-gap); flex-wrap: wrap;
}
.bar h1 { margin: 0; font-size: var(--font-page-title); min-width: 0; flex: 1; font-weight: 650; letter-spacing: -.025em; }

.user-menu { position: relative; }
.user-chip {
  background: var(--bg-card); border: 1px solid var(--surface-line); color: var(--text);
  border-radius: var(--radius); padding: 0.35rem 0.85rem; cursor: pointer; font: inherit;
  max-width: min(320px, 70vw);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  outline: none; box-shadow: none; font-size: var(--font-btn);
}
.user-chip:hover { background: var(--ix-bg); color: var(--ix-fg); border-color: var(--surface-line); text-shadow: none; }
.user-chip:focus-visible { box-shadow: var(--focus-ring-on-light); }
.topbar .user-chip {
  background: transparent; border: 0; color: var(--text-muted);
  max-width: min(280px, 42vw);
}
.topbar .user-chip:hover {
  background: var(--ix-bg); color: var(--ix-fg); text-shadow: none;
}
.topbar .user-chip:focus-visible { box-shadow: var(--focus-ring-on-dark); }
.user-dropdown {
  /* inherits canonical .xk-pop / .user-dropdown shell from xiaoke-ui.css */
  display: flex; flex-direction: column; gap: 2px;
}
.user-dropdown[hidden] { display: none !important; }
.user-dropdown button {
  text-align: left; background: transparent; border: 0; color: var(--text);
  padding: 8px 12px; min-height: var(--control-h-menu); border-radius: var(--radius); cursor: pointer; font: inherit; white-space: normal;
  outline: none; box-shadow: none;
}
.user-dropdown button:hover { background: var(--ix-bg); color: var(--ix-fg); text-shadow: none; }
.user-dropdown button:focus-visible { box-shadow: var(--focus-ring-on-light); }

.card {
  background: var(--card-fill); border: 1px solid var(--surface-line); border-radius: var(--card-radius);
  box-shadow: var(--card-shadow); padding: var(--panel-padding-block) 18px; margin-bottom: var(--panel-gap);
}
.card > h3 { margin: 0 0 10px; }
#view > .card:last-child { margin-bottom: 0; }
.login-card .auth-alt {
  margin: 24px 0 0; font-size: 0.9rem;
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
}
.login-card .auth-alt-sep { display: none; }
.login-card .auth-alt #auth-mode-toggle { margin-left: auto; }
.login-card .auth-link {
  background: none; border: 0; padding: 0; margin: 0;
  color: var(--ix-fg); font: inherit; font-weight: 500; cursor: pointer;
  border-radius: var(--radius); outline: none; box-shadow: none;
}
.login-card .auth-link:hover { color: var(--ix-fg); background: var(--ix-bg); text-decoration: none; text-shadow: none; }
.login-card .auth-link:focus-visible { box-shadow: var(--focus-ring-on-light); }
.login-card .auth-method-tabs {
  display: flex; gap: 16px; justify-content: center; margin: 0 0 14px;
}
.login-card .auth-method-tabs .auth-link[aria-pressed="true"] {
  color: var(--ix-fg); font-weight: 600; text-decoration: none;
}
.login-card .captcha-row,
.login-card .sms-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end;
}
.login-card :is(.captcha-row, .sms-row) label { min-width: 0; }
.login-card .captcha-img-btn {
  padding: 0; border: 1px solid var(--surface-line); border-radius: var(--radius); background: var(--bg-card);
  cursor: pointer; line-height: 0; overflow: hidden;
}
.login-card .captcha-img-btn img { display: block; width: 150px; height: 40px; }
.login-card .sms-row .btn { white-space: nowrap; }
@media (max-width: 380px) {
  .login-card .captcha-row { grid-template-columns: 1fr; }
  .login-card .captcha-img-btn { justify-self: start; }
}
.grid { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.console-table-scroll { max-width: 100%; overflow-x: auto; }
.console-table-scroll:focus-visible { outline: 2px solid var(--accent-primary); }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--surface-line); }
th { color: var(--muted); font-weight: 500; }
.console-table-scroll th,
.console-table-scroll td:last-child { white-space: nowrap; }
.console-table-scroll td { overflow-wrap: anywhere; }
.console-table-scroll td code { white-space: nowrap; }
.console-device-table :is(th, td) { white-space: nowrap; }
.error { color: var(--danger); margin-top: 8px; }
.ok { color: var(--ok); margin-top: 8px; }
code { font-family: ui-monospace, monospace; font-size: 0.85rem; border-radius: var(--radius); }
pre { border-radius: var(--radius); border: 1px solid var(--surface-line); padding: 12px; background: var(--input-bg); }

.donate-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.donate-card { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.donate-card img.qr {
  width: min(100%, 200px); aspect-ratio: 220 / 260; object-fit: contain;
  background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--surface-line);
}
.donate-card .title { font-weight: 600; }
.donate-card.selected {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.community-static-detail { overflow-wrap: anywhere; }
.community-static-detail img {
  display: block;
  max-inline-size: 100%;
  block-size: auto;
}

@media (max-width: 800px) {
  body.auth-ok #app { grid-template-columns: 1fr; }
  body.auth-ok .sidebar { border-right: 0; border-bottom: 1px solid var(--surface-line); }
  body.auth-ok .sidebar nav { flex-direction: row; flex-wrap: wrap; }
}

/* Marketplace responds to available space, not guessed device/user-agent types.
   The 1.67 landscape card is the default; content can grow at large text sizes. */
.market-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: 18px; align-items: start; max-width: 108rem;
}
.market-card.card {
  width: 100%; max-width: 100%;
  aspect-ratio: 1.67 / 1; min-height: 208px; min-width: 0;
  margin: 0; padding: 16px; border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 8px;
  border-color: var(--surface-line); box-shadow: none;
}
.market-card:focus-within { border-color: var(--surface-line); }
.market-card-header { display: flex; gap: 12px; align-items: center; min-width: 0; }
.market-card-header strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; font-size: 1.05rem; }
.market-version { flex: 0 0 auto; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; padding: 2px 8px; background: var(--bg-hover); border-radius: var(--pill-radius); }
.market-stats { overflow-wrap: anywhere; }
.market-description { margin: 0; line-height: 1.4; font-size: .875rem; color: var(--text-muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.market-card .catalog-variant { display: block; min-width: 0; margin-top: auto; }
.catalog-variant select { width: 100%; max-width: 100%; min-width: 0; }
.market-icon.btn { padding: 0; width: var(--control-h); min-width: var(--control-h); height: var(--control-h); flex: 0 0 var(--control-h); }
.market-icon svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.market-icon[aria-pressed="true"] { color: var(--ix-fg); background: var(--ix-bg); border-color: var(--surface-line); text-shadow: none; }
.market-icon[aria-pressed="true"] svg { fill: currentColor; fill-opacity: .16; }
.market-recovery { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; padding: 14px 16px; background: var(--bg-card); border: 1px solid var(--surface-line); border-radius: var(--radius); }
.market-recovery .row { gap: 8px; }
.market-recovery a { font-size: .875rem; }
.catalog-controls { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); align-items: end; }
.catalog-controls label { display: flex; flex-direction: column; min-width: 0; gap: 5px; color: var(--muted); font-size: .8rem; }
.catalog-controls input, .catalog-controls select { width: 100%; min-width: 0; max-width: 100%; height: var(--control-h); min-height: var(--control-h); max-height: var(--control-h); box-sizing: border-box; }
.catalog-controls .catalog-search { grid-column: span 2; }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .market-card { transition: border-color .15s, box-shadow .15s; }
  .market-card:hover { color: inherit; background: var(--ix-bg); border-color: var(--surface-line); box-shadow: none; text-shadow: none; }
}
@media (max-width: 960px) {
  body.auth-ok #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  body.auth-ok .sidebar { padding: 6px 12px; border-right: 0; border-bottom: 1px solid var(--surface-line); }
  body.auth-ok .sidebar nav { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 4px; }
  body.auth-ok .sidebar button { flex: 0 0 auto; min-height: var(--control-h-touch); }
  main { padding: 18px 20px 24px; }
}
@media (max-width: 600px) {
  main { padding: 16px 12px 24px; }
  .market-grid { gap: 14px; }
  .market-card.card { padding: 14px; min-height: 208px; }
  .catalog-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .catalog-controls .catalog-search { grid-column: 1 / -1; }
  .catalog-tools.card { padding: 14px; }
  .market-recovery { padding: 12px; }
  .market-recovery .row { width: 100%; }
  .market-recovery .btn { flex: 1; height: var(--control-h); min-height: var(--control-h); max-height: var(--control-h); white-space: nowrap; box-sizing: border-box; }
  .market-recovery a { width: 100%; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar-right { gap: 8px; }
  .topbar .top-link[href="/console/"], .topbar .top-link[href="/"] { display: none; }
  .topbar .user-chip { max-width: 100px; }
}
@media (max-width: 360px) {
  .market-card.card { padding: 12px; }
  .topbar { flex-wrap: wrap; }
  .topbar-right { margin-left: auto; }
}

/* Decorative artwork must not enlarge the scrollable business pane. */

body.auth-ok .sidebar { min-width: 0; }
body.auth-ok .sidebar nav { min-width: 0; max-width: 100%; }

/* Community cards: cover / editorial copy above a shared stats / boards row. */
body.community-view #app{height:auto;min-height:0}
body.community-view main{padding:24px;min-height:100%;height:auto}
body.community-view .bar{display:flex}
.community-intro{color:var(--muted);margin:0 0 24px}
.market-grid{grid-template-columns:repeat(auto-fill,minmax(min(100%,22rem),1fr));gap:20px;max-width:108rem}
.market-card.card{display:grid;grid-template-columns:minmax(0,.72fr) minmax(0,1.7fr);grid-template-rows:minmax(0,1fr) auto;gap:14px 18px;padding:18px;aspect-ratio:1.67;min-height:244px;position:relative;overflow:visible}
.market-cover{display:block;min-height:0;grid-column:1;grid-row:1;border-radius: var(--radius);overflow:hidden;background:var(--bg-hover)}
.market-cover img{width:100%;height:100%;object-fit:cover;display:block}
.market-copy{display:flex;flex-direction:column;min-width:0;min-height:0;grid-column:2;grid-row:1;gap:8px}
.market-card-header{display:block;flex:none}.market-card-header a{text-decoration:none;color:var(--text);display:block;min-width:0}.market-card-header strong{display:block;font-size:1.05rem;line-height:1.35}
.market-description{font-size:.84rem;line-height:1.5;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;margin:0;flex:1}
.market-stats{grid-column:1/-1;grid-row:2;display:flex;gap:6px;align-items:center;max-width:60%;min-width:0;color:var(--text-muted);font-variant-numeric:tabular-nums}.market-stat{display:inline-flex;align-items:center;justify-content:center;gap:5px;padding:4px 2px;min-height:var(--control-h-touch);background:none;border:0;font:inherit;color:inherit;cursor:pointer;white-space:nowrap}.market-stat svg{width:19px;height:19px;flex:none;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linejoin:round;stroke-linecap:round}.market-stat[aria-pressed=true]{color:var(--ix-fg);background:var(--ix-bg);text-shadow:none}.market-stat[aria-pressed=true] svg{fill:currentColor;fill-opacity:.15}.market-stat:focus-visible{outline:2px solid var(--accent);border-radius:var(--radius)}
.board-pop p{margin:8px 0 0;user-select:text;-webkit-user-select:text;overflow-wrap:anywhere;max-height:38vh;overflow:auto}
.app-detail{max-width:960px;margin:24px auto 40px}.app-detail .market-card{max-width:740px;margin:0 auto;min-height:330px}.app-full-summary{white-space:pre-wrap;overflow-wrap:anywhere;color:var(--text-muted);line-height:1.9;margin:24px 0}.discussion{max-width:1080px;margin:0 auto;padding:32px 0;border-top:1px solid var(--surface-line)}.discussion-title{display:flex;gap:16px;justify-content:space-between;align-items:baseline}.discussion h2{font-size:1.35rem;margin:0}.discussion-title>span{color:var(--muted);font-size:.85rem;white-space:nowrap}.comment-composer{border:1px solid var(--surface-line);border-radius:var(--card-radius);padding:18px;margin-top:24px}.comment-composer textarea{display:block;width:100%;border:0;min-height:120px;background:transparent;padding:0;resize:vertical;font:inherit;line-height:1.7}.community-covenant{font-size:.83rem}.community-covenant a{color:var(--accent)}[data-image-preview]{max-width:200px;max-height:140px;object-fit:contain;margin:12px 0}.comment-toolbar{border-block:1px solid var(--surface-line);padding:20px 0;display:flex;justify-content:space-between;gap:16px;align-items:center;margin-top:32px;flex-wrap:wrap}.comment-sorts{display:flex;gap:8px;flex-wrap:wrap}.comment-sorts button{display:inline-flex;align-items:center;justify-content:center;min-height:var(--control-h-compact);background:none;border:0;border-radius:var(--radius);color:var(--muted);padding:6px 8px;cursor:pointer}.comment-sorts button[aria-pressed=true]{color:var(--ix-fg);background:var(--ix-bg);text-shadow:none}.comment{display:flex;gap:14px;padding:28px 0;border-bottom:1px solid var(--surface-line)}.comment-avatar{height:40px;width:40px;flex:0 0 40px;background:var(--accent-soft-06);color:var(--accent-primary);border-radius:50%;display:grid;place-items:center;font-weight:600}.comment-main{flex:1;min-width:0}.comment-main>header{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.comment-badge{font-size:.7rem;background:var(--bg-hover);color:var(--text-muted);padding:3px 6px;border-radius:var(--pill-radius)}.comment-body{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.8}.comment-attachment{display:block;max-width:min(100%,420px);max-height:300px;object-fit:contain;border-radius: var(--radius);margin:12px 0}.comment-main>footer{display:flex;justify-content:space-between;align-items:center;gap:12px;font-size:.75rem;color:var(--muted);flex-wrap:wrap}.comment-main>footer>div{display:flex;gap:8px;flex-wrap:wrap}.comment-main>footer button{display:inline-flex;align-items:center;gap:5px;border:0;border-radius:var(--radius);background:none;min-height:var(--control-h-compact);cursor:pointer;color:inherit}.comment-main>footer button[aria-pressed=true]{color:var(--ix-fg);background:var(--ix-bg);text-shadow:none}.comment-main svg{height:17px;width:17px;stroke:currentColor;stroke-width:1.6;fill:none}.comment-pagination{display:flex;align-items:center;justify-content:center;gap:16px;margin:24px 0}.comment-pagination .btn{width:auto;min-width:0;color:var(--accent);white-space:nowrap}.comment-pagination .btn:disabled{color:var(--muted);cursor:default}.comment-empty{text-align:center;color:var(--muted);margin:0;padding:var(--empty-state-padding-block) 12px}.comment [data-replies-for] .comment{background:var(--bg-card);padding:18px 10px;margin-top:12px;border-radius: var(--radius)}.comment [data-replies-for] .comment-avatar{width:28px;height:28px;flex-basis:28px;font-size:.7rem}
@media(max-width:600px){body.community-view main{padding:16px 12px}.market-card.card{padding:14px;gap:12px;min-height:244px}.market-description{-webkit-line-clamp:3;font-size:.8rem}.market-stats{gap:4px}.market-stat{gap:4px}.market-stat svg{width:17px;height:17px}.app-detail .market-card{min-height:244px}.discussion-title p{font-size:.85rem}.comment-composer{padding:14px}.comment{gap:10px}.comment-avatar{width:30px;height:30px;flex-basis:30px}.comment-main>footer{font-size:.7rem}.comment-sorts{gap:2px}.comment-sorts button{padding-inline:5px}}
.market-stat{min-width:var(--control-h-touch)}
/* Shared by the app and firmware discussions. */
.comment-compose-footer,
.comment-attachment-actions,
.comment-submit-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.comment-compose-footer {
  flex-wrap: wrap;
  margin-block-start: 8px;
}
.comment-attachment-actions,
.comment-submit-actions {
  max-width: 100%;
}
.comment-submit-actions { margin-inline-start: auto; }
.comment-count {
  color: var(--text-muted);
  font-size: var(--font-btn-compact);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.comment-image-label {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--control-h-touch);
  height: var(--control-h-touch);
  min-width: 0;
  border-radius: var(--radius-compact);
  color: var(--text-muted);
  cursor: pointer;
}
.comment-image-label svg { width: 20px; height: 20px; }
.comment-image-label:hover { background: var(--ix-bg); color: var(--ix-fg); }
.comment-image-label:has(input:focus-visible) { outline: 2px solid var(--accent-primary); }
.comment-image-label input { cursor: pointer; }
.comment-attachment-actions .btn {
  height: auto;
  max-height: none;
  min-width: 0;
  padding: 4px 10px;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}

/* Guest community pages must keep decorative pseudo-elements inside the pane. */
