/* スマホ縦画面・片手操作前提のモバイルファーストCSS。実装は docs/SPEC.md 参照 */

:root {
  --tap-target-min: 48px;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-strong: #ecf3f1;
  --text: #17201d;
  --muted: #5d6863;
  --line: #d9dfdc;
  --primary: #176b58;
  --primary-press: #0f5142;
  --accent: #9c4f1f;
  --danger: #a33a3a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px 16px 104px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-button {
  min-height: var(--tap-target-min);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 700;
}

button {
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 12px;
}

textarea {
  resize: vertical;
}

label {
  display: block;
  margin: 10px 0 6px;
  color: var(--muted);
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 2px;
  font-size: 1.45rem;
}

h2 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.view[hidden] {
  display: none;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.app-header > div {
  min-width: 0;
  flex: 1;
}

.panel {
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.panel.compact {
  margin: 12px 0;
}

.status {
  min-height: 24px;
  color: var(--accent);
  font-weight: 700;
}

.subtle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.material-list,
.word-list {
  display: grid;
  gap: 10px;
}

.material-item,
.word-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
}

.material-item button {
  width: 100%;
  margin-top: 10px;
}

.item-title {
  margin-bottom: 4px;
  font-weight: 800;
}

.item-meta,
.word-context,
.word-date {
  color: var(--muted);
  font-size: 0.92rem;
}

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

.primary-button:active {
  background: var(--primary-press);
}

.secondary-button,
.file-button,
.icon-button {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.danger-button {
  border-color: #ddb5b5;
  background: #fff7f7;
  color: var(--danger);
}

.icon-button {
  width: var(--tap-target-min);
  min-width: var(--tap-target-min);
  padding: 0;
  font-size: 1.35rem;
}

.button-row,
.inline-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.file-button {
  display: grid;
  place-items: center;
  text-align: center;
}

.file-button input {
  display: none;
}

.sentence-area {
  display: grid;
  align-content: center;
  min-height: 260px;
  margin: 16px 0;
  padding: 20px 0;
}

.sentence-text {
  margin-bottom: 16px;
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.35;
}

.translation-text {
  color: var(--muted);
  font-size: 1.08rem;
}

.hidden-content {
  color: var(--muted);
  font-style: italic;
}

.toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.toggle-grid label {
  min-height: var(--tap-target-min);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.toggle-grid input {
  width: auto;
}

input[type="range"] {
  min-height: var(--tap-target-min);
  padding: 12px 0;
}

select {
  min-height: var(--tap-target-min);
}

.bottom-controls {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr 1fr;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(246, 244, 239, 0.96);
}

.bottom-controls button {
  padding-inline: 8px;
}

.control-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.word-item {
  display: grid;
  gap: 8px;
}

.word-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.word-text {
  font-size: 1.1rem;
  font-weight: 800;
}

@media (min-width: 430px) {
  .button-row,
  .inline-form {
    grid-template-columns: 1fr 1fr;
  }
}
