:root {
  --bg: #FBF8F3;
  --fg: #1C1A17;
  --sub: #6B655C;
  --line: #DFD8CC;
  --accent: #1C1A17;
  --live: #C1663B;
}

* { box-sizing: border-box; }

/* display を持つ要素は hidden 属性だけでは消えないので明示する */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body { overflow: hidden; }

.screen { display: none; }
.screen.is-active { display: flex; flex-direction: column; }

/* ---------- 入力・設定 ---------- */

#screen-input, #screen-settings {
  height: 100%;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  gap: 18px;
  overflow-y: auto;
}

.input-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.input-head h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .08em;
}

.field { display: flex; flex-direction: column; gap: 7px; }

.field-label {
  font-size: 13px;
  color: var(--sub);
  letter-spacing: .06em;
}

.field-note {
  font-size: 12px;
  color: var(--sub);
  line-height: 1.6;
}

textarea, input[type="text"], input[type="password"] {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;          /* 16px未満だとiOSがズームする */
  line-height: 1.7;
  color: var(--fg);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  resize: vertical;
}

textarea:focus, input:focus { outline: 2px solid var(--fg); outline-offset: -1px; }

.primary {
  width: 100%;
  padding: 17px;
  font-size: 17px;
  font-family: inherit;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 10px;
  letter-spacing: .06em;
}

.primary:disabled { opacity: .45; }

.secondary {
  width: 100%;
  padding: 15px;
  font-size: 15px;
  font-family: inherit;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--fg);
  border-radius: 10px;
  letter-spacing: .06em;
}

.secondary:disabled { opacity: .45; }

select {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--fg);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.linkish {
  padding: 6px 2px;
  font-size: 14px;
  font-family: inherit;
  color: var(--sub);
  background: none;
  border: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.resume { align-self: flex-start; }

.status {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--sub);
}

.status.err { color: #A33B22; }

/* ---------- 調理画面 ---------- */

#screen-cook { height: 100%; }

.tap-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 20px 8px;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  cursor: pointer;
  min-height: 0;
}

.tap-area:active { background: #F3EDE3; }

.cook-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}

.progress {
  font-size: 17px;
  color: var(--sub);
  font-variant-numeric: tabular-nums;
  letter-spacing: .08em;
}

.mic-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--live);
}

.mic-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.cook-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  min-height: 0;
  overflow-y: auto;
}

.step-text {
  margin: 0;
  font-size: clamp(30px, 8.2vw, 54px);
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: .02em;
}

.step-detail {
  margin: 0;
  font-size: clamp(16px, 4.2vw, 21px);
  line-height: 1.8;
  color: var(--sub);
}

/* 材料は1行1つで縦に並べる */
.step-text.is-list {
  font-size: clamp(21px, 5.4vw, 32px);
  line-height: 1.85;
  font-weight: 500;
  white-space: pre-line;
}

.cook-hint {
  flex: 0 0 auto;
  padding: 6px 0 2px;
  font-size: 12px;
  color: var(--sub);
  text-align: center;
  letter-spacing: .06em;
}

.cook-bar {
  flex: 0 0 auto;
  display: flex;
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.barbtn {
  flex: 1;
  padding: 15px 4px;
  font-size: 14px;
  font-family: inherit;
  color: var(--sub);
  background: var(--bg);
  border: none;
  letter-spacing: .06em;
}

.barbtn.is-on { color: var(--live); }

/* ---------- 音量メーター ---------- */

.level-wrap {
  flex: 0 0 auto;
  padding: 10px 20px calc(10px + env(safe-area-inset-bottom));
  background: #F3EDE3;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.level-row { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--sub); }

.level-meter {
  position: relative;
  flex: 1;
  height: 8px;
  background: #E2DACD;
  border-radius: 4px;
  overflow: hidden;
}

#level-bar {
  height: 100%;
  width: 0%;
  background: var(--sub);
  border-radius: 4px;
}

#level-thresh {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  left: 0%;
  background: var(--live);
}

.testbtn {
  padding: 9px 14px;
  font-size: 13px;
  font-family: inherit;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--sub);
  border-radius: 8px;
  letter-spacing: .04em;
}

.testbtn.is-on { color: var(--bg); background: var(--live); border-color: var(--live); }

.hits { font-variant-numeric: tabular-nums; }

.sens input[type="range"] { flex: 1; }

.sens span:last-child { font-variant-numeric: tabular-nums; min-width: 2.2em; text-align: right; }
