/* ── Reset & Base ────────────────────────────────────────────────────────── */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #fff0f5 0%, #fce4ec 30%, #f3e5f5 70%, #ede7f6 100%);
  background-attachment: fixed;
  color: #4a4a6a;
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: #e91e8c;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ── Utility ────────────────────────────────────────────────────────────── */

.hidden {
  display: none !important;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.header {
  background: linear-gradient(90deg, #f8bbd0, #e1bee7);
  border-bottom: 2px solid #f48fb1;
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(233, 30, 140, 0.12);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: #6a1b5e;
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 0.85rem;
  color: #8e24aa;
  font-weight: 400;
}

/* ── Input Section ───────────────────────────────────────────────────────── */

.input-section {
  max-width: 720px;
  margin: 2rem auto 1.5rem;
  padding: 0 1.5rem;
}

.fetch-form {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.url-input {
  flex: 1;
  padding: 0.85rem 1.2rem;
  font-size: 1rem;
  background-color: #faf5ff;
  border: 2px solid #f3d4e8;
  border-radius: 12px;
  color: #4a4a6a;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.url-input::placeholder {
  color: #c9a8c5;
  font-style: italic;
}

.url-input:focus {
  border-color: #e91e8c;
  box-shadow: 0 0 0 3px rgba(233, 30, 140, 0.15);
}

.fetch-btn {
  padding: 0.85rem 1.8rem;
  font-size: 1rem;
  font-weight: 600;
  background: linear-gradient(135deg, #e91e8c, #ab47bc);
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(233, 30, 140, 0.25);
}

.fetch-btn:hover {
  background: linear-gradient(135deg, #d81b7a, #9c27b0);
  box-shadow: 0 4px 14px rgba(233, 30, 140, 0.35);
  transform: translateY(-1px);
}

.fetch-btn:active {
  transform: scale(0.97);
}

.fetch-btn:disabled {
  background: #c9a8c5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Loading ─────────────────────────────────────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #f3d4e8;
  border-top-color: #e91e8c;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: #ab47bc;
  font-size: 0.95rem;
}

/* ── Error ───────────────────────────────────────────────────────────────── */

.error-message {
  max-width: 720px;
  margin: 0 auto 1rem;
  padding: 0.85rem 1.2rem;
  background-color: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 12px;
  color: #d32f2f;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ── Delete Buttons ──────────────────────────────────────────────────────── */

.delete-all-btn {
  margin-left: auto;
  padding: 0.4rem 0.8rem;
  font-size: 0.78rem;
  background: rgba(233, 30, 140, 0.08);
  border: 1px solid rgba(233, 30, 140, 0.2);
  border-radius: 8px;
  color: #d32f2f;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
  font-weight: 500;
  white-space: nowrap;
}

.delete-all-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
}

.card-delete-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(233, 30, 140, 0.06);
  border: 1px solid rgba(233, 30, 140, 0.15);
  border-radius: 50%;
  color: #c9a8c5;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}

.card-delete-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #d32f2f;
}

.article-card {
  position: relative;
}

.card-error-url {
  display: block;
  font-size: 0.75rem;
  color: #9c6b9e;
  word-break: break-all;
  margin-top: 0.2rem;
}

.reading-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.reading-toolbar .back-btn {
  margin-bottom: 0;
}

.delete-btn {
  margin-left: auto;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  background: rgba(233, 30, 140, 0.06);
  border: 1px solid rgba(233, 30, 140, 0.15);
  border-radius: 8px;
  color: #9c6b9e;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.delete-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.25);
  color: #d32f2f;
}

/* ── Empty State ─────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
}

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  filter: drop-shadow(0 2px 8px rgba(233, 30, 140, 0.15));
}

.empty-state h2 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #7b1fa2;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: #9c6b9e;
  font-size: 0.95rem;
}

/* ── Article List ────────────────────────────────────────────────────────── */

.article-list {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.article-card {
  background-color: #faf5ff;
  border: 1.5px solid #f3d4e8;
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(233, 30, 140, 0.06);
}

.article-card:hover {
  background-color: #fff5fc;
  border-color: #e91e8c;
  box-shadow: 0 4px 16px rgba(233, 30, 140, 0.12);
  transform: translateY(-1px);
}

.article-card:active {
  transform: scale(0.995);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #4a148c;
  margin-bottom: 0.4rem;
  line-height: 1.4;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.8rem;
  color: #9c6b9e;
  margin-bottom: 0.5rem;
}

.card-site {
  color: #e91e8c;
  font-weight: 500;
}

.card-author {
  color: #ab47bc;
}

.card-date {
  color: #c9a8c5;
}

.card-excerpt {
  font-size: 0.88rem;
  color: #7b5b7e;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-error {
  margin-top: 0.5rem;
  padding: 0.4rem 0.7rem;
  background-color: rgba(239, 68, 68, 0.08);
  border-radius: 8px;
  font-size: 0.8rem;
  color: #d32f2f;
}

/* ── Reading View ────────────────────────────────────────────────────────── */

.reading-view {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.back-btn {
  display: inline-block;
  padding: 0.5rem 0;
  margin-bottom: 1.5rem;
  background: none;
  border: none;
  color: #e91e8c;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
}

.back-btn:hover {
  color: #f06292;
}

.article-content {
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.reading-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1.5px solid #f3d4e8;
}

.reading-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  color: #4a148c;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.reading-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-size: 0.88rem;
  color: #9c6b9e;
  margin-bottom: 1rem;
}

.reading-author {
  color: #ab47bc;
}

.reading-site {
  color: #e91e8c;
}

.reading-date,
.reading-words {
  color: #c9a8c5;
}

.reading-image {
  max-width: 100%;
  height: auto;
  border-radius: 14px;
  margin: 1.5rem 0;
  box-shadow: 0 4px 20px rgba(233, 30, 140, 0.12);
}

.reading-source {
  font-size: 0.8rem;
  color: #c9a8c5;
  font-style: italic;
  margin-top: 0.5rem;
}

/* ── Reading Body (article content from Readability) ────────────────────── */

.reading-body {
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 1.15rem;
  line-height: 1.8;
  color: #4a4a6a;
}

.reading-body p {
  margin-bottom: 1.25rem;
}

.reading-body h1,
.reading-body h2,
.reading-body h3,
.reading-body h4 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 700;
  color: #4a148c;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.reading-body h1 { font-size: 1.75rem; }
.reading-body h2 { font-size: 1.5rem; }
.reading-body h3 { font-size: 1.25rem; }
.reading-body h4 { font-size: 1.1rem; }

.reading-body img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 1.5rem 0;
  box-shadow: 0 2px 12px rgba(233, 30, 140, 0.08);
}

.reading-body blockquote {
  border-left: 3px solid #e91e8c;
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: #7b5b7e;
  font-style: italic;
}

.reading-body ul,
.reading-body ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.reading-body li {
  margin-bottom: 0.4rem;
}

.reading-body a {
  color: #e91e8c;
  text-decoration: underline;
}

.reading-body a:hover {
  color: #f06292;
}

.reading-body pre {
  background-color: #faf5ff;
  border: 1.5px solid #f3d4e8;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  margin: 1.5rem 0;
}

.reading-body code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background-color: rgba(233, 30, 140, 0.06);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.reading-body pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

.reading-body hr {
  border: none;
  border-top: 1px solid #f3d4e8;
  margin: 2rem 0;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .header {
    padding: 0.75rem 1rem;
  }

  .logo {
    font-size: 1.3rem;
  }

  .input-section {
    margin-top: 1.5rem;
    padding: 0 1rem;
  }

  .fetch-form {
    flex-direction: column;
  }

  .fetch-btn {
    width: 100%;
    padding: 0.75rem;
  }

  .reading-title {
    font-size: 1.5rem;
  }

  .reading-body {
    font-size: 1.05rem;
  }

  .article-list {
    padding: 0 1rem 2rem;
  }

  .reading-view {
    padding: 0 1rem 3rem;
  }

  .article-card {
    padding: 1rem 1.2rem;
  }
}

@media (max-width: 400px) {
  html {
    font-size: 15px;
  }
}
