:root {
  color-scheme: light dark;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
  font-size: 16px;
  --accent: #1769ff;
  --accent-muted: rgba(23, 105, 255, 0.15);
  --surface: rgba(255, 255, 255, 0.75);
  --border: rgba(0, 0, 0, 0.08);
  --shadow: rgba(15, 23, 42, 0.16);
  --content-width: min(100%, 1480px);
  background: linear-gradient(180deg, #f4f7ff 0%, #ffffff 60%);
  padding: 0;
  margin: 0;
}

@media (prefers-color-scheme: dark) {
  :root {
    background: linear-gradient(180deg, #0f172a 0%, #111827 60%);
    --accent: #8ab4ff;
    --accent-muted: rgba(138, 180, 255, 0.2);
    --surface: rgba(17, 24, 39, 0.65);
    --border: rgba(255, 255, 255, 0.08);
    --shadow: rgba(0, 0, 0, 0.4);
  }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.page {
  width: min(1620px, 100vw);
  padding: clamp(1.5rem, 3vw, 3rem);
  display: flex;
  flex-direction: column;
  gap: clamp(1.5rem, 3vw, 2.5rem);
}

.page__header {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 30px var(--shadow);
  padding: clamp(1rem, 2vw, 1.5rem);
}

.page__header h1 {
  margin-top: 0;
  margin-bottom: 0.3rem;
  font-size: clamp(1.6rem, 2.2vw, 2.2rem);
}

.page__header p {
  margin: 0;
  max-width: 65ch;
}

.page__content {
  width: var(--content-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 3.2fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 3vw, 2.5rem);
  align-items: stretch;
}

.word-panel {
  align-self: stretch;
  width: 100%;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 30px var(--shadow);
  padding: clamp(1rem, 2vw, 1.5rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.word-panel__header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.word-panel__header h2 {
  margin: 0;
  font-size: clamp(1.2rem, 1.8vw, 1.5rem);
}

.word-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.action-button {
  font: inherit;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.action-button:hover,
.action-button:focus-visible {
  background: var(--accent);
  color: #fff;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.word-panel__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.word-item {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 12px;
  border: 1px solid transparent;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  padding: 0.4rem 0.5rem 0.4rem 0.4rem;
  transition: transform 0.1s ease, border 0.1s ease, background 0.1s ease;
}

.word-item:focus-within,
.word-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent-muted);
}

.word-item__toggle {
  all: unset;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  flex: 1 1 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.word-item__toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.word-item__toggle[data-active="true"] {
  background: var(--accent-muted);
  border-radius: 8px;
}

.word-panel__badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.word-item__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.word-item__star {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  padding: 0.2rem;
  color: #cbd5f5;
  transition: color 0.15s ease, transform 0.15s ease;
}

.word-item__star:hover,
.word-item__star:focus-visible {
  color: var(--accent);
  transform: scale(1.1);
}

.word-item__star[data-starred="true"] {
  color: #ffb400;
}

.word-item__pronounce {
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.word-item__pronounce:hover,
.word-item__pronounce:focus-visible {
  background: var(--accent-muted);
  color: inherit;
}

.word-panel__list::-webkit-scrollbar {
  width: 0.6rem;
}

.word-panel__list::-webkit-scrollbar-thumb {
  background: rgba(23, 105, 255, 0.35);
  border-radius: 999px;
}

@media (max-width: 1100px) {
  .page__content {
    grid-template-columns: 1fr;
  }

  .word-panel {
    height: auto;
  }

  .word-panel__list {
    max-height: none;
  }
}

.picture-area {
  display: block;
}

.picture-area__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.picture-area__picker {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.75);
}

.picture-area__picker select {
  appearance: none;
  padding: 0.45rem 2.4rem 0.45rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9)
    url('data:image/svg+xml,%3Csvg width="10" height="6" viewBox="0 0 10 6" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath d="M1 1l4 4 4-4" stroke="%231769ff" stroke-width="1.5" fill="none" stroke-linecap="round"/%3E%3C/svg%3E')
    no-repeat right 0.9rem center;
  font: inherit;
  color: inherit;
  min-width: 220px;
  cursor: pointer;
}

.picture-area__picker select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.picture-area__meta {
  font-size: 0.9rem;
  color: rgba(15, 23, 42, 0.6);
}

.picture-area__canvas-wrapper {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 20px 35px var(--shadow);
  background: rgba(255, 255, 255, 0.85);
  padding: clamp(0.5rem, 2vw, 1rem);
}

.picture-area canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  background: #f5f5f5;
}

.picture-area__status {
  position: absolute;
  inset: clamp(0.5rem, 2vw, 1rem);
  background: rgba(0, 0, 0, 0.08);
  color: #000;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.9rem;
  pointer-events: none;
}

@media (prefers-color-scheme: dark) {
  .word-panel__list button {
    background: rgba(15, 23, 42, 0.75);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
  }
  
  .picture-area__canvas-wrapper {
    background: rgba(17, 25, 40, 0.85);
  }

  .picture-area__status {
    background: rgba(255, 255, 255, 0.16);
    color: #f8fafc;
  }

  .picture-area__picker {
    color: rgba(226, 232, 240, 0.85);
  }

  .picture-area__picker select {
    background: rgba(30, 41, 59, 0.9)
      url('data:image/svg+xml,%3Csvg width="10" height="6" viewBox="0 0 10 6" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath d="M1 1l4 4 4-4" stroke="%238ab4ff" stroke-width="1.5" fill="none" stroke-linecap="round"/%3E%3C/svg%3E')
      no-repeat right 0.9rem center;
    color: inherit;
    border-color: rgba(148, 163, 184, 0.3);
  }

  .picture-area__meta {
    color: rgba(226, 232, 240, 0.7);
  }
}

.starred-panel {
  width: var(--content-width);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 30px var(--shadow);
  padding: clamp(1rem, 2vw, 1.5rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.starred-panel__header {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.starred-panel__header h2 {
  margin: 0;
  font-size: clamp(1.2rem, 1.8vw, 1.5rem);
}

.starred-panel__header p {
  margin: 0;
  font-size: 0.95rem;
  color: rgba(15, 23, 42, 0.7);
}

.starred-panel__empty {
  font-size: 0.95rem;
  color: rgba(15, 23, 42, 0.65);
}

@media (prefers-color-scheme: dark) {
  .starred-panel__header p,
  .starred-panel__empty {
    color: rgba(226, 232, 240, 0.75);
  }
}

.starred-panel__table-wrapper {
  overflow-x: auto;
}

.starred-panel__table {
  width: 100%;
  border-collapse: collapse;
  min-width: 320px;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.starred-panel__table th,
.starred-panel__table td {
  padding: 0.75rem 0.9rem;
  text-align: left;
}

.starred-panel__table thead {
  background: var(--accent-muted);
  color: inherit;
}

.starred-panel__table tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.04);
}

.starred-panel__table tbody tr:hover {
  background: rgba(23, 105, 255, 0.08);
}

.starred-panel__actions-header {
  text-align: right;
}

.starred-panel__table td:last-child {
  text-align: right;
}

.starred-panel__actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.starred-table__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  font: inherit;
  color: var(--accent);
  text-decoration: none;
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  transition: background 0.15s ease, color 0.15s ease;
  background: transparent;
  border: none;
  cursor: pointer;
}

.starred-table__btn:is(a) {
  border: 1px solid transparent;
}

.starred-table__btn:hover,
.starred-table__btn:focus-visible {
  background: var(--accent-muted);
  color: inherit;
}
