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

:root {
  --bg-primary: #f8f9fa;
  --bg-secondary: #fff;
  --text-primary: #333;
  --text-secondary: #555;
  --text-muted: #666;
  --text-light: #999;
  --accent-color: #3498db;
  --accent-hover: #2980b9;
  --header-bg: #fff;
  --card-shadow: rgba(0, 0, 0, 0.08);
  --card-shadow-hover: rgba(0, 0, 0, 0.12);
  --footer-bg: #2c3e50;
  --category-bg: #e8f4fd;
}

[data-theme="dark"] {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --text-primary: #eee;
  --text-secondary: #ccc;
  --text-muted: #aaa;
  --text-light: #888;
  --accent-color: #5dade2;
  --accent-hover: #3498db;
  --header-bg: #16213e;
  --card-shadow: rgba(0, 0, 0, 0.3);
  --card-shadow-hover: rgba(0, 0, 0, 0.4);
  --footer-bg: #0f0f1a;
  --category-bg: #1a3a5c;
}

body {
  font-family: 'Noto Sans KR', sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: background-color 0.3s, color 0.3s;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  background-color: var(--header-bg);
  box-shadow: 0 2px 10px var(--card-shadow);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 0.3s;
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 30px;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  transition: color 0.3s;
}

.nav-links a:hover {
  color: var(--accent-color);
}

/* Theme Toggle Button */
.theme-toggle {
  background: none;
  border: 2px solid var(--text-muted);
  border-radius: 50px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s;
}

.theme-toggle:hover {
  border-color: var(--accent-color);
}

.icon-moon {
  display: none;
}

[data-theme="dark"] .icon-sun {
  display: none;
}

[data-theme="dark"] .icon-moon {
  display: inline;
}

/* Date Time Bar */
.date-time-bar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--card-shadow);
  padding: 12px 0;
  position: sticky;
  top: 68px;
  z-index: 90;
}

.current-datetime {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
}

/* Ticker Wrapper */
.ticker-wrapper {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--card-shadow);
  position: sticky;
  top: 108px;
  z-index: 89;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 60px 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  margin: 30px 0;
  color: #fff;
}

.hero-gradient {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  border-radius: 0;
  margin: 0;
  padding: 80px 0;
  position: relative;
  overflow: hidden;
}

.hero-gradient::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.5;
}

.hero-gradient .container {
  position: relative;
  z-index: 1;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 15px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.hero p {
  font-size: 1.1rem;
  opacity: 0.95;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
}

/* Section Spacing */
.section-spacing {
  padding: 60px 0;
}

/* Category Grid */
.category-overview {
  padding: 40px 0;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 25px;
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 30px 25px;
  background: var(--bg-secondary);
  border-radius: 16px;
  text-decoration: none;
  box-shadow: 0 4px 20px var(--card-shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.category-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 35px var(--card-shadow-hover);
}

.category-icon {
  font-size: 2.5rem;
  margin-bottom: 15px;
  display: block;
}

.category-card h3 {
  color: var(--text-primary);
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.category-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Market Chart Section */
.market-chart-section {
  padding: 20px 0 40px 0;
  border-top: none;
}

.chart-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.chart-btn {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 2px solid var(--text-light);
  padding: 12px 30px;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.chart-btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  transform: translateY(-2px);
}

.chart-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-color: transparent;
}

.chart-container {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 4px 20px var(--card-shadow);
  min-height: 700px;
  height: 700px;
  overflow: hidden;
  position: relative;
}

/* Posts Grid */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 25px;
}

.post-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 15px var(--card-shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 30px var(--card-shadow-hover);
}

.post-card-content {
  padding: 25px;
}

/* Posts Section */
.section-title {
  font-size: 1.8rem;
  margin-bottom: 30px;
  color: var(--text-primary);
}

.posts {
  padding: 40px 0;
}

.no-posts {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size: 1.1rem;
}

.post-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 25px;
  box-shadow: 0 4px 15px var(--card-shadow);
  transition: box-shadow 0.3s, background-color 0.3s;
}

.post-card:hover {
  box-shadow: 0 8px 25px var(--card-shadow-hover);
}

.post-main {
  display: flex;
}

.post-image {
  flex: 0 0 280px;
}

.post-image img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.post-content {
  padding: 25px;
  display: flex;
  flex-direction: column;
}

.post-category {
  display: inline-block;
  background: var(--category-bg);
  color: var(--accent-color);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 10px;
  width: fit-content;
  transition: background-color 0.3s;
}

.post-title {
  font-size: 1.3rem;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.post-excerpt {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 15px;
  flex-grow: 1;
}

.post-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.post-date {
  color: var(--text-light);
  font-size: 0.85rem;
}

.read-more {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s;
}

.read-more:hover {
  color: var(--accent-hover);
}

/* Footer */
.footer {
  background: var(--footer-bg);
  color: #fff;
  text-align: center;
  padding: 30px 0;
  margin-top: 50px;
  transition: background-color 0.3s;
}

/* Admin Button */
.admin-btn {
  background: var(--accent-color);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  margin-left: 10px;
  transition: background 0.3s;
}

.admin-btn:hover {
  background: var(--accent-hover);
}

.admin-btn.logged-in {
  background: #27ae60;
}

.admin-btn.logged-in:hover {
  background: #219a52;
}

/* Write Button (Floating) */
.write-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  padding: 15px 25px;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  transition: transform 0.3s, box-shadow 0.3s;
  z-index: 99;
}

.write-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.write-btn.hidden {
  display: none;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  padding: 30px;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-content.modal-large {
  max-width: 600px;
}

.modal-content.modal-xlarge {
  max-width: 800px;
  max-height: 85vh;
  overflow-y: auto;
}

/* Post Modal Styles */
.post-modal-header {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--accent-color);
}

.post-modal-category {
  display: inline-block;
  background: var(--category-bg);
  color: var(--accent-color);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 10px;
}

.post-modal-title {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.post-modal-date {
  color: var(--text-light);
  font-size: 0.85rem;
}

.post-modal-body {
  color: var(--text-secondary);
  line-height: 1.8;
}

.post-modal-body h4 {
  color: var(--text-primary);
  font-size: 1.2rem;
  margin: 25px 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent-color);
}

.post-modal-body h4:first-child {
  margin-top: 0;
}

.post-modal-body p {
  margin-bottom: 12px;
}

.post-modal-body ul,
.post-modal-body ol {
  margin: 12px 0;
  padding-left: 25px;
}

.post-modal-body li {
  margin-bottom: 8px;
  line-height: 1.7;
}

.post-modal-body strong {
  color: var(--text-primary);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.3s;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-content h2 {
  margin-bottom: 20px;
  color: var(--text-primary);
}

/* Form Styles */
.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--text-light);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-color);
}

#adminPassword {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--text-light);
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 15px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent-color);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.error-msg {
  color: #e74c3c;
  margin-top: 10px;
  font-size: 0.9rem;
}

/* Comment Toggle Button */
.comment-toggle-btn {
  background: var(--category-bg);
  color: var(--accent-color);
  border: none;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
}

.comment-toggle-btn:hover {
  background: var(--accent-color);
  color: #fff;
}

.comment-count {
  margin-left: 4px;
}

/* Comment Section */
.comment-section {
  border-top: 1px solid var(--text-light);
  padding: 20px;
  background: var(--bg-primary);
}

.comment-section.hidden {
  display: none;
}

.comment-list {
  margin-bottom: 20px;
}

.comment-item {
  background: var(--bg-secondary);
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 10px;
}

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

.comment-author {
  font-weight: 600;
  color: var(--text-primary);
}

.comment-date {
  font-size: 0.8rem;
  color: var(--text-light);
}

.comment-body {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.comment-delete {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 0.8rem;
  margin-left: 10px;
  transition: color 0.3s;
}

.comment-delete:hover {
  color: #e74c3c;
}

/* Comment Form */
.comment-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comment-form-row {
  display: flex;
  gap: 10px;
}

.comment-form-row input {
  flex: 1;
  padding: 10px;
  border: 2px solid var(--text-light);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: border-color 0.3s;
}

.comment-form-row input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.comment-text {
  padding: 10px;
  border: 2px solid var(--text-light);
  border-radius: 6px;
  font-size: 0.9rem;
  resize: vertical;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color 0.3s;
}

.comment-text:focus {
  outline: none;
  border-color: var(--accent-color);
}

.btn-comment {
  align-self: flex-end;
  padding: 10px 20px;
  background: var(--accent-color);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.3s;
}

.btn-comment:hover {
  background: var(--accent-hover);
}

/* Read More Button */
.read-more-btn {
  background: none;
  border: none;
  color: var(--accent-color);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  margin-bottom: 15px;
  text-decoration: underline;
  transition: color 0.3s;
}

.read-more-btn:hover {
  color: var(--accent-hover);
}

/* Full Content Styles */
.post-full-content {
  border-top: 1px solid var(--text-light);
  padding: 25px;
  background: var(--bg-primary);
}

.post-full-content.hidden {
  display: none;
}

.full-content-inner {
  max-width: 800px;
}

.full-content-inner h4 {
  color: var(--text-primary);
  font-size: 1.2rem;
  margin: 25px 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent-color);
}

.full-content-inner h4:first-child {
  margin-top: 0;
}

.full-content-inner p {
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.8;
}

.full-content-inner ul,
.full-content-inner ol {
  color: var(--text-secondary);
  margin: 12px 0;
  padding-left: 25px;
}

.full-content-inner li {
  margin-bottom: 8px;
  line-height: 1.7;
}

.full-content-inner strong {
  color: var(--text-primary);
}

/* Info Table */
.info-table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
  background: var(--bg-secondary);
  border-radius: 8px;
  overflow: hidden;
}

.info-table th,
.info-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid var(--text-light);
}

.info-table th {
  background: var(--accent-color);
  color: #fff;
  font-weight: 600;
}

.info-table tr:last-child td {
  border-bottom: none;
}

.info-table tr:hover td {
  background: var(--category-bg);
}

/* Highlight Box */
.highlight-box {
  background: var(--category-bg);
  padding: 20px;
  border-radius: 8px;
  margin: 15px 0;
  border-left: 4px solid var(--accent-color);
}

.highlight-box p {
  margin-bottom: 10px;
}

.highlight-box ul {
  margin: 8px 0;
}

/* Tip Box */
.tip-box {
  background: linear-gradient(135deg, #667eea22 0%, #764ba222 100%);
  padding: 15px 20px;
  border-radius: 8px;
  margin-top: 20px;
  border: 1px solid #667eea44;
  color: var(--text-primary);
}

.hidden {
  display: none;
}

/* Responsive */
@media (max-width: 768px) {
  .nav {
    flex-direction: column;
    gap: 15px;
  }

  .nav-links {
    gap: 20px;
  }

  .post-main {
    flex-direction: column;
  }

  .post-image {
    flex: none;
  }

  .hero h1 {
    font-size: 1.8rem;
  }

  .comment-form-row {
    flex-direction: column;
  }

  .chart-buttons {
    gap: 10px;
  }

  .chart-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }

  .chart-container {
    min-height: 450px;
    height: 450px;
    padding: 0;
  }

  .market-chart-section {
    padding: 15px 0 30px 0;
  }
}
