* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: #1a1a1a;
  background: #fafafa;
}

#app {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 1.5rem;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

header h1 a {
  color: inherit;
  text-decoration: none;
}

#search-input {
  padding: 0.35rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.875rem;
  width: 220px;
}

main {
  padding-bottom: 3rem;
}

/* Wiki list */
.wiki-list {
  list-style: none;
}

.wiki-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid #eee;
}

.wiki-list li:last-child {
  border-bottom: none;
}

.wiki-list a {
  font-size: 1.1rem;
  color: #0066cc;
  text-decoration: none;
}

.wiki-list a:hover {
  text-decoration: underline;
}

.wiki-list .description {
  color: #666;
  font-size: 0.875rem;
  margin-top: 0.15rem;
}

/* Page list */
.page-list {
  list-style: none;
}

.page-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
}

.page-list li:last-child {
  border-bottom: none;
}

.page-list a {
  color: #0066cc;
  text-decoration: none;
}

.page-list a:hover {
  text-decoration: underline;
}

.page-list .meta {
  color: #888;
  font-size: 0.8rem;
  margin-left: 0.5rem;
}

.page-list .tags {
  display: inline;
}

.page-list .tag {
  background: #e8f0fe;
  color: #1a5fb4;
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-left: 0.25rem;
}

/* Breadcrumb */
.breadcrumb {
  font-size: 0.875rem;
  color: #666;
  margin-bottom: 1rem;
}

.breadcrumb a {
  color: #0066cc;
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb-aux {
  margin-left: 0.75rem;
  font-size: 0.8rem;
}

.home-hint {
  background: #fff8e1;
  border: 1px solid #f1d278;
  border-radius: 4px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #5a4400;
}

.home-hint a {
  color: #0066cc;
  text-decoration: none;
}

.home-hint a:hover {
  text-decoration: underline;
}

/* Page detail */
.page-header {
  margin-bottom: 1.5rem;
}

.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.page-header h2 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.btn-edit {
  background: none;
  border: 1px solid #ccc;
  color: #333;
  font-size: 0.8rem;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
}

.btn-edit:hover {
  background: #f0f0f0;
}

.page-list-actions {
  margin: 0 0 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-list-link {
  font-size: 0.875rem;
  color: #0066cc;
  text-decoration: none;
}

.btn-primary,
.btn-secondary {
  display: inline-block;
  font-size: 0.875rem;
  padding: 0.35rem 0.9rem;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  line-height: 1.4;
}

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

.btn-primary:hover {
  background: #0052a3;
}

.btn-primary:disabled {
  background: #88b8e6;
  border-color: #88b8e6;
  cursor: default;
}

.btn-secondary {
  background: #fff;
  color: #333;
  border-color: #ccc;
}

.btn-secondary:hover {
  background: #f5f5f5;
}

.btn-secondary:disabled {
  color: #999;
  cursor: default;
}

.page-editor {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.page-editor-title {
  font-size: 1.25rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
}

.page-editor-textarea {
  width: 100%;
  min-height: 24rem;
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
}

.page-editor-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-editor-status {
  margin-left: 0.5rem;
  font-size: 0.85rem;
  color: #b00;
}

.page-header .page-meta {
  color: #888;
  font-size: 0.8rem;
}

.page-header .tag {
  background: #e8f0fe;
  color: #1a5fb4;
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-right: 0.25rem;
}

.page-content {
  line-height: 1.7;
}

.page-content h1 { font-size: 1.4rem; margin: 1.5rem 0 0.75rem; }
.page-content h2 { font-size: 1.25rem; margin: 1.25rem 0 0.5rem; }
.page-content h3 { font-size: 1.1rem; margin: 1rem 0 0.5rem; }

.page-content p {
  margin-bottom: 0.75rem;
}

.page-content ul, .page-content ol {
  margin: 0 0 0.75rem 1.5rem;
}

.page-content code {
  background: #f0f0f0;
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  font-size: 0.9em;
}

.page-content pre {
  background: #f0f0f0;
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: 0.75rem;
}

.page-content pre code {
  background: none;
  padding: 0;
}

.page-content blockquote {
  border-left: 3px solid #ccc;
  padding-left: 1rem;
  color: #555;
  margin-bottom: 0.75rem;
}

.page-content a {
  color: #0066cc;
}

.page-content .broken-link {
  color: #cc0000;
  text-decoration: line-through;
}

.page-content table {
  border-collapse: collapse;
  margin-bottom: 0.75rem;
  width: 100%;
}

.page-content th, .page-content td {
  border: 1px solid #ddd;
  padding: 0.4rem 0.75rem;
  text-align: left;
}

.page-content th {
  background: #f5f5f5;
}

/* Attachments section */
.page-attachments {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

.page-attachments h3 {
  font-size: 0.9rem;
  color: #444;
  margin-bottom: 0.75rem;
}

.attachments-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}

.attachment {
  min-width: 0;
}

.attachment-image {
  max-width: 160px;
}

.attachment-thumb {
  max-width: 150px;
  max-height: 150px;
  display: block;
  border-radius: 4px;
  border: 1px solid #ddd;
  object-fit: cover;
}

.attachment-thumb:hover {
  border-color: #0066cc;
}

.attachment-name {
  font-size: 0.8rem;
  color: #444;
  word-break: break-word;
  margin-top: 0.25rem;
}

.attachment-desc {
  font-size: 0.75rem;
  color: #888;
  margin-top: 0.15rem;
}

.attachment-size {
  font-size: 0.75rem;
  color: #999;
  margin-top: 0.15rem;
}

.attachment-audio {
  max-width: 320px;
  width: 100%;
}

.attachment-audio-transcript {
  max-width: 100%;
}

.attachment-audio audio {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
}

.attachment-meta {
  font-size: 0.75rem;
  color: #999;
  margin-top: 0.2rem;
}

.meta-sep {
  color: #ccc;
}

.transcript-details {
  margin-top: 0.75rem;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  overflow: hidden;
}

.transcript-summary {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #444;
  cursor: pointer;
  background: #f7f7f7;
  user-select: none;
}

.transcript-summary:hover {
  background: #f0f0f0;
}

.transcript-body {
  padding: 0.75rem;
  max-height: 500px;
  overflow-y: auto;
  font-size: 0.82rem;
  line-height: 1.5;
}

.transcript-group {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.transcript-speaker {
  font-weight: 700;
  color: #0066cc;
  min-width: 80px;
  max-width: 120px;
  flex-shrink: 0;
  padding-top: 0.05rem;
  font-size: 0.8rem;
  word-break: break-word;
}

.transcript-segs {
  flex: 1;
  min-width: 0;
}

.transcript-segment {
  color: #333;
  cursor: pointer;
  border-radius: 3px;
  padding: 0.1rem 0.2rem;
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
}

.transcript-segment:hover {
  background: #e8f0fe;
}

.transcript-time {
  font-size: 0.7rem;
  color: #0066cc;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  min-width: 2.5rem;
}

.transcript-text {
  flex: 1;
}

.attachment-file .attachment-link {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  color: #0066cc;
  text-decoration: none;
  font-size: 0.875rem;
}

.attachment-file .attachment-link:hover {
  text-decoration: underline;
}

.attachment-file .attachment-size {
  margin-top: 0;
  font-size: 0.8rem;
  color: #888;
}

/* Links section */
.page-links {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
  font-size: 0.875rem;
  color: #666;
}

.page-links h3 {
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  color: #444;
}

.page-links ul {
  list-style: none;
  margin-bottom: 0.75rem;
}

.page-links a {
  color: #0066cc;
  text-decoration: none;
}

.page-links a:hover {
  text-decoration: underline;
}

.page-links .broken {
  color: #cc0000;
  text-decoration: line-through;
}

.page-links .link-wiki {
  color: #888;
  font-size: 0.85em;
}

/* Search results */
.search-results {
  list-style: none;
}

.search-results li {
  padding: 0.75rem 0;
  border-bottom: 1px solid #eee;
}

.search-results a {
  color: #0066cc;
  text-decoration: none;
  font-size: 1.05rem;
}

.search-results a:hover {
  text-decoration: underline;
}

.search-results .snippet {
  color: #555;
  font-size: 0.875rem;
  margin-top: 0.2rem;
}

.search-results mark {
  background: #fff3cd;
  padding: 0 0.1rem;
}

/* Empty / error states */
.empty {
  color: #888;
  font-style: italic;
  padding: 2rem 0;
}

.error {
  color: #cc0000;
  padding: 2rem 0;
}

/* Comments */
.page-comments {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

.page-comments h3 {
  font-size: 0.9rem;
  color: #444;
  margin-bottom: 0.75rem;
}

.comments-empty {
  color: #888;
  font-size: 0.875rem;
  font-style: italic;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.comment-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 0.6rem 0.85rem;
}

.comment-meta {
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 0.25rem;
}

.comment-body {
  font-size: 0.9rem;
  color: #1a1a1a;
  white-space: pre-wrap;
}

.comment-anchor {
  border-left: 3px solid #ddd;
  padding: 0.15rem 0.6rem;
  margin: 0.25rem 0 0.4rem;
  color: #555;
  font-size: 0.85rem;
  font-style: italic;
}

.comment-reply {
  margin-top: 0.5rem;
  padding-left: 0.75rem;
  border-left: 2px solid #e8f0fe;
}

.comment-selection-btn {
  background: #0066cc;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.comment-composer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6rem;
  z-index: 1000;
}

.comment-composer {
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  width: min(480px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.comment-composer-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.comment-composer-textarea {
  width: 100%;
  min-height: 6rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.comment-composer-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.comment-composer-status {
  font-size: 0.8rem;
  color: #b00;
}

/* Loading indicator for pagination */
.load-more {
  display: block;
  margin: 1rem auto;
  padding: 0.5rem 1.5rem;
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
}

.load-more:hover {
  background: #e5e5e5;
}
