﻿:root {
  --bg-1: #e0f2fe;
  --bg-2: #f8fafc;
  --panel: #ffffffee;
  --text: #102a43;
  --border: #d7e2ea;
  --shadow: 0 6px 16px #0f172a12;
  --primary: #1d4ed8;
}

* {
  box-sizing: border-box;
  min-width: 0;
}

html,
body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  font-family: "Verdana", "Trebuchet MS", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, var(--bg-1) 0%, var(--bg-2) 55%);
}

.app-shell {
  width: min(100%, 1100px);
  margin: 0 auto;
  padding: 8px max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left));
  display: grid;
  gap: 8px;
}

.panel {
  width: 100%;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  box-shadow: var(--shadow);
}

h1,
h2 {
  margin: 0 0 6px;
  line-height: 1.12;
}

h1 {
  font-size: 1.05rem;
}

.phrase-bar {
  min-height: 36px;
  padding: 4px;
  border: 2px dashed #bfdbfe;
  border-radius: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: #f0f9ff;
}

.phrase-chip {
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid #93c5fd;
  background: #dbeafe;
  font-size: 0.78rem;
  font-weight: 700;
}

.phrase-preview {
  margin: 5px 0 0;
  font-size: 0.88rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.evaluation {
  margin: 5px 0 0;
  padding: 5px 7px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 0.76rem;
}

.evaluation.neutral {
  background: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}

.evaluation.correct {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.evaluation.almost {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.evaluation.incomplete {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

.control-row {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

button,
select,
input {
  font: inherit;
}

button {
  min-height: 34px;
  width: 100%;
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid #94a3b8;
  background: #ffffff;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.74rem;
  line-height: 1.1;
  white-space: normal;
  touch-action: manipulation;
}

button.primary {
  background: var(--primary);
  color: #fff;
  border-color: #1e40af;
}

button:active {
  transform: scale(0.98);
}

.category-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 2px 4px;
  margin-bottom: 6px;
}

.category-tab {
  flex: 0 0 auto;
  min-height: 34px;
  width: auto;
  white-space: nowrap;
  padding: 0 10px;
  font-size: 0.75rem;
}

.category-tab.active {
  border-width: 2px;
}

.cards-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.word-card {
  width: 100%;
  height: 130px;
  min-height: 130px;
  max-height: 130px;
  border-radius: 10px;
  border: 2px solid #cbd5e1;
  padding: 4px;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: center;
  justify-items: center;
  text-align: center;
  overflow: hidden;
}

.word-image {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid #ffffff99;
  background: #ffffff70;
}

.word-label {
  margin-top: 2px;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.modal {
  position: fixed;
  inset: 0;
  background: #0f172a80;
  display: grid;
  place-items: center;
  padding: 10px;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(100%, 560px);
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  background: #fff;
  padding: 10px;
}

.type-form {
  display: grid;
  gap: 6px;
}

.type-form input,
.type-form select {
  min-height: 38px;
  width: 100%;
  font-size: 0.9rem;
  border-radius: 8px;
  border: 1px solid #94a3b8;
  padding: 5px 7px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 2px;
}

@media (max-width: 420px) {
  .control-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .word-card {
    height: 118px;
    min-height: 118px;
    max-height: 118px;
  }
}

@media (min-width: 560px) {
  h1 {
    font-size: 1.12rem;
  }

  .phrase-preview {
    font-size: 0.93rem;
  }

  button {
    min-height: 36px;
    font-size: 0.76rem;
  }

  .category-tab {
    font-size: 0.78rem;
  }

  .word-card {
    height: 116px;
    min-height: 116px;
    max-height: 116px;
  }

  .word-image {
    width: 42px;
    height: 42px;
  }

  .word-label {
    font-size: 0.72rem;
  }

  .modal-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .app-shell {
    padding: 10px;
    gap: 10px;
  }

  .panel {
    padding: 10px;
  }

  .control-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  button {
    min-height: 38px;
    font-size: 0.78rem;
  }

  .cards-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .word-card {
    height: 112px;
    min-height: 112px;
    max-height: 112px;
  }

  .word-image {
    width: 40px;
    height: 40px;
  }

  .word-label {
    font-size: 0.7rem;
  }
}

@media (min-width: 1024px) {
  .cards-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .word-card {
    height: 108px;
    min-height: 108px;
    max-height: 108px;
  }
}

@media (max-width: 600px) {
  .category-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    overflow: visible;
    padding: 0;
    margin-bottom: 6px;
  }

  .category-tab {
    width: 100%;
    min-height: 34px;
    white-space: normal;
    padding: 4px 8px;
    text-align: center;
  }
}
