.app-library[hidden] {
  display: none !important;
}

.app-library {
  min-height: 100%;
  padding: 0 0 48px;
  display: flex;
  flex-direction: column;
}

.library-catalog[hidden],
.library-browse[hidden] {
  display: none !important;
}

.library-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px 16px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.library-filters {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 3%, transparent);
}

.library-filter {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.library-filter.is-active {
  background: var(--surface, #fff);
  color: var(--accent, #6b4eff);
  font-weight: 600;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 8%, transparent);
}

.library-search {
  flex: 1 1 220px;
  max-width: 320px;
}

.library-search input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: var(--surface, #fff);
  color: var(--ink);
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 14px;
  padding: 0 24px 24px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.library-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: var(--surface, #fff);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  min-height: 140px;
}

.library-card:hover {
  border-color: color-mix(in srgb, var(--accent, #6b4eff) 40%, var(--line));
  box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 6%, transparent);
}

.library-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.library-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  color: var(--muted);
}

.library-badge[data-kind="agent"] {
  background: color-mix(in srgb, #df2855 12%, transparent);
  color: #df2855;
}

.library-badge[data-kind="workflow"] {
  background: color-mix(in srgb, #2673d9 12%, transparent);
  color: #2673d9;
}

.library-card h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.library-card-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.library-empty {
  grid-column: 1 / -1;
  padding: 32px 8px;
  color: var(--muted);
}

.library-browse {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 24px 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.library-browse-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.library-browse-header h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.library-browse-header .lede {
  margin: 4px 0 0;
}

.library-with-files {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.library-split {
  flex: 1 1 auto;
  min-height: 420px;
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface, #fff);
}

.library-sessions-pane,
.library-files-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.library-sessions-pane {
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--ink) 2%, transparent);
}

.library-sessions-pane h3,
.library-files-header h3 {
  margin: 0;
  padding: 14px 14px 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.library-sessions {
  flex: 1;
  overflow: auto;
  padding: 0 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.library-session {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.library-session:hover {
  background: color-mix(in srgb, var(--ink) 4%, transparent);
}

.library-session.is-active {
  border-color: var(--line);
  background: var(--surface, #fff);
}

.library-session strong {
  font-size: 13px;
  line-height: 1.35;
}

.library-session small {
  color: var(--muted);
  font-size: 11px;
}

.library-files-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-right: 14px;
}

.library-files-header .lede {
  margin: 0;
  font-size: 12px;
}

.library-files-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  border-top: 1px solid var(--line);
}

.library-files {
  overflow: auto;
  border-right: 1px solid var(--line);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.library-file {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.library-file:hover {
  background: color-mix(in srgb, var(--ink) 4%, transparent);
}

.library-file.is-active {
  border-color: var(--line);
  background: color-mix(in srgb, var(--accent, #6b4eff) 8%, transparent);
}

.library-file strong {
  font-size: 13px;
  word-break: break-word;
}

.library-file small {
  color: var(--muted);
  font-size: 11px;
}

.library-preview {
  overflow: auto;
  padding: 14px;
  min-height: 0;
}

.library-preview-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.library-preview-actions strong {
  font-size: 13px;
  word-break: break-word;
}

.library-preview-body {
  font-size: 14px;
  line-height: 1.55;
}

.library-preview-body pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12px;
}

.library-preview img,
.library-preview iframe {
  max-width: 100%;
  border: 0;
  border-radius: 10px;
}

.library-preview iframe {
  width: 100%;
  min-height: 420px;
  background: #fff;
}

@media (max-width: 900px) {
  .library-split {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .library-sessions-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 220px;
  }

  .library-files-body {
    grid-template-columns: 1fr;
  }

  .library-files {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 200px;
  }
}
