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

:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --text-light: #666666;
  --border: #e5e5e5;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==================== Header ==================== */
header {
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
}

nav {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
}

.logo {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 2rem;
}

.nav-links a {
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
}

/* ==================== Main ==================== */
main {
  flex: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 2rem;
  width: 100%;
  min-width: 0;
}

/* ==================== Home Page ==================== */
.hero {
  text-align: center;
  padding: 5rem 0 3rem;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
}

.subtitle {
  color: var(--text-light);
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

/* ==================== Page Header ==================== */
.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 300;
}

.page-header p {
  color: var(--text-light);
  margin-top: 0.25rem;
}

/* ==================== Profile Detail ==================== */
.profile-detail {
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-light);
}

/* ==================== Section Title ==================== */
.section-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.profile-card .section-title {
  margin-bottom: 0.5rem;
}

/* ==================== Profile Card ==================== */
.profile-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.75rem 2rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 2rem;
  transition: all 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.profile-card:hover {
  border-color: #ccc;
  background: #fafafa;
}

.profile-avatar {
  font-size: 3rem;
  line-height: 1;
}

.profile-info {
  min-width: 0;
}

.profile-info h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  overflow-wrap: break-word;
}

.profile-edu {
  color: var(--text-light);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  overflow-wrap: break-word;
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
}

.profile-links + .profile-links {
  margin-top: 0.25rem;
}

.profile-links a {
  color: var(--text-light);
  font-size: 0.9rem;
  text-decoration: none;
  transition: color 0.2s;
}

.profile-links a:hover {
  color: var(--text);
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-top: 2rem;
}

.card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
}

.card:hover {
  background: #fafafa;
  border-color: #ccc;
}

.card h2 {
  font-size: 1.25rem;
  font-weight: 500;
}

.card-en {
  font-weight: 400;
  color: var(--text-light);
}

.card p {
  color: var(--text-light);
  margin-top: 0.5rem;
}

.card .arrow {
  display: inline-block;
  margin-top: 1.5rem;
  font-size: 1.2rem;
}

/* ==================== Page Header ==================== */
.page-header {
  margin-bottom: 2.5rem;
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 300;
}

.page-header p {
  color: var(--text-light);
  margin-top: 0.25rem;
  overflow-wrap: break-word;
}

/* ==================== Carousel (Thoughts) ==================== */
.carousel-wrapper {
  position: relative;
}

.carousel-track {
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.carousel-slides {
  display: flex;
  transition: transform 0.4s ease;
}

.carousel-slide {
  flex: 0 0 100%;
  padding: 3rem 2.5rem;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.carousel-time {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}

.carousel-content {
  font-size: 1.3rem;
  line-height: 1.8;
}

.carousel-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.carousel-arrow {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.carousel-arrow:hover {
  background: #f5f5f5;
  border-color: #999;
}

.carousel-dots {
  display: flex;
  gap: 0.5rem;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: background 0.2s;
  border: none;
}

.carousel-dot:focus {
  outline: 2px solid rgba(0,0,0,0.12);
  outline-offset: 2px;
}

.carousel-dot.active {
  background: var(--text);
}

/* ==================== Works Layout ==================== */
.works-layout {
  display: flex;
  gap: 2.5rem;
  min-height: 400px;
}

.works-sidebar {
  flex: 0 0 200px;
  border-right: 1px solid var(--border);
  padding-right: 1.5rem;
}

.works-nav-group {
  margin-bottom: 1.5rem;
}

.works-sidebar h3 {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

.article-list {
  list-style: none;
}

.article-list li {
  margin-bottom: 2px;
}

.article-list button.article-link {
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  font-size: 0.95rem;
  color: var(--text-light);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}

.article-list button.article-link:hover {
  background: #f5f5f5;
  color: var(--text);
}

.article-list button.article-link.active {
  background: #f0f0f0;
  color: var(--text);
  font-weight: 500;
}

.works-content {
  flex: 1;
  min-width: 0;
}

.content-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text-light);
}

.article-display {
  display: none;
}

.article-display.active {
  display: block;
}

.article-title {
  font-size: 1.75rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.article-meta {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 2rem;
}

.article-body {
  font-size: 1rem;
  line-height: 1.9;
  white-space: pre-wrap;
}

/* MathJax formula rendering in Works */
.article-body mjx-container[display="true"] {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.25rem;
}

/* Code block and inline code styles in Works */
.article-body pre,
.article-body pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", "Segoe UI Mono", "Droid Sans Mono", "Courier New", monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

.article-body pre {
  background: #f6f8fa;
  border: 1px solid #eaecef;
  padding: 1rem;
  border-radius: 8px;
  overflow: auto;
  white-space: pre;
  margin: 0 0 1rem 0;
}

.article-body pre code {
  display: block;
  padding: 0;
  background: transparent;
  border: none;
  white-space: inherit;
}

.article-body code {
  background: rgba(27,31,35,0.05);
  padding: 0.15em 0.35em;
  border-radius: 6px;
  font-size: 0.95em;
}

.article-body pre .line-number {
  user-select: none;
  opacity: 0.6;
  padding-right: 0.5rem;
}

/* ==================== Add Section ==================== */
.add-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.add-section h3 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: 1rem;
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

input[type="text"] {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}

textarea {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--text);
}

button[type="submit"] {
  align-self: flex-start;
  padding: 0.6rem 1.5rem;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

button[type="submit"]:hover {
  opacity: 0.85;
}

button[type="submit"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==================== States ==================== */
.loading,
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-light);
}

.empty-item {
  color: var(--text-light);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
}

.error-state {
  text-align: center;
  padding: 3rem;
  color: #c00;
}

/* ==================== Footer ==================== */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem;
  text-align: center;
  color: var(--text-light);
  font-size: 0.9rem;
}

/* ==================== Responsive ==================== */
@media (max-width: 700px) {
  .cards {
    grid-template-columns: 1fr;
  }

  nav {
    flex-direction: column;
    height: auto;
    padding: 1rem 0;
    gap: 1rem;
  }

  main {
    padding: 2rem 1.5rem;
  }

  .works-layout {
    flex-direction: column;
  }

  .works-sidebar {
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 1.5rem;
  }
}
