:root {
  --bg: #fafafa;
  --panel: #f5f5f5;
  --surface: #ffffff;
  --text: #0b0b0c;
  --muted: #6b6b6f;
  --line: #e5e5e7;
  --line-2: #ededf0;
  --brand-h: 56px;
  --radius: 12px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, .06);
  --container-max: 1120px;
  --space-md: 16px;
  --space-lg: 32px;
  --content-max:768px;
  --bgColor-neutral-muted: #f6f8fa;
  --color-neutral-muted: #f6f8fa;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100vh;
}

body {
  margin: 0;
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    linear-gradient(transparent 23px, rgba(0, 0, 0, .04) 24px),
    linear-gradient(90deg, transparent 23px, rgba(0, 0, 0, .04) 24px),
    radial-gradient(1200px 400px at 80% -10%, rgba(0, 0, 0, .06), transparent 60%),
    var(--bg);
  background-size: 24px 24px, 24px 24px, auto, auto;
  overflow: hidden;
}

/* App shell */
.app {
  display: grid;
  grid-template-columns: 200px 1fr;
  grid-template-rows: var(--brand-h) 1fr;
  column-gap: 0;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  grid-row: 1 / span 2;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: grid;
  grid-template-rows: var(--brand-h) 1fr;
  backdrop-filter: saturate(1.1);
  position: sticky;
  top: 0;
  height: 100vh;
  /* stays fixed */
  overflow: hidden;
  /* last row */
  grid-template-rows: var(--brand-h) 1fr auto;
  width: 100%
}

.brand {
  height: var(--brand-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: conic-gradient(from 180deg at 50% 50%, #fff, #f2f2f2, #fff);
  box-shadow: inset 0 0 0 2px #111, inset 0 0 0 4px #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: .5px;
}

.brand-name {
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
  font-size: 13px;
}

.nav {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
  font-size: 16px;
}

@media (max-width: 980px) {
  .nav {
    width: 100%;
    box-sizing: border-box;
  }
}

.nav button,
.nav a {
  font-size: inherit;
  appearance: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
}

.nav button:hover,
.nav a:hover{
  background: #eee;
}

.nav button[aria-current="page"] {
  background: #ececec;
  border-color: #e2e2e2;
}

.nav a {
  text-decoration: none;
}

/* Ensure primary styling wins inside the sidebar nav */
.nav .btn.btn-primary {
  background: #111;
  color: #fff;
  border-color: #111;
}

.nav .btn.btn-primary:hover {
  background: #000;
}

/* Header (right of sidebar) */
.header {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  height: var(--brand-h);
  backdrop-filter: saturate(1.05);
  gap: 12px;
}

/* user slot */
/* User slot at the bottom */
.user-slot {
  /*border-top: 1px solid var(--line);*/
  padding: 10px;
  /*background: linear-gradient(#f9f9f9,#f4f4f4);*/
}

/* Compact user chip */
.user-chip {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.user-chip:hover {
  background: #f6f6f6;
}

.user-chip .avatar,
.comment-row .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.user-chip[aria-expanded="true"] {
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.user-chip .meta {
  line-height: 1.1;
  min-width: 0;
}

.user-chip .name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-chip .handle {
  font-size: 12px;
  color: var(--muted);
}

/* Dropdown menu */
.user-menu-anchor {
  position: relative;
  display: block;
}

.user-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  z-index: 1000;
}

.user-menu[hidden] {
  display: none;
}

/* allow flipping below if JS sets data-placement="bottom" */
.user-menu[data-placement="bottom"] {
  bottom: auto;
  top: calc(100% + 8px);
  /* ⬇️ show below the button */
}

/* Little pointer at the bottom edge of the menu (since it sits above) */
.menu-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  border-radius: 10px 10px 0 0;
  border-bottom: none;
}

.menu-caret {
  position: absolute;
  bottom: -5px;
  right: 12px;
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  background: var(--card-bg, #fff);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

/* Rotate chevron when open */
.user-chip svg {
  transition: transform .15s ease;
}

.user-chip[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.user-menu button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.user-menu button:hover {
  background: #f0f0f0;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(720px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  box-shadow: var(--shadow);
  margin-right: auto;
}

.search input {
  width: 100%;
  border: none;
  outline: none;
  font: inherit;
  color: var(--text);
  background: transparent;
}

.search .kbd {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px 6px;
}

/* Views (key: don't override grid) */
.content {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  /* ensure subgrid-container's margin starts at the sidebar border */
  padding-left: 0;
  padding-right: 0;
}

/* Subgrid container INSIDE .content */
.subgrid-container {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--container-max);
  /* was m:w-[1120px] */
  margin-left: auto;
  margin-right: auto;
  justify-content: stretch;
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

/* Medium screens and up (Tailwind md ≈ 768px) */
@media (min-width: 768px) {
  .content > .subgrid-container {
    /* keep it in column 2, just adjust paddings for md */
    padding-left: var(--space-lg);
    /* m:px-lg */
    padding-right: var(--space-lg);
    /* m:px-lg */
  }
}

.main-container {
  width: 100%;
  flex: 1 1 0%;
  gap: var(--space-lg, 24px);
  place-content: space-between;
  max-width: var(--content-max);
  margin: 0 auto;
  padding-inline: var(--space-md);
}

@media (min-width: 768px) {
  .main-container {
    /* “flex” behavior between 768px–1099px */
    grid-template-columns: minmax(0, var(--content-max)) auto;
  }
}

@media (min-width: 1100px) {
  .main-container {
    /* “fixed” behavior at large desktop */
    grid-template-columns: minmax(0, var(--content-max)) minmax(0, var(--rail-width));
  }
}

.view {
  height: 100%;
  overflow: auto;
}

.view:not(.active) {
  display: none;
}

/* Home */
.home {
  padding: 28px;
  color: var(--muted);
  overflow: auto;
}

.home .panel {
  max-width: 720px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.home h1 {
  margin: 0 0 8px;
  font-size: 20px;
  color: var(--text);
  letter-spacing: .2px;
}

.home p {
  margin: 0;
}

/* Messages (two columns) */
.view.messages {
  overflow: hidden;
}

.messages {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100%;
}

.convo-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* Sticky header on the left list */
.convo-header {
  position: sticky;
  top: 0;
  z-index: 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 8px;
}

/* Reuse your button styles; make it full width in the narrow list */
.convo-header .btn {}

/* New chat modal (reuses auth modal look) */
#newchat-modal[aria-hidden="false"] {
  display: block;
}

#newchat-modal {
  position: fixed;
  inset: 0;
  display: none;
}

#newchat-modal .overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  backdrop-filter: blur(2px);
}

#newchat-modal .card {
  position: relative;
  z-index: 1;
  width: min(520px, 92vw);
  margin: 12vh auto;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
}

#newchat-modal .row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

#newchat-modal label {
  font-size: 12px;
  color: var(--muted);
}

#newchat-modal input,
#newchat-modal textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  resize: vertical;
}

#newchat-modal .actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  margin-top: 8px;
}

#newchat-error {
  color: #b00020;
  font-size: 12px;
}

.convo-list {
  border-right: 1px solid var(--line);
  background: linear-gradient(#f7f7f7, #f3f3f3);
  overflow: auto;
}

.convo-item {
  width: 100%;
  text-align: left;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.convo-item+.convo-item {
  border-top: 1px solid var(--line-2);
}

.convo-item:hover {
  background: #efefef;
}

.convo-item:active {
  background: #e9e9e9;
}

.convo-item.is-active,
.convo-item[aria-current="true"] {
  background: #eaeaea;
  border-color: #ddd;
}

.convo-title {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.convo-meta {
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.convo-preview {
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.convo-unread,
.notif-unread {
  text-align: right;
  justify-self: end;
  align-self: start;
  display: inline-block;
  padding: 2px 6px;
  border-radius: 8px;
  background: #111;
  border: 1px solid #e8e8e8;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
}

.conversation {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.conversation-empty {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--muted);
}

#view-messages .conversation-empty[hidden] {
  display: none !important;
}

.message-list {
  padding: 16px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
}

.msg {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  flex: 0 0 auto;
}

.msg-header {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Composer */
.conversation-composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 10px 12px;
}

.conversation-composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 160px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
}

.conversation-composer textarea:focus {
  outline: 2px solid #111;
  outline-offset: 2px;
}

.conversation-composer .btn-primary:disabled {
  opacity: .45;
  background: #cfcfcf;
  border-color: #cfcfcf;
  cursor: not-allowed;
  box-shadow: none;
}

/* Profile view */
.profile {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
}

.profile-header {
  padding: 16px 20px;
  position: relative;
}

.profile-header::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 20px;
  bottom: 0;
  height: 1px;
  background-color: var(--line);
}

.profile-title {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: .2px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.profile-handle {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.profile-articles {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.article {
  padding: 12px 14px;
}

.article h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.article .meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.load-more-sentinel {
  padding: 12px;
  text-align: center;
  color: var(--muted);
}

/* Indicators */
#convos-indicator,
#messages-indicator {
  display: none;
  padding: 12px;
  color: var(--muted);
}

#convos-indicator.htmx-request,
#messages-indicator.htmx-request {
  display: block;
}

/* Mobile */
@media (max-width: 980px) {
  .app {
    grid-template-columns: 140px 1fr;
  }

  .brand-name {
    display: none;
  }

  .messages {
    grid-template-columns: 1fr;
  }

  .convo-list {
    height: 40%;
  }

  .conversation {
    height: 60%;
  }
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.btn:hover {
  background: #f3f3f3;
}

.btn:active {
  background: #ededed;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.btn-primary {
  background: #111;
  color: #fff;
  border-color: #111;
}

.btn-primary:hover {
  background: #000;
}

/* Disabled buttons look and feel disabled */
.btn:disabled,
.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: .45;
  background: #efefef;
  color: #7a7a7a;
  border-color: #dcdcdc;
  cursor: not-allowed;
  box-shadow: none;
  pointer-events: none;
  /* prevents hover effects on non-button elements styled as .btn */
}

/* Primary variant when disabled */
.btn-primary:disabled,
.btn-primary[disabled],
.btn-primary[aria-disabled="true"] {
  background: #cfcfcf;
  border-color: #cfcfcf;
  color: #fff;
}

/* Ensure hover/active don't override the disabled look */
.btn:disabled:hover,
.btn[disabled]:hover,
.btn:disabled:active,
.btn[disabled]:active,
.btn-primary:disabled:hover,
.btn-primary[disabled]:hover {
  background: inherit;
}

/* Nice focus ring for enabled buttons */
.btn:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 5;
}

.modal[aria-hidden="false"] {
  display: block;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(480px, 92vw);
  margin: 12vh auto;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

#keyboard-modal .modal-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
}

#keyboard-modal #shortcuts-title {
  order: 1;
  flex: 1 1 auto;
}

#keyboard-modal .modal-close {
  order: 2;
  margin-left: auto;
}

#keyboard-modal .modal-subtitle {
  order: 3;
  flex: 0 0 100%;
  margin: 8px 0 0;
}

#keyboard-modal .tabs{
  border-bottom: none;
  margin: 16px -24px 0;
  padding: 0 24px;
  display: flex;
  gap: 24px;
}

.modal-title {
  font-weight: 800;
  letter-spacing: .3px;
}

.modal-close {
  appearance: none;
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #333;
}

/* Auth forms */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-form label {
  font-size: 12px;
  color: var(--muted);
}

.auth-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.auth-note {
  font-size: 12px;
  color: var(--muted);
}

.auth-link {
  color: #111;
  text-decoration: underline;
  cursor: pointer;
}

.hint-list {
  margin: 6px 0 0 0;
  padding-left: 18px;
}

.hint-list li {
  list-style: none;
  position: relative;
  padding-left: 14px;
  color: var(--muted);
}

.hint-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  top: 0;
}

.hint-list li.ok {
  color: var(--text);
  font-weight: 600;
}

.hint-list li.ok::before {
  content: "✓";
}

/* Specific rule for the user consent label */
.auth-form label:has(#signup-consent) {
  text-align: left;
}

/* Override input size for this specific checkbox */
.auth-form label:has(#signup-consent) input[type="checkbox"] {
  width: auto !important;
  margin-top: 3px;
  /* visually aligns box with text */
  flex-shrink: 0;
}


/* Write (Create Article) view */
.write {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
}

.write-header {
  padding: 16px 20px;
  font-weight: 800;
  letter-spacing: .2px;
  position: relative;
}

.write-header::after{
  content: "";
  position: absolute;
  left: 16px;
  right: 20px;
  bottom: 0;
  height: 1px;
  background-color: var(--line);
}

.write-form {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.write-form .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.write-form input[type="text"],
.write-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.write-form textarea {
  resize: vertical;
  min-height: 220px;
}

.write-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: auto;
  align-items: center;
}

#write-saving[hidden] {
  display: none;
}

/* Write counters + errors */
.field .count-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 4px;
  min-height: 1.2em;
  /* avoid layout jump */
}

/* Write counters + errors */
.field .radio-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 4px;
  min-height: 1.2em;
  padding-bottom: 0.5em;
  /* avoid layout jump */
}

.field .radio-row .radio-button {
  align-self: auto;
  /* override earlier align-self */
}

.field .count-row .error-text {
  margin: 0;
  white-space: nowrap;
  /* keep row height stable */
  overflow: hidden;
  text-overflow: ellipsis;
  color: #b00020;
}

.field .count-row .count {
  margin-left: auto;
  /* pin counter to the right */
  align-self: auto;
  /* override earlier align-self */
}

.field .count-row .count.error {
  color: #b00020;
  font-weight: 600;
}

/*Mardown editor*/
.markdown-editor {
  display: flex;
  border-radius: 10px;
  border: 1px solid var(--line);  
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  background: #fff;
  flex-direction: column;
  color: var(--text);
  height: 100%;
  width: 100%;
  margin-top: 5px;
}

.markdown-editor-write-container{
  display: block;
}

.markdown-editor-preview-container {
  display: none;
}

.markdown-editor.preview-mode .markdown-editor-write-container {
  display: none;
}

.markdown-editor.preview-mode .markdown-editor-preview-container {
  display: block;
}

/* simple tab styling */
.markdown-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
}

.markdown-tab {
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: #8b949e;
    cursor: pointer;
    font-size: 13px;
    border-right: 1px solid transparent;
    border-left: 1px solid transparent;
  }
  
.markdown-tab:first-child {
  border-top-left-radius: 6px;
 }

.markdown-tab.active {
  background: #0d1117;
  color: #8b949e;
  border-bottom: 1px solid var(--line);
  /* visually merges with content */
  border-right-color: #30363d;
  border-left-color: #30363d;
  font-weight: 500;
}

.markddown-tab:hover:not(.active) {
  background: #1c2128;
}

/* Toolbar row */
.toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}

.toolbar button {
  border: 1px solid transparent;
  background: transparent;
  color: #8b949e;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
}

.toolbar button b,
.toolbar button i {
  font-weight: 600;
}

.toolbar button:hover {
  background: #21262d;
  border-color: #30363d;
}

.toolbar button:active {
  background: #30363d;
}

/* tiny divider between groups of tools */
.toolbar-separator {
  width: 1px;
  height: 18px;
  background: #30363d;
  margin: 0 4px;
}

/* Editor + preview area */
.markdown-editor-write-container,
.markdown-editor-preview-container {
  padding: 8px 10px;
}

/* default: “Write” mode */
.markdown-editor-write-container {
  display: block;
  min-height: 230px;
 
}

.markdown-editor-preview-container {
  display: block;
  min-height: 230px;
}

#markdown-editor-write {
  width: 100%;
  height: 100%;
  resize: vertical;
  border: none;
  outline: none;
  color: #0d1117;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 14px;
}

.md :where(p, ol, ul, h1, h2, h3, h4, h5, h6, blockquote) {
  margin: 0.5em 0;
}

.render-preview {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.render-viewer {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.render-preview,
.render-viewer {
  height: 100%;
  width: 100%;
  font-size: 14px;
  resize: vertical;
  border: none;
  outline: none;
  color: #0d1117;
  padding: 8px 10px;

}

.markdown-image{
  max-width: 100%;
  /* responsive */
  height: auto;
}

.markdown-code{
  padding: .2em .4em;
  margin: 0;
  font-size: 85%;
  white-space: break-spaces;
  background-color: var(--bgColor-neutral-muted, var(--color-neutral-muted));
  border-radius: 6px;
}

ul:has(> li.task-list-item) {
  list-style: none;
  padding-left: 0;
}

.task-list {
  list-style: none;
  padding-left: 0;
}

.task-list-item {
  list-style-type: none;
}

.task-list-item>input[type="checkbox"] {
  margin-right: 0.4rem;
}

/* Mobile */
@media (max-width: 800px) {
  .container {
    grid-template-columns: 1fr;
  }
}

/* Read (Article) view */
.read {
  display: block;
  grid-template-rows: auto 1fr;
  height: 100%;
}

.read-header {
  padding: 16px 20px;
  position: relative;
}

.read-header::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 20px;
  bottom: 0;
  height: 1px;
  background-color: var(--line);
}

.read-header h1 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: .2px;
}

.read-header .meta {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}

.read-header .handle {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.read-content {
  padding: 8px 10px;
  overflow: auto;
  line-height: 1.6;
}

.read-error {
  padding: 16px 20px;
  color: #b00020;
}

/* 1) Baseline link normalization (keeps monochrome) */
a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, .35);
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: text-decoration-color .12s ease, text-decoration-thickness .12s ease;
}

a:hover {
  text-decoration-color: rgba(0, 0, 0, .85);
}

a:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Button-anchors keep button look */
a.btn,
a.btn:link,
a.btn:visited {
  text-decoration: none;
}

/* 2) Title links (formal) — e.g., profile article list, read header, convo titles */
.article h3 a,
.read-header h1 a,
.messages .convo-title a {
  text-decoration: none;
  /* no underline by default */
  color: var(--text);
  font-weight: 800;
  letter-spacing: .2px;
}

.article h3 a:hover,
.read-header h1 a:hover,
.messages .convo-title a:hover {
  text-decoration: underline;
  /* only underline on hover */
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;
  text-decoration-color: #111;
}

/* 3) Inline text links (body copy, small notes) */
.read-content a,
.home .panel a,
.auth-note a,
.meta a {
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.read-content a:hover,
.home .panel a:hover,
.auth-note a:hover,
.meta a:hover {
  text-decoration-thickness: 2px;
}

/* Optional: tone down visited inline links slightly (still monochrome) */
.read-content a:visited,
.home .panel a:visited,
.auth-note a:visited,
.meta a:visited {
  text-decoration-color: rgba(0, 0, 0, .5);
}

/* Comment */
/* Comment tree container & layers */
.comment-tree {
  position: relative;
  padding: 16px 20px;
  overflow: auto;
}

.comment-rails-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.comment-controls-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

/* A single comment node */
.comment-card {
  position: relative;
  margin-top: 10px;
  z-index: 1;
}

.comment-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

/* Content column (reuse .avatar for the left token) */
.comment-content {
  max-width: 68ch;
}

.comment-meta {
  color: var(--muted);
  margin-left: 8px;
}

.comment-body {
  margin-top: 4px;
  line-height: 1.5;
}

.comment-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.comment-actions .btn {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  box-shadow: none;
  padding: 0;
  border-radius: 8px;
  font-weight: 500;
}

.comment-actions .btn:hover {
  background: transparent;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.comment-actions .btn:active {
  transform: none;
}

.comment-actions .btn:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

/* Indentation for children (roughly avatar width) */
.comment-children {
  position: relative;
  margin-left: 28px;
}

/* Collapsed state hides body/actions/subtree */
.comment-card.comment-collapsed .comment-body,
.comment-card.comment-collapsed .comment-actions,
.comment-card.comment-collapsed>.comment-children {
  display: none !important;
}

/* Toggles: + (expand) & − (collapse on rail) */
.comment-toggle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: #111;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  cursor: pointer;
}

.comment-toggle--expand {
  /* + sits inline, replaces avatar when collapsed */
}

.comment-toggle--collapse {
  position: absolute;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
  pointer-events: auto;
}

/* “X more replies” pill */
.comment-load-more {
  display: inline-block;
  cursor: pointer;
  user-select: none;
  padding: 6px 10px;
  margin: 6px 0;
  border-radius: 10px;
  color: #111;
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 600;
}

/* htmx indicator state */
.comment-load-more[aria-busy="true"],
.comment-load-more.htmx-request {
  opacity: .6;
  pointer-events: none;
}

.reply-form {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.reply-form .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reply-form input[type="text"],
.reply-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.reply-form textarea {
  resize: vertical;
  min-height: 110px;
}

.reply-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 0;
  align-items: center;
}


/* votes */
.vote {
  --up: #16a34a;
  /* active/hover up */
  --down: #dc2626;
  /* active/hover down */
  --focus: #2563eb;
  /* focus ring */
  --neutral: #111827;

  display: inline-flex;
  align-items: center;
  gap: .5rem;
  user-select: none;
  color: var(--neutral);
  /* neutral by default */
}

/* round icon button */
.vote .icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: .3rem;
  border-radius: 9999px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  line-height: 0;
  text-decoration: none;
  transition: box-shadow .16s, background-color .16s, color .12s, transform .06s;
}

.vote .icon-btn:focus {
  outline: none;
}

.vote .icon-btn:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, #fff);
}

.vote .icon-btn:active {
  transform: translateY(1px);
}

.vote .icon-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

/* SVG: circle + chevron; INACTIVE = hollow neutral */
.vote .icon-btn svg {
  width: 24px;
  height: 24px;
  display: block;
}

.vote .circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.vote .chev {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* HOVER: apply color (still hollow) + soft halo */
@supports (color: color-mix(in srgb, #000 10%, #fff)) {
  .vote .icon-btn.up:hover {
    color: var(--up);
    background: color-mix(in srgb, var(--up) 14%, transparent);
  }

  .vote .icon-btn.down:hover {
    color: var(--down);
    background: color-mix(in srgb, var(--down) 14%, transparent);
  }
}

@supports not (color: color-mix(in srgb, #000 10%, #fff)) {
  .vote .icon-btn.up:hover {
    color: var(--up);
    background: rgba(22, 163, 74, .14);
  }

  .vote .icon-btn.down:hover {
    color: var(--down);
    background: rgba(220, 38, 38, .14);
  }
}

/* ACTIVE: filled circle + white chevron */
.vote .icon-btn[aria-pressed="true"].up .circle {
  fill: var(--up);
  stroke: var(--up);
}

.vote .icon-btn[aria-pressed="true"].up .chev {
  stroke: #fff;
}

.vote .icon-btn[aria-pressed="true"].down .circle {
  fill: var(--down);
  stroke: var(--down);
}

.vote .icon-btn[aria-pressed="true"].down .chev {
  stroke: #fff;
}

/* counts + score */
.vote .count {
  min-width: 2ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
  opacity: .9;
}

.vote .score {
  margin-left: .25rem;
  font-variant-numeric: tabular-nums;
  opacity: .7;
}

#view-notifications.view.notifications {
  height: calc(100vh - var(--brand-h));
}

.notifications-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  align-items: center;
}

.notifications-list {
  overflow: auto;
  padding: 8px 12px;
}

.notif-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}

.notif-item.unread {
  background: #f9f9f9;
}

.notif-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.notif-title {
  font-weight: 700;
}

.notif-meta {
  color: var(--muted);
  font-size: 12px;
}

.notif-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 8px;
  background: #f2f2f2;
  border: 1px solid #e8e8e8;
  font-size: 12px;
}

.notif-more {
  text-align: center;
  padding: 10px;
  color: var(--muted);
}

.notif-more.htmx-request {
  opacity: .6;
}

/* Hotkey focus*/
button:focus-visible,
input:focus-visible {
  outline: 2px solid #007aff;
  outline-offset: 2px;
}

 /* ====== Tabs ====== */
 .tabs {
   border-bottom: 1px solid #e4e4e4;
   margin: 16px -24px 0;
   padding: 0 24px;
   display: flex;
   gap: 24px;
 }

 .tab-button {
   border: none;
   background: transparent;
   padding: 10px 0;
   cursor: pointer;
   font-size: 14px;
   color: #666;
   border-bottom: 2px solid transparent;
 }

 .tab-button[aria-selected="true"] {
   color: #000;
   border-bottom-color: #000;
   font-weight: 500;
 }

 .tab-panels {
   padding-top: 16px;
 }

 .tab-panel {
   display: none;
 }

 .tab-panel.active {
   display: block;
 }

 /* ====== Shortcuts list ====== */
 .shortcut-row {
   display: flex;
   justify-content: space-between;
   align-items: center;
   padding: 6px 0;
   font-size: 14px;
 }

 .shortcut-label {
   color: #333;
 }

 .shortcut-key {
   padding: 4px 9px;
   border-radius: 4px;
   border: 1px solid #ddd;
   font-size: 12px;
   text-transform: uppercase;
   color: #555;
   background: #fafafa;
   min-width: 24px;
   text-align: center;
 }

 .section-footer {
   border-top: 1px solid #e4e4e4;
   margin-top: 12px;
   padding-top: 12px;
   display: flex;
   justify-content: space-between;
   align-items: center;
   font-size: 14px;
 }

 /* ====== Toggle switch ====== */
 .toggle-wrapper {
   display: flex;
   align-items: center;
   gap: 8px;
 }

 .toggle-label {
   font-size: 14px;
 }

 .toggle {
   position: relative;
   width: 46px;
   height: 24px;
 }

 .toggle input {
   opacity: 0;
   width: 0;
   height: 0;
 }

 .toggle-slider {
   position: absolute;
   cursor: pointer;
   inset: 0;
   background: #d0d0d0;
   border-radius: 999px;
   transition: 0.25s;
 }

 .toggle-slider::before {
   content: "";
   position: absolute;
   height: 18px;
   width: 18px;
   left: 3px;
   top: 3px;
   background: #fff;
   border-radius: 50%;
   transition: 0.25s;
   box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
 }

 .toggle input:checked+.toggle-slider {
   background: #165dff;
 }

 .toggle input:checked+.toggle-slider::before {
   transform: translateX(22px);
 }

 .kb-selected {
   outline: 2px solid currentColor;
   border-radius: 8px;
 }
/* popover event */
.info-btn {
  anchor-name: --info-btn;
}

.my-popover{
  position: fixed;
  position-anchor: --info-btn;
  inset: auto;
  bottom: calc(anchor(top) + 20px);
  justify-self: center;
}

.my-popover[popover] {
  max-width: min(360px, calc(100vw - 24px));
  white-space: normal;
  overflow-wrap: anywhere;
  border: 0;
  outline: 0;
  background: white;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
  border-radius: 12px;
  padding: 10px 12px;
}

.icon-btn {
  /* remove default button look */
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;

  /* layout */
  display: inline-flex;
  align-items: center;
  justify-content: center;

  /* optional: larger click target */
  width: 28px;
  height: 28px;
  border-radius: 8px;

  color: #111;
  /* icon color (uses currentColor) */
  cursor: pointer;
}