/* Zettelkasten template — tool styles. Site chrome lives in shared.css. */

.zk-page .header-back-link {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 6px 10px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.zk-page .header-back-link:hover {
  border-color: var(--text-secondary);
  text-decoration: none;
}

.zk-page .page-intro {
  max-width: 42rem;
}

.zk-page .lead {
  margin: 0 0 0.75rem;
  color: var(--text-secondary);
  font-size: 1.0625rem;
}

.zk-page .privacy-line {
  margin: 0;
}

.zk-tool {
  max-width: 980px;
  margin: 0 auto 1.25rem;
}

.zk-layout {
  display: grid;
  grid-template-columns: minmax(0, 15.5rem) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.zk-rail,
.downloads,
.seo,
.faq,
.apps {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem 1.15rem;
  margin: 0 0 1rem;
}

.zk-rail {
  margin: 0;
  min-width: 0;
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.rail-head h2,
.downloads h2,
.seo h2,
.faq h2,
.apps h2,
.cta h2 {
  margin: 0;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
}

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.card-list button {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  align-items: flex-start;
}

.card-list button.is-active {
  border-color: var(--text);
  box-shadow: inset 3px 0 0 var(--text);
}

.card-title {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.card-id {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.sheet {
  color-scheme: light;
  min-width: 0;
  background: #fffcf7;
  color: #1d1d1f;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1rem 1.1rem 0.9rem;
}

.sheet label,
.type-switch legend,
.link-box legend {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.6875rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #314152;
}

.type-switch,
.link-box {
  border: 0;
  margin: 0 0 0.9rem;
  padding: 0;
  min-width: 0;
}

.type-switch legend,
.link-box legend {
  flex-basis: 100%;
  padding: 0;
}

.type-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.sheet label.type-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.35rem 0.65rem;
  border: 1px solid #8aa0b8;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: #1d1d1f;
  background: #fff;
}

.type-option input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: #1d1d1f;
}

.id-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin-bottom: 0.85rem;
}

.field-id {
  flex: 1 1 12rem;
  min-width: 0;
}

.field-title,
.field-body,
.field-tags,
.field-extra {
  margin-bottom: 0.85rem;
  min-width: 0;
}

.sheet input,
.sheet textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #1d1d1f;
  font: inherit;
  line-height: 1.45;
}

.sheet input[type='text'] {
  padding: 0.4rem 0;
  border-bottom: 1px solid #d5dde6;
}

#card-id {
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.field-title input {
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.sheet textarea {
  resize: vertical;
  padding: 0.45rem 0;
  border-bottom: 1px solid #d5dde6;
}

.field-body textarea {
  min-height: 12rem;
  line-height: 28px;
  padding: 0.35rem 0.15rem 0.5rem;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 27px,
    #d5dde6 27px,
    #d5dde6 28px
  );
  background-position: 0 6px;
  background-attachment: local;
}

.sheet input:focus,
.sheet textarea:focus {
  outline: 2px solid #005bb5;
  outline-offset: 2px;
}

.sheet input::placeholder,
.sheet textarea::placeholder {
  color: #4d5d6e;
}

#links-empty {
  margin: 0.2rem 0 0;
  color: #314152;
  font-size: 0.875rem;
}

#link-choices {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

#link-choices label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0;
  padding: 0.4rem 0.15rem;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: #1d1d1f;
  overflow-wrap: anywhere;
}

#link-choices input {
  width: 1rem;
  height: 1rem;
  margin-top: 0.15rem;
  flex: 0 0 auto;
  accent-color: #1d1d1f;
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
}

.zk-tool button {
  font: inherit;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  min-height: 40px;
  cursor: pointer;
}

.sheet button {
  color: #1d1d1f;
  background: #fff;
  border-color: #8aa0b8;
}

.zk-tool button:hover {
  border-color: var(--text-secondary);
}

.zk-tool button.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.zk-tool button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.zk-tool button:focus-visible,
.zk-page a:focus-visible {
  outline: 2px solid #005bb5;
  outline-offset: 2px;
}

.downloads h3 {
  margin: 0.9rem 0 0.45rem;
  font-size: 0.8125rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.downloads p,
.seo p,
.apps p,
.faq p,
.cta p {
  margin: 0 0 0.75rem;
  line-height: 1.6;
}

.dl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.save-status {
  min-height: 1.25rem;
  margin: 0.75rem 0 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.seo a,
.faq a,
.zk-nav a {
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.seo h3,
.faq h3 {
  margin: 1.25rem 0 0.35rem;
  font-size: 1rem;
}

.seo ol,
.seo ul,
.apps ul {
  margin: 0 0 0.75rem;
  padding-left: 1.2rem;
}

.seo li,
.apps li {
  margin: 0.35rem 0;
  line-height: 1.5;
}

.faq details {
  border-top: 1px solid var(--border);
  padding: 0.7rem 0;
}

.faq details:last-of-type {
  border-bottom: 1px solid var(--border);
}

.faq summary {
  cursor: pointer;
  font-weight: 600;
}

.faq details p {
  margin: 0.45rem 0 0.2rem;
}

.cta {
  background: #243044;
  color: #f5f5f7;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.3rem 1.3rem;
  margin: 0 0 1rem;
}

.cta-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d5dde6;
}

.cta p {
  max-width: 40rem;
  color: #f5f5f7;
}

.cta-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: #1d1d1f;
  font-weight: 700;
  text-decoration: none;
}

.cta-link:hover {
  background: #fffcf7;
  text-decoration: none;
}

.app-links {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 0.5rem;
}

.app-links li {
  margin: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.app-links a {
  font-weight: 650;
}

.app-links span {
  display: block;
  margin-top: 0.15rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.zk-nav {
  margin: 0.25rem 0 0;
}

@media (max-width: 800px) {
  .zk-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail-head {
    flex-direction: column;
    align-items: stretch;
  }

  .card-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));
  }

  .field-body textarea {
    min-height: 9rem;
  }

  .dl-row button,
  #add-card {
    flex: 1 1 auto;
    width: 100%;
  }

  .cta-link {
    display: flex;
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
  }
}

@media print {
  body::before,
  .site-header,
  .site-footer,
  .page-intro,
  .zk-rail,
  .downloads,
  .seo,
  .faq,
  .cta,
  .apps,
  .save-status,
  .skip-link,
  .sheet-actions,
  .id-row button,
  .no-print {
    display: none !important;
  }

  body,
  main {
    margin: 0;
    padding: 0;
    max-width: none;
    background: #fff;
  }

  .zk-tool,
  .zk-layout {
    display: block;
    max-width: none;
    margin: 0;
  }

  .sheet {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }

  .sheet textarea {
    min-height: 0 !important;
    resize: none;
  }

  .sheet,
  .sheet textarea,
  .sheet input,
  .type-option {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

@page {
  size: A4;
  margin: 12mm;
}
