/* ───────────── Top bar ───────────── */

.app:not(.is-import) .appbar {
  padding-top: 12px;
  padding-bottom: 14px;
}

/* ─── Collapsed icon strip (double-click to toggle) ─── */

/* Expandable body wrapper — same grid-row trick as .widget-body */
.appbar-body {
  display: grid;
  grid-template-rows: 1fr;
  overflow: hidden;
  opacity: 1;
  width: 100%;
  min-height: 0;
  transition: grid-template-rows 220ms ease, opacity 180ms ease;
}
.appbar-body-inner {
  min-height: 0;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  align-items: stretch;
  gap: 22px;
}

/* Strip wrapper — collapsed by default */
.appbar-icon-strip {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  min-height: 0; /* prevent flex parent from reserving space when row is 0fr */
  transition: grid-template-rows 220ms ease, opacity 200ms ease 20ms;
}
.appbar-strip-inner {
  min-height: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 auto;
}

/* Collapsed state */
.app.appbar-collapsed .appbar-body {
  grid-template-rows: 0fr;
  opacity: 0;
  pointer-events: none;
  height: 0; /* force flex child to zero — grid-template-rows alone isn't enough in a flex container */
}
.app.appbar-collapsed .appbar-icon-strip {
  grid-template-rows: 1fr;
  opacity: 1;
  pointer-events: auto;
  width: 100%;
  height: 40px;
  align-items: center;
}
.app.appbar-collapsed .appbar {
  min-height: 52px;
  height: 52px;
  padding: 6px 14px;
  justify-content: center;
  align-items: center;
}
.app.appbar-collapsed .appbar-strip-inner {
  height: 40px;
  align-items: center;
}

.strip-sq {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--glass-line);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, opacity 120ms;
}
.strip-sq:hover { background: rgba(255,255,255,0.08) !important; }
.strip-sq-process:hover { filter: brightness(1.1); }
.strip-sq-brand {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
  background: rgba(255,255,255,0.05);
  letter-spacing: -0.03em;
}
.strip-sq-url {
  background: rgba(255,255,255,0.03);
  color: var(--ink-faint);
  margin-right: 3px;
}
.strip-sq-stems {
  display: flex;
  align-items: center;
  gap: 5px;
}
.strip-sq-stem {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity 120ms, background 120ms;
}
.strip-sq-stem:hover { opacity: 0.85 !important; }
.strip-sq-stem.inactive { opacity: 0.2; }
.strip-sq-process {
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 100%);
  color: #17130c;
  border-color: transparent;
  margin-left: 4px;
}
.strip-sq-process.loading {
  cursor: progress;
  filter: saturate(0.92);
}
.strip-sq-process.loading svg {
  display: none;
}
.strip-sq-process.loading::before {
  content: "";
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border-radius: 50%;
  background: conic-gradient(currentColor 0deg 270deg, transparent 270deg 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 0);
  animation: spin 0.85s linear infinite;
}

.brand-version {
  font-size: 11px;
  color: rgba(216,222,230,0.35);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.brand-update-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(100, 200, 120, 0.10);
  border: 1px solid rgba(100, 200, 120, 0.22);
  color: #6dcc82;
  font-size: 9px;
  text-decoration: none;
}
.brand-update-chip:hover {
  background: rgba(100, 200, 120, 0.2);
  color: #88dfa0;
}

.appbar {
  display: flex;
  flex-direction: column;
  padding: 20px 24px 22px;
  border: 1px solid var(--glass-line);
  border-radius: 16px;
  background:
    radial-gradient(circle at 82% -20%, rgba(216, 168, 74, 0.11), transparent 20rem),
    linear-gradient(180deg, rgba(27, 39, 48, 0.76), rgba(13, 22, 30, 0.84));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    var(--shadow-panel);
  transition: padding 220ms ease;
}

.brand-group {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  padding-right: 8px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand {
  margin: 0;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 24px;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.brand-logo {
  display: block;
  width: 190px;
  height: auto;
}

.beta-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 5px;
  border: 1px solid rgba(216, 168, 74, 0.65);
  border-radius: 6px;
  background: var(--gold-soft);
  color: var(--gold-bright);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.brand-sub {
  font-size: 13px;
  color: var(--ink-dim);
  white-space: nowrap;
}

.post-urlbar,
.post-process-btn {
  display: none;
}

.appbar-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.appbar-import-panel {
  min-width: 0;
}

.appbar-import-panel .import-input-row {
  grid-template-columns: minmax(0, 1fr) clamp(140px, 14vw, 220px);
  gap: clamp(12px, 2vw, 28px);
  padding-bottom: 22px;
}

.appbar-import-panel .url-wrap {
  min-height: 58px;
  padding: 0 20px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 11px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
    rgba(3, 9, 14, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.035),
    inset 0 -1px 0 rgba(0, 0, 0, 0.32),
    0 0 0 0 rgba(216, 168, 74, 0);
  transition:
    border-color var(--t-base) var(--easing),
    box-shadow var(--t-base) var(--easing),
    background-color var(--t-base) var(--easing);
}

.appbar-import-panel .url-wrap:focus-within {
  border-color: rgba(216, 168, 74, 0.56);
  background-color: rgba(6, 13, 19, 0.86);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    inset 0 -1px 0 rgba(0, 0, 0, 0.34),
    0 0 0 3px rgba(216, 168, 74, 0.08),
    0 14px 34px rgba(0, 0, 0, 0.22);
}

.appbar-import-panel .url-prefix {
  color: #cbd2dc;
  opacity: 0.92;
}

.appbar-import-panel input[type="url"] {
  font-size: clamp(15px, 0.95vw, 18px);
  height: 100%;
  color: #edf0f4;
  caret-color: var(--gold-bright);
  letter-spacing: 0;
}

.appbar-import-panel .btn-primary {
  height: 58px;
  min-width: 0;
  width: 100%;
  border-radius: 11px;
  font-size: clamp(14px, 0.9vw, 16px);
}

.appbar-import-panel .stem-choice-row {
  grid-template-columns: clamp(110px, 11vw, 156px) repeat(6, minmax(0, 1fr));
  gap: clamp(8px, 1vw, 14px);
  padding-top: 20px;
}

.appbar-import-panel .stem-choice-row > span {
  font-size: clamp(12px, 0.8vw, 14px);
}

.appbar-import-panel .stem-choice {
  min-height: 48px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: clamp(12px, 0.8vw, 14px);
  background:
    linear-gradient(180deg, color-mix(in srgb, currentColor 9%, transparent), transparent),
    rgba(8, 15, 22, 0.42);
}

.url-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
  cursor: text;
}

.url-prefix {
  flex-shrink: 0;
  color: #d7dbe2;
}

.appbar-form input[type="url"],
.appbar-import-panel input[type="url"],
.import-card input[type="url"] {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 19px;
  padding: 0;
  min-width: 0;
  appearance: none;
  box-shadow: none;
}

.appbar-form input[type="url"]::placeholder,
.appbar-import-panel input[type="url"]::placeholder,
.import-card input[type="url"]::placeholder {
  color: #9da3ad;
  opacity: 0.78;
}

.appbar-import-panel input[type="url"]::selection {
  background: rgba(216, 168, 74, 0.28);
  color: #fff6de;
}

.appbar-import-panel input[type="url"] {
  font-size: clamp(15px, 0.95vw, 18px);
  color: #edf0f4;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 56px;
  min-width: 150px;
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 100%);
  color: #17130c;
  border: 0;
  border-radius: var(--radius);
  padding: 0 24px;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.38),
    0 16px 36px rgba(216, 168, 74, 0.18);
  transition:
    filter var(--t-base) var(--easing),
    transform var(--t-fast) var(--easing);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.82;
  cursor: progress;
}

.btn-primary.loading {
  filter: saturate(0.92);
}

.btn-primary.loading .icon {
  display: none;
}

.btn-primary.loading::before {
  content: "";
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 50%;
  background: conic-gradient(currentColor 0deg 270deg, transparent 270deg 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 0);
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-primary.loading::before {
    animation-duration: 1.8s;
  }
}
