:root {
  --lg-bg: #f2f2f7;
  --lg-card: #ffffff;
  --lg-ink: #1c1c1e;
  --lg-muted: #8e8e93;
  --lg-line: #e5e5ea;
  --lg-blue: #007aff;
  --lg-accent: var(--accent, #2E46F0);
  --lg-shadow: 0 1px 2px rgba(0,0,0,.04), 0 10px 28px rgba(0,0,0,.08);
  --lg-cutout: 0 2px 4px rgba(0,0,0,.06), 0 14px 32px rgba(0,0,0,.12);
}
body.page.lg-page { background: var(--lg-bg); color: var(--lg-ink); }
.lg-shell { max-width: none; margin: 0; padding: 0; }
.lg-frame {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: calc(100vh - 64px);
  transition: grid-template-columns .32s cubic-bezier(.2,.8,.2,1);
}
.lg-frame.cone-open {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 50%);
}
@media (max-width: 900px) {
  .lg-frame.cone-open { grid-template-columns: 1fr; }
  .lg-frame.cone-open .cone-panel {
    position: fixed; inset: 0; z-index: 50; width: 100%; max-width: none;
    border-left: 0; border-radius: 0;
  }
}

.lg-main { min-width: 0; padding: 18px 22px 48px; }
.lg-top {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.lg-search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: #fff; border-radius: 14px; padding: 11px 14px;
  border: 1px solid rgba(0,0,0,.06);
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.lg-search svg { width: 18px; height: 18px; color: var(--lg-muted); flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; }
.lg-search input {
  flex: 1; border: 0; outline: none; background: transparent;
  font: 400 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  color: var(--lg-ink);
}
.lg-search .clear {
  appearance: none; border: 0; background: #c7c7cc; color: #fff;
  width: 18px; height: 18px; border-radius: 50%; cursor: pointer;
  display: none; place-items: center; font-size: 12px; line-height: 1; padding: 0;
}
.lg-search[data-filled="1"] .clear { display: grid; }
.lg-top .icon-btn {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  border: 0; background: #fff; color: var(--lg-ink); cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.04); font-size: 16px;
}
.lg-top .cone-open-btn {
  height: 42px; padding: 0 14px; border-radius: 999px; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  font: 650 13px/1 -apple-system, system-ui, sans-serif;
  background: var(--lg-accent); color: #fff;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--lg-accent) 35%, transparent);
}
.lg-top .cone-open-btn .dot {
  width: 7px; height: 7px; border-radius: 50%; background: #7dffb3;
  box-shadow: 0 0 0 3px rgba(125,255,179,.25);
}

.lg-query-line {
  display: flex; align-items: center; gap: 8px; margin: 0 0 16px;
  color: var(--lg-muted);
  font: 400 13px/1.3 -apple-system, system-ui, sans-serif;
}
.lg-query-line svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.lg-query-line b { color: var(--lg-ink); font-weight: 600; }
.lg-status-pill {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; background: #fff;
  border: 1px solid var(--lg-line); font-size: 12px; color: var(--lg-ink);
}
.lg-status-pill[data-state="indexing"] { color: var(--lg-accent); }
.lg-spin {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--lg-accent) 25%, transparent);
  border-top-color: var(--lg-accent);
  animation: lg-spin .7s linear infinite;
}
@keyframes lg-spin { to { transform: rotate(360deg); } }

/* Featured suggestion */
.lg-featured {
  display: none; margin-bottom: 20px; padding: 14px;
  border-radius: 20px; background: var(--lg-card);
  border: 1px solid rgba(0,0,0,.05);
  box-shadow: var(--lg-shadow);
  grid-template-columns: 104px minmax(0, 1fr) auto;
  gap: 16px; align-items: center;
}
.lg-featured[data-show="1"] { display: grid; }
.lg-featured .pv { width: 104px; }
.lg-featured .kicker {
  margin: 0 0 4px; font: 700 11px/1 -apple-system, system-ui, sans-serif;
  letter-spacing: .06em; text-transform: uppercase; color: var(--lg-accent);
}
.lg-featured h2 {
  margin: 0 0 4px;
  font: 700 19px/1.2 -apple-system, system-ui, sans-serif;
  letter-spacing: -.02em;
}
.lg-featured p { margin: 0; color: var(--lg-muted); font-size: 13px; }
.lg-featured .primary {
  border-radius: 12px; padding: 11px 18px; text-decoration: none;
  background: var(--lg-accent); color: #fff; border: 0;
  font: 650 14px/1 -apple-system, system-ui, sans-serif;
}

/* Square cutout grid — iOS Files style */
.lg-section { margin-bottom: 22px; }
.lg-section[data-empty="1"] {
  display: none;
}
.lg-section h3 {
  margin: 0 0 12px;
  font: 600 13px/1.2 -apple-system, system-ui, sans-serif;
  color: var(--lg-muted); letter-spacing: .01em;
}
.lg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 22px 18px;
}
@media (min-width: 1100px) {
  .lg-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

.lg-tile {
  appearance: none; border: 0; background: transparent; padding: 0; cursor: pointer;
  text-align: left; color: inherit; font: inherit;
  transition: opacity .18s ease, transform .18s ease;
}
.lg-tile:hover .pv { transform: translateY(-2px); box-shadow: var(--lg-cutout); }
.lg-tile[data-dim="1"] { opacity: 0; transform: scale(.97); pointer-events: none; }
.lg-tile[data-halo="1"] {
  opacity: .5; pointer-events: auto; transform: none;
}
.lg-tile[data-halo="1"] .pv {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--lg-accent) 35%, transparent), var(--lg-shadow);
}
.lg-tile[data-hit="1"] .pv {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lg-accent) 55%, transparent), var(--lg-cutout);
}

/* The cutout itself — square card, paper/photo inside */
.pv {
  position: relative; width: 100%; aspect-ratio: 1 / 1;
  border-radius: 18px; overflow: hidden;
  background: linear-gradient(180deg, #fafafa, #f0f0f5);
  border: 1px solid rgba(0,0,0,.05);
  box-shadow: var(--lg-shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.pv-sheet {
  position: absolute; inset: 12% 14% 14%;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 10px 20px rgba(0,0,0,.1);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.pv-sheet .hdr {
  height: 10px; flex: none;
  background: linear-gradient(90deg, #e8eefc, #f5f5f7 40%, #f5f5f7);
  border-bottom: 1px solid #eee;
}
.pv-sheet .body {
  flex: 1; padding: 7px 8px; overflow: hidden;
  font: 500 6.5px/1.28 ui-sans-serif, system-ui, sans-serif;
  color: #2c2c2e; white-space: pre-wrap; letter-spacing: -.01em;
}
.pv-sheet .body .bar {
  display: block; height: 3px; border-radius: 2px; margin: 0 0 3px;
  background: #e5e5ea;
}
.pv-sheet .body .bar.w80 { width: 80%; }
.pv-sheet .body .bar.w60 { width: 60%; }
.pv-sheet .body .bar.w90 { width: 90%; }
.pv-sheet .body .bar.accent { background: color-mix(in srgb, var(--lg-accent) 55%, #c7d2ff); height: 4px; }

.pv[data-kind="pdf"] .pv-sheet .hdr { background: linear-gradient(90deg, #ffe3e0, #fff 45%); }
.pv[data-kind="pdf"] .pv-badge {
  position: absolute; left: 50%; bottom: 7%; transform: translateX(-50%);
  font: 800 9px/1 -apple-system, system-ui, sans-serif; letter-spacing: .08em;
  color: #d70015; text-transform: uppercase;
}

.pv[data-kind="image"] .pv-sheet {
  inset: 0; border-radius: 18px; box-shadow: none;
  background:
    radial-gradient(120% 80% at 20% 15%, rgba(255,255,255,.55), transparent 45%),
    linear-gradient(145deg, #7eb6ff 0%, #b7a6ff 42%, #ffc48a 100%);
}
.pv[data-kind="image"] .pv-sheet .hdr,
.pv[data-kind="image"] .pv-sheet .body { display: none; }
.pv[data-kind="image"] .pv-photo {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
}
.pv[data-kind="image"] .pv-photo::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,.28));
}

.pv[data-kind="video"] .pv-sheet {
  inset: 0; border-radius: 18px; box-shadow: none;
  background: linear-gradient(160deg, #1c1c1e, #3a3a3c 55%, #111);
}
.pv[data-kind="video"] .pv-sheet .hdr { display: none; }
.pv[data-kind="video"] .pv-sheet .body {
  color: #fff; display: grid; place-items: center; font-size: 0; padding: 0;
}
.pv[data-kind="video"] .play {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.92); color: #111;
  display: grid; place-items: center; font-size: 14px; padding-left: 2px;
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
}

.pv[data-kind="folder"] {
  background: transparent; border: 0; box-shadow: none;
}
.pv[data-kind="folder"] .pv-sheet { display: none; }
.pv[data-kind="folder"] .folder-stack {
  position: absolute; inset: 18% 12% 16%;
}
.pv[data-kind="folder"] .folder-tab {
  position: absolute; left: 6%; top: -8%; width: 34%; height: 18%;
  background: #f6c453; border-radius: 5px 6px 0 0;
}
.pv[data-kind="folder"] .folder-body {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #ffd76a, #f0b429);
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(180,120,0,.28);
}

.pv[data-kind="product"] .pv-sheet,
.pv[data-kind="chat"] .pv-sheet,
.pv[data-kind="mail"] .pv-sheet,
.pv[data-kind="cal"] .pv-sheet {
  inset: 14%; border-radius: 16px;
  background: linear-gradient(180deg, #f7f8ff, #e9edff);
  display: grid; place-items: center; box-shadow: var(--lg-shadow);
}
.pv[data-kind="product"] .pv-sheet .hdr,
.pv[data-kind="chat"] .pv-sheet .hdr,
.pv[data-kind="mail"] .pv-sheet .hdr,
.pv[data-kind="cal"] .pv-sheet .hdr { display: none; }
.pv[data-kind="product"] .pv-sheet .body,
.pv[data-kind="chat"] .pv-sheet .body,
.pv[data-kind="mail"] .pv-sheet .body,
.pv[data-kind="cal"] .pv-sheet .body {
  font-size: 28px; line-height: 1; padding: 0; color: var(--lg-accent);
  display: grid; place-items: center;
}

.lg-meta { margin-top: 9px; min-height: 3.6em; }
.lg-meta b {
  display: block;
  font: 500 12.5px/1.25 -apple-system, system-ui, sans-serif;
  color: var(--lg-ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lg-meta small {
  display: block; margin-top: 2px;
  font: 400 11px/1.3 -apple-system, system-ui, sans-serif;
  color: var(--lg-muted);
}

/* Cone half-screen canvas sidebar */
.cone-panel {
  display: none; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--lg-line);
  background:
    radial-gradient(120% 80% at 100% 0%, color-mix(in srgb, var(--lg-accent) 10%, transparent), transparent 55%),
    #fff;
  box-shadow: -16px 0 48px rgba(0,0,0,.08);
}
.lg-frame.cone-open .cone-panel { display: flex; }
.cone-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 12px; border-bottom: 1px solid var(--lg-line);
}
.cone-head .mark-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--lg-accent) 12%, #fff);
  color: var(--lg-accent);
  font: 700 11px/1 -apple-system, system-ui, sans-serif;
  letter-spacing: .04em; text-transform: uppercase;
}
.cone-head h2 {
  margin: 0; flex: 1;
  font: 700 17px/1.2 -apple-system, system-ui, sans-serif;
  letter-spacing: -.02em;
}
.cone-head .icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: #f2f2f7;
  cursor: pointer; display: grid; place-items: center;
}
.cone-body {
  flex: 1; min-height: 0; overflow: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 14px;
}
.cone-thread { display: flex; flex-direction: column; gap: 10px; }
.cone-msg {
  max-width: 94%; padding: 11px 13px; border-radius: 16px;
  font: 400 14px/1.4 -apple-system, system-ui, sans-serif;
  white-space: pre-wrap;
}
.cone-msg.user {
  align-self: flex-end; background: var(--lg-accent); color: #fff;
  border-bottom-right-radius: 5px;
}
.cone-msg.bot {
  align-self: flex-start; background: #f2f2f7; color: var(--lg-ink);
  border-bottom-left-radius: 5px;
}
.cone-msg small { display: block; margin-top: 5px; opacity: .65; font-size: 11px; }
.cone-hits {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
}
.cone-hit {
  border: 1px solid var(--lg-line); border-radius: 14px; padding: 8px;
  background: #fff; cursor: pointer; text-align: left;
  transition: border-color .15s ease, transform .15s ease;
}
.cone-hit:hover { border-color: color-mix(in srgb, var(--lg-accent) 40%, #ccc); transform: translateY(-1px); }
.cone-hit .pv { border-radius: 12px; }
.cone-hit b {
  display: block; margin-top: 7px;
  font: 600 12px/1.25 -apple-system, system-ui, sans-serif;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cone-hit small { color: var(--lg-muted); font-size: 11px; }
.cone-composer {
  border-top: 1px solid var(--lg-line); padding: 12px 14px 16px;
  display: grid; gap: 8px; background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
}
.cone-composer textarea {
  width: 100%; min-height: 78px; resize: vertical;
  border: 1px solid var(--lg-line); border-radius: 14px;
  padding: 12px 14px;
  font: 400 15px/1.35 -apple-system, system-ui, sans-serif;
  outline: none; background: #f9f9fb;
}
.cone-composer textarea:focus {
  border-color: color-mix(in srgb, var(--lg-accent) 50%, #ccc);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lg-accent) 14%, transparent);
  background: #fff;
}
.cone-composer .row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.cone-composer .row small { color: var(--lg-muted); font-size: 12px; }
.cone-composer .primary {
  border-radius: 12px; padding: 11px 16px; border: 0; cursor: pointer;
  background: var(--lg-accent); color: #fff;
  font: 650 14px/1 -apple-system, system-ui, sans-serif;
}

.page-top { background: rgba(255,255,255,.82); backdrop-filter: blur(12px); }
