* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 1rem/1.55 var(--font-sans); }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); text-underline-offset: .2em; }
a:hover { color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.skip-link { position: absolute; top: 8px; left: 8px; z-index: 100; padding: 10px; background: var(--bg); transform: translateY(-200%); }
.skip-link:focus { transform: none; }
.community-shell { width: min(100% - clamp(32px, 9vw, 120px), 1240px); margin-inline: auto; }
.community-top { border-bottom: 1px solid var(--border); }
.community-nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 20px; padding-block: 12px; }
.community-brand { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; color: var(--text); text-decoration: none; font-size: 1.025rem; font-weight: 700; letter-spacing: -.025em; }
.community-brand::before { content: ''; width: 9px; height: 9px; border-radius: 3px; background: var(--accent); }
.community-nav nav, .community-account-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 12px; }
.community-nav nav a { display: inline-flex; align-items: center; min-height: 40px; color: var(--muted); text-decoration: none; font-size: .8125rem; }
.community-nav nav a[aria-current="page"], .community-nav nav a:hover { color: var(--text); }
.community-nav nav a[aria-current="page"] { text-decoration: underline; }
.community-account-actions { gap: 4px 8px; }
.account-menu { position: relative; }
.account-menu:not(:has(#communityUser:not([hidden]))) { display: none; }
.account-menu summary { max-width: 17ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.disclosure-panel { position: absolute; right: 0; top: calc(100% + 7px); z-index: 1; display: grid; gap: 6px; width: max-content; max-width: calc(100vw - 32px); padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.disclosure-panel .btn { text-align: left; }
.btn, select { min-height: 40px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: 600 .8125rem var(--font-sans); }
.btn, select, summary { cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { cursor: default; color: var(--muted); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent:hover:not(:disabled) { background: #c3f6df; color: var(--accent-ink); }
.quiet-button { background: transparent; border-color: transparent; color: var(--secondary); }

.community-intro { display: grid; grid-template-columns: minmax(0, 1.36fr) minmax(0, 1fr); align-items: center; gap: clamp(20px, 5vw, 70px); padding-block: clamp(32px, 6vw, 80px) clamp(32px, 5vw, 58px); border-bottom: 1px solid var(--border); }
.community-intro h1 { font-size: clamp(2.35rem, 6vw, 4.5rem); line-height: 1; letter-spacing: -.055em; }
.community-intro > div > p { max-width: 42ch; margin-top: 16px; color: var(--secondary); font-size: clamp(.95rem, 2vw, 1.125rem); }
.community-guide { display: grid; gap: 8px; padding: clamp(16px, 3vw, 25px); border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.community-guide h2 { font-size: 1.08rem; }
.community-guide p { color: var(--muted); font-size: .875rem; }
.community-guide a { width: fit-content; max-width: 100%; font-size: .875rem; font-weight: 600; }
.alpha-feed { padding-block: 26px 64px; scroll-margin-top: 16px; }
.alpha-feed-header { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding-bottom: 12px; }
.alpha-feed-header h2 { margin-right: auto; font-size: clamp(1.175rem, 3vw, 1.65rem); letter-spacing: -.02em; }
.alpha-feed-header label, .alpha-source-meta, .alpha-hint { color: var(--muted); font-size: .8125rem; }
.alpha-hint:not(:empty) { margin-block: 6px; }
.community-list { display: grid; gap: 12px; margin: 10px 0 16px; }
#alphaFeed { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
.community-list article { padding: clamp(14px, 3vw, 22px); border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow-wrap: anywhere; }
.alpha-entry { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; }
.alpha-entry h3 { font-size: 1.08rem; line-height: 1.35; }
.alpha-entry > a { font-size: .875rem; font-weight: 600; }
.alpha-meta, .alpha-actions, .alpha-author { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px; }
.alpha-author { color: var(--muted); font-size: .8125rem; }
.alpha-meta .ticker { color: var(--secondary); font: 500 .75rem var(--font-mono); }
.tag, .alpha-votes { border-radius: 5px; padding: 3px 7px; background: var(--surface-hover); color: var(--secondary); font-size: .75rem; }
.alpha-votes { background: var(--accent-dim); color: var(--accent); font-variant-numeric: tabular-nums; }
.alpha-submission-body { max-width: 100%; font-size: .875rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.alpha-prompt-preview { max-width: 100%; font-size: .875rem; }
.alpha-prompt-preview summary { color: var(--accent); }
.alpha-prompt-preview p { margin-top: 8px; }
.alpha-actions { width: 100%; margin-top: auto; padding-top: 6px; }
.community-delete { margin-left: auto; color: #fca5a5; }

.modal-backdrop { position: fixed; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center; padding: 10px; background: #0009; }
.modal-backdrop.open { display: flex; }
.modal { width: min(100%, 690px); max-height: min(90dvh, 900px); overflow-y: auto; padding: clamp(14px, 4vw, 28px); border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-header h2 { font-size: clamp(1.25rem, 4vw, 1.7rem); line-height: 1.2; }
.alpha-modal .tabs, .alpha-form-actions, .history-filter-actions, #communityProviders, .alpha-footer { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 8px; }
.alpha-modal .tabs, #communityProviders { margin: 10px 0; }
.tab { min-height: 38px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--secondary); font: 600 .8125rem var(--font-sans); cursor: pointer; }
.tab.active { background: var(--accent-dim); color: var(--accent); }
.alpha-intro, .alpha-footer, .history-meta, .community-form small { color: var(--muted); font-size: .8125rem; }
.community-form { display: grid; gap: 12px; margin: 10px 0 12px; }
.community-form label { display: grid; gap: 4px; color: var(--secondary); font-size: .8125rem; }
.community-form input, .community-form select, .community-form textarea { width: 100%; min-width: 0; min-height: 40px; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; }
.community-form textarea { resize: vertical; }
.alpha-field-row, .history-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.history-query, .history-filter-actions { grid-column: 1 / -1; }

@media (max-width: 760px) {
  .community-nav nav { order: 2; width: 100%; }
  .community-nav { padding-block: 8px; }
  .community-intro, #alphaFeed { grid-template-columns: minmax(0, 1fr); }
  .alpha-feed-header h2 { width: 100%; }
}
@media (max-width: 385px) {
  .community-nav { column-gap: 4px; }
  .community-nav nav { gap: 0 7px; }
  .community-brand { font-size: .875rem; gap: 6px; }
  .community-account-actions .btn { padding-inline: 7px; }
  .alpha-field-row { grid-template-columns: minmax(0, 1fr); }
}
