/* ========== Reset & Base ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  background: #0c1222;
  color: #c9d1d9;
  min-height: 100vh;
}

/* Background gradient */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(100, 50, 200, 0.12) 0%, transparent 100%),
    radial-gradient(ellipse 60% 40% at 85% 10%, rgba(50, 80, 200, 0.1) 0%, transparent 100%),
    radial-gradient(ellipse 80% 60% at 50% 120%, rgba(30, 50, 100, 0.08) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* ========== Header ========== */
header {
  position: relative;
  z-index: 1;
  padding: 36px 40px 28px;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
}

.header-left {
  flex-shrink: 0;
}

header h1 {
  font-size: 2.6rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.1em;
}

.subtitle {
  margin-top: 6px;
  font-size: 0.9rem;
  color: #6e7681;
  line-height: 1.5;
}

.profile-link {
  margin-top: 6px;
}

.profile-link a {
  font-size: 0.75rem;
  color: #6e7681;
  text-decoration: none;
  transition: color 0.2s;
}

.profile-link a:hover {
  color: #f59e0b;
  text-decoration: underline;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 16px;
}

/* ========== Header Actions ========== */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.usage-btn {
  display: inline-block;
  padding: 9px 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  color: #c9d1d9;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s;
}

.usage-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ========== Search Bar ========== */
.search-wrapper {
  position: relative;
  width: 260px;
}

.search-wrapper .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #6e7681;
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  color: #e8e8ed;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

#search-input::placeholder {
  color: #484f58;
}

#search-input:focus {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
}

/* ========== Category Nav ========== */
.category-nav {
  display: flex;
  gap: 8px;
}

.category-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  width: 76px;
}

.category-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.14);
  transform: translateY(-2px);
}

.category-btn.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.category-gem {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.category-btn span {
  font-size: 0.58rem;
  color: #6e7681;
  text-align: center;
  line-height: 1.3;
  transition: color 0.2s;
}

.category-btn:hover span,
.category-btn.active span {
  color: #c9d1d9;
}

/* ========== Main Content ========== */
main {
  padding: 8px 40px 80px;
  position: relative;
  z-index: 1;
}

.gem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.no-results {
  text-align: center;
  color: #484f58;
  font-size: 0.95rem;
  padding: 60px 0;
}

/* ========== Gem Card ========== */
.gem-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 20px 20px 18px;
  background: url("images/bg.jpg") center / cover no-repeat;
  border: 1px solid rgba(200, 210, 230, 0.5);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.25s, transform 0.15s;
  text-align: left;
  position: relative;
}

.gem-btn:hover {
  background: var(--cat-hover-bg, rgba(255, 255, 255, 0.07));
  border-color: var(--cat-hover-border, rgba(255, 255, 255, 0.15));
  box-shadow: 0 8px 32px var(--cat-hover-shadow, rgba(0, 0, 0, 0.25));
  transform: translateY(-3px);
}

.gem-btn:hover .gem-btn-title {
  color: var(--cat-color, #1a2744);
}

.gem-btn-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}

.gem-btn-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding-right: 32px;
}

.gem-btn-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a2744;
  line-height: 1.4;
}

.gem-btn-description {
  font-size: 0.8rem;
  color: #4a5568;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ========== Modal Overlay ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay[hidden] {
  display: none;
}

/* ========== Modal ========== */
.modal {
  background: #161b22;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  width: 100%;
  max-width: 580px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 36px 32px 32px;
  position: relative;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
  animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: #484f58;
  line-height: 1;
  transition: color 0.15s;
}

.modal-close:hover {
  color: #c9d1d9;
}

.modal-category {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #e8e8ed;
  margin-bottom: 12px;
}

.modal-description {
  font-size: 0.9rem;
  line-height: 1.75;
  color: #8b949e;
  margin-bottom: 20px;
}

/* ========== Attachments ========== */
.modal-attachments {
  margin-bottom: 20px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}

.attachments-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #6e7681;
  margin-bottom: 8px;
}

.attachments-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.attachments-list li {
  font-size: 0.85rem;
  color: #c9d1d9;
  padding-left: 18px;
  position: relative;
  line-height: 1.5;
}

.attachments-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 8px;
  height: 8px;
  background: var(--bullet-color, #f59e0b);
  border-radius: 2px;
}

.attachments-none {
  font-size: 0.85rem;
  color: #484f58;
  margin: 0;
}

/* ========== Modal Actions ========== */
.modal-actions {
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
  flex: 1;
}

.btn:hover {
  opacity: 0.85;
}

.btn-primary {
  color: #fff;
}

.btn-secondary {
  border: 1px solid;
}

/* ========== Prompt Area ========== */
.prompt-area {
  margin-top: 20px;
  animation: slideDown 0.25s ease-out;
}

.prompt-area[hidden] {
  display: none;
}

@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to   { opacity: 1; max-height: 600px; }
}

.prompt-wrapper {
  position: relative;
}

.prompt-area pre {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 20px;
  padding-top: 44px;
  font-size: 0.82rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: #8b949e;
  max-height: 300px;
  overflow-y: auto;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #f59e0b;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  z-index: 1;
}

.copy-btn:hover {
  opacity: 0.85;
}

.copy-btn.copied {
  background: #16a34a;
}

/* ========== Responsive ========== */
@media (max-width: 1024px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-right {
    align-items: flex-start;
    width: 100%;
  }

  .search-wrapper {
    width: 100%;
    max-width: 400px;
  }

  .category-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    width: 100%;
  }
}

@media (max-width: 480px) {
  header {
    padding: 24px 16px 20px;
  }

  header h1 {
    font-size: 2rem;
  }

  main {
    padding: 8px 16px 60px;
  }

  .gem-grid {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: 28px 20px 24px;
  }

  .modal-actions {
    flex-direction: column;
  }

  .category-btn {
    width: 64px;
    padding: 8px 6px 6px;
  }

  .category-gem {
    width: 36px;
    height: 36px;
  }
}
