:root {
  --green: #0a7d3e;
  --red: #c8372c;
  --ink: #1e1e24;
  --muted: #6b6b75;
  --bg: #f7f7f5;
  --card-bg: #ffffff;
  --border: #e4e2dd;
  --irregular: #c8372c;
  --irregular-bg: #fdeceb;
  --accent-bg: #f0f7f2;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: 40px;
}

.app-header {
  background: linear-gradient(90deg, var(--green), #0a7d3e 33%, #ffffff 33%, #ffffff 66%, var(--red) 66%);
  padding: 3px 0 0 0;
}

.header-inner {
  background: var(--ink);
  color: white;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.header-inner h1 {
  font-size: 1.2rem;
  margin: 0;
}

.tabs { display: flex; gap: 6px; }

.tab-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: white;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
}

.tab-btn.active {
  background: white;
  color: var(--ink);
  font-weight: 600;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 14px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.search-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.search-form #search-input {
  flex: 1 1 200px;
}

#pos-hint {
  padding: 12px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: white;
  font-size: 0.9rem;
  color: var(--ink);
}

#search-input, #review-filter {
  flex: 1;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 1rem;
  background: white;
}

#search-btn, #review-refresh-btn {
  padding: 12px 18px;
  border-radius: var(--radius);
  border: none;
  background: var(--green);
  color: white;
  font-size: 1rem;
  cursor: pointer;
}

#search-btn:active, #review-refresh-btn:active { opacity: 0.85; }

.status {
  min-height: 22px;
  margin: 10px 2px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.word-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.lang-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.lang-cell {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.lang-tag {
  font-size: 0.65rem;
  font-weight: 700;
  color: white;
  background: var(--muted);
  padding: 2px 6px;
  border-radius: 5px;
  min-width: 26px;
  text-align: center;
}

.lang-cell.it .lang-tag { background: var(--green); }
.lang-cell.en .lang-tag { background: #2563a8; }
.lang-cell.ja .lang-tag { background: var(--red); }

.lang-text { font-size: 1.05rem; }
.lang-cell.it .lang-text { font-weight: 700; font-size: 1.2rem; }

.meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.pos-badge {
  font-size: 0.75rem;
  background: var(--accent-bg);
  color: var(--green);
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
}

.summary-text {
  font-size: 0.9rem;
  color: var(--muted);
}

.seen-row {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 10px;
  padding: 8px 10px;
  background: #fbf7ea;
  border-radius: 8px;
}

.seen-dates { color: var(--ink); }

.forms-area { margin-top: 6px; }

.form-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  margin: 12px 0 6px;
  border-left: 4px solid var(--green);
  padding-left: 8px;
}

table.forms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin-bottom: 4px;
}

table.forms-table th, table.forms-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

table.forms-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
}

.irregular-form {
  color: var(--irregular);
  font-weight: 700;
  background: var(--irregular-bg);
  border-radius: 5px;
  padding: 2px 6px;
}

.irregular-note {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--irregular);
  margin-top: 2px;
}

.review-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.review-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
  cursor: pointer;
}

.review-item:hover { border-color: var(--green); }

.review-item .ri-main { display: flex; flex-direction: column; }
.review-item .ri-it { font-weight: 700; }
.review-item .ri-sub { font-size: 0.8rem; color: var(--muted); }
.review-item .ri-count {
  font-size: 0.75rem;
  background: var(--accent-bg);
  color: var(--green);
  padding: 3px 8px;
  border-radius: 999px;
}

.review-item .ri-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.review-item .ri-updated {
  font-size: 0.72rem;
  color: var(--muted);
}

@media (min-width: 520px) {
  .lang-row { grid-template-columns: repeat(3, 1fr); }
}
