:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #edf2f8;
  --ink: #172033;
  --muted: #64748b;
  --soft: #e7edf6;
  --surface: #f8fafc;
  --surface-tint: #f1f5f9;
  --line: #d4deeb;
  --line-strong: #aebfd6;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #dbeafe;
  --accent: #7c3aed;
  --success: #16a34a;
  --warning: #ca8a04;
  --danger: #dc2626;
  --shadow: 0 18px 45px #1e3a8a12;
  --shadow-soft: 0 10px 28px #1e3a8a0e;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #edf2f8;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  background:
    radial-gradient(circle at top left, #c7d9f4 0, transparent 32rem),
    radial-gradient(circle at top right, #ddd2f0 0, transparent 28rem),
    linear-gradient(180deg, #f3f6fa 0%, #edf2f8 46%, #e8eef6 100%);
}

.page {
  width: min(100%, 820px);
  margin: 0 auto;
  padding: 44px 20px;
}

.search-panel {
  padding: 0;
}

.top-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 20px;
}

.login-top-bar {
  justify-content: center;
}

h1 {
  margin: 0;
  color: var(--primary-dark);
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.logo-button {
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 44px;
}

.auth-panel button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 15px;
  color: #334155;
  background: #f8fafce0;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.sign-in-panel {
  max-width: 390px;
  margin: 42px auto 0;
  padding: 26px;
  border: 1px solid #f8fafc;
  border-radius: 28px;
  background: #f8fafce6;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 22px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--soft);
}

.auth-tabs button {
  min-height: 40px;
  border: 0;
  border-radius: 13px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.auth-tabs button.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 10px 24px #2563eb30;
}

.sign-in-form {
  display: grid;
  gap: 7px;
}

.sign-in-form label {
  color: #334155;
  font-weight: 700;
}

.sign-in-form label:not(:first-child) {
  margin-top: 8px;
}

.sign-in-form input,
.sign-in-form button {
  min-height: 44px;
  border-radius: 14px;
}

.sign-in-form button {
  margin-top: 18px;
  border: 1px solid var(--primary);
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 12px 28px #2563eb2e;
  cursor: pointer;
}

.google-signin-button {
  width: 100%;
  height: 40px;
  margin-top: 22px;
  border-radius: 12px;
}

.search-form {
  display: flex;
  gap: 10px;
  padding: 0;
}

input,
button,
textarea {
  font: inherit;
}

button,
input,
textarea,
.home-card,
.meaning-card,
.bookmark-inline-tag,
.bookmark-tag-input-tag {
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, color 0.18s ease,
    transform 0.18s ease;
}

input,
.search-form button {
  min-height: 50px;
  border-radius: 16px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  padding: 0 16px;
  color: var(--ink);
  background: var(--surface-tint);
}

.search-form input {
  background: #ffffff;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px #2563eb1f;
  outline: 0;
}

.search-form button {
  border: 1px solid var(--primary);
  padding: 0 22px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 10px 24px #2563eb2b;
  cursor: pointer;
}

.auth-panel button:hover:not(:disabled),
.top-back-button:hover:not(:disabled),
.top-save-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  color: var(--primary-dark);
  background: #ffffff;
  box-shadow: 0 12px 30px #1e3a8a18;
  transform: translateY(-1px);
}

.search-form button:hover:not(:disabled),
.sign-in-form button:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  box-shadow: 0 16px 30px #2563eb36;
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.status-row {
  position: relative;
  min-height: 42px;
  margin: 22px 0 0;
}

.status {
  min-height: 24px;
  margin: 0;
  padding-top: 8px;
  color: var(--muted);
  text-align: center;
}

.page-header-status {
  padding: 12px 128px 0;
  color: #334155;
  font-size: 1.08rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.status.error {
  color: var(--danger);
}

.results {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.empty-message {
  margin: 0;
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: 20px;
  color: var(--muted);
  text-align: center;
  background: #f8fafcb3;
}

.load-more-row {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.load-more-button {
  width: 100%;
  min-height: 44px;
  border: 1px solid #111827;
  border-radius: 14px;
  padding: 0 22px;
  color: #ffffff;
  background: linear-gradient(135deg, #1f2937, #111827);
  box-shadow: 0 10px 24px #11182730;
  cursor: pointer;
}

.load-more-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #374151, #1f2937);
  box-shadow: 0 16px 30px #1118273a;
  transform: translateY(-1px);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 26px;
}

.home-card {
  min-height: 152px;
  overflow: hidden;
  border: 1px solid #f8fafc;
  border-radius: 26px;
  color: #ffffff;
  background-color: var(--surface);
  background-position: center;
  background-size: cover;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.words-card {
  background-image: linear-gradient(145deg, #1d4ed8d9, #0f172aa6), url("image/words.png");
}

.examples-card {
  background-image: linear-gradient(145deg, #7c3aedd9, #0f172aa6), url("image/examples.png");
}

.notes-card {
  background-image: linear-gradient(145deg, #059669d9, #0f172aa6), url("image/notes.png");
}

.home-card:hover {
  border-color: #ffffff;
  box-shadow: 0 20px 45px #1e3a8a24;
  transform: translateY(-3px);
}

.home-card h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  text-shadow: 0 2px 10px #02061780;
}

.meaning-card {
  width: 100%;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--ink);
  text-align: left;
  background: #f8fafce6;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.meaning-card:hover {
  border-color: var(--line-strong);
  background: #ffffff;
  box-shadow: 0 16px 34px #1e3a8a18;
  transform: translateY(-2px);
}

.meaning-card h2 {
  margin: 0 0 8px;
  color: #0f172a;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
}

.example-card em,
.detail-card em,
.meaning-card em {
  color: #6d28d9;
  font-style: normal;
  font-weight: 700;
}

.example-card em,
.meaning-card em {
  border-radius: 5px;
  padding: 0 4px;
  background: #ede9fe;
}

.meaning-card p {
  margin: 0;
  color: #475569;
  line-height: 1.5;
}

.replacements-area {
  display: flex;
  height: 24px;
  align-items: center;
  justify-content: flex-start;
  margin-top: 14px;
}

.note-definition-area {
  margin-top: 9px;
}

.replacements-button {
  border: 0;
  border-radius: 999px;
  padding: 4px 10px;
  color: #1f2937;
  font: inherit;
  font-size: 0.92rem;
  background: #e5e7eb;
  cursor: pointer;
}

.replacements-button:hover {
  color: #020617;
  background: #d1d5db;
}

.replacements-text {
  overflow: hidden;
  color: #475569;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-panel {
  display: grid;
  gap: 16px;
}

.detail-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #f8fafce6;
  box-shadow: var(--shadow-soft);
}

.detail-header {
  padding: 20px;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
}

.detail-card h2 {
  margin: 0 0 8px;
  color: #0f172a;
  letter-spacing: -0.03em;
}

.bookmark-inline-tag {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  margin-left: 8px;
  border: 0;
  border-radius: 999px;
  padding: 3px 8px;
  color: #475569;
  font-size: 0.78rem;
  line-height: 1.2;
  vertical-align: middle;
  background: #e5e7eb;
}

.bookmark-inline-tag button {
  border: 0;
  padding: 0;
  color: #64748b;
  line-height: 1;
  background: transparent;
  cursor: pointer;
}

.bookmark-add-tag {
  color: #64748b;
  cursor: pointer;
}

.bookmark-add-tag:hover,
.bookmark-inline-tag button:hover {
  color: #0f172a;
  background: #d1d5db;
}

.bookmark-tag-input-tag {
  display: inline-flex;
  width: auto;
  min-width: 70px;
  max-width: 160px;
  min-height: 0;
  margin-left: 8px;
  border: 0;
  border-radius: 999px;
  padding: 3px 8px;
  color: #334155;
  font-size: 0.78rem;
  line-height: 1.2;
  vertical-align: middle;
  background: #e5e7eb;
  field-sizing: content;
}

.bookmark-tag-input-tag:focus {
  border: 0;
  box-shadow: 0 0 0 3px #64748b26;
  outline: 0;
}

.detail-note-input {
  display: block;
  width: 100%;
  min-height: 20px;
  margin-top: 9px;
  margin-bottom: -4px;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: #334155;
  font-size: 0.95rem;
  font-style: italic;
  line-height: 1.5;
  background: transparent;
  resize: none;
  field-sizing: content;
}

.detail-note-input:focus {
  border: 0;
  box-shadow: none;
  outline: 0;
}

.detail-card h3 {
  display: block;
  margin: 0;
  padding: 11px 18px;
  color: #1e3a8a;
  font-size: 0.95rem;
  background: #dbeafe;
}

.detail-card p {
  margin: 0;
  color: #334155;
  line-height: 1.65;
}

.detail-card:not(.detail-header) p {
  padding: 14px 18px 17px;
  line-height: 1.5;
}

.detail-card:not(.detail-header) .word-list {
  padding: 14px 18px 7px;
}

.detail-card:not(.detail-header) p + p,
.detail-card:not(.detail-header) .comparison-text,
.detail-card:not(.detail-header) .comparison-loader p {
  padding-top: 0;
}

.detail-loader {
  text-align: center;
}

.quote-card h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #4c1d95;
  background: #ede9fe;
}

.quote-source {
  color: #6d28d9;
  line-height: 1;
  text-decoration: none;
}

.quote-source img {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.word-button {
  margin: 0 6px 7px 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 11px;
  color: #1d4ed8;
  background: #eff6ff;
  cursor: pointer;
}

.word-button:hover {
  border-color: #bfdbfe;
  color: #1e40af;
  background: #dbeafe;
  transform: translateY(-1px);
}

.word-button[selected] {
  border-color: #2563eb;
  color: #ffffff;
  background: #2563eb;
}

.inline-word-link {
  border: 0;
  padding: 0;
  color: #1d4ed8;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  background: transparent;
  cursor: pointer;
}

.inline-word-link:hover {
  color: #1e40af;
}

.top-back-button,
.top-save-button {
  position: absolute;
  top: 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  color: #334155;
  background: #f8fafce0;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.top-back-button {
  left: 0;
}

.top-save-button {
  right: 0;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.page-size-field {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  min-height: 40px;
  gap: 8px;
  align-items: center;
  color: #334155;
  font-size: 0.86rem;
}

.page-size-field select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  color: #334155;
  background: #f8fafce0;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.save-star.saved {
  color: #eab308;
}

.pos {
  display: inline-flex;
  margin-left: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #1e40af;
  font-size: 0.78rem;
  line-height: 1.2;
  vertical-align: middle;
  background: #dbeafe;
}

.user-tag {
  color: #475569;
  background: #e5e7eb;
}

.first-user-tag {
  margin-left: 4px;
}

.level-tag {
  display: inline-flex;
  margin-left: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #1e40af;
  font-size: 0.78rem;
  line-height: 1.2;
  vertical-align: middle;
  background: #dbeafe;
}

.level-a1 {
  color: #166534;
  background: #dcfce7;
}

.level-a2 {
  color: #3f6212;
  background: #ecfccb;
}

.level-b1 {
  color: #713f12;
  background: #fef3c7;
}

.level-b2 {
  color: #9a3412;
  background: #ffedd5;
}

.level-c1 {
  color: #991b1b;
  background: #fee2e2;
}

.level-c2 {
  color: #581c87;
  background: #f3e8ff;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 540px) {
  .page {
    padding: 28px 14px;
  }

  .top-bar {
    align-items: center;
  }

  h1 {
    font-size: 2.5rem;
  }


  .home-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .home-card {
    min-height: 124px;
    border-radius: 22px;
  }

  .page-header-status {
    padding-right: 80px;
    padding-left: 82px;
    font-size: 0.98rem;
  }

  .page-size-field span {
    display: none;
  }

  .page-size-field select {
    padding: 0 10px;
  }

  .top-back-button,
  .top-save-button {
    padding: 0 12px;
  }

  .search-form input {
    border-color: var(--line-strong);
    background: #ffffff;
  }

  .search-form button {
    width: 54px;
    padding: 0;
    font-size: 0;
  }

  .search-form button::before {
    display: inline-block;
    width: 18px;
    height: 18px;
    background: url("image/search.svg") center / contain no-repeat;
    content: "";
  }
}

@media (hover: none), (pointer: coarse) {
  .home-card:hover,
  .meaning-card:hover {
    transform: none;
  }
}
