:root {
  --bg-color: #0F0F11;
  --primary-glow: #261418;
  --accent: #E9C46A;
  --success: #2A9D8F;
  --card-bg: rgba(30, 30, 35, 0.8);
  --border-color: rgba(255, 255, 255, 0.05);
  --text-primary: #F0F0F0;
  --text-secondary: #A0A0A0;
  --font-ui: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html, body {
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

body {
  background-color: var(--bg-color);
  background-image: radial-gradient(circle at 50% 0%, var(--primary-glow) 0%, rgba(38, 20, 24, 0) 70%);
  background-attachment: fixed;
  font-family: var(--font-ui);
  color: var(--text-primary);
  margin: 0;
  padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
  -webkit-tap-highlight-color: transparent;
  -webkit-overflow-scrolling: touch;
}

header {
  padding: 15px;
  text-align: center;
  background: rgba(0,0,0,0.1);
  border-bottom: 1px solid var(--border-color);
}

h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-primary);
  text-transform: uppercase;
}

h3 {
  margin: 0 0 15px 0;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

label {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

nav.workflow-tabs {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(18, 18, 18, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  counter-reset: tab-counter;
}

.tab-btn {
  flex: 1;
  padding: 16px 5px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
  touch-action: manipulation;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom: 3px solid var(--accent);
}

.tab-btn:not([style*='display: none']) { counter-increment: tab-counter; }
.tab-btn:not([style*='display: none'])::before { content: counter(tab-counter) '. '; font-weight: 400; }

.workflow-tabs.sub-tabs {
  background: rgba(24, 24, 28, 0.8);
  border-bottom: 1px solid var(--border-color);
  margin: 0 0 20px 0;
  padding: 0;
}

.tab-btn.sub-tab {
  font-size: 0.75rem;
  padding: 12px 8px;
}

.tab-btn.sub-tab.active {
  color: var(--accent);
  border-bottom: 3px solid var(--accent);
}

.container {
  padding: 15px;
  max-width: 500px;
  margin: auto;
  overflow-x: hidden;
}

.card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 15px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.5s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.input-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; }
.input-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.full-width {
  width: 100% !important;
  text-align: left !important;
}

input, textarea, select {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-family: var(--font-ui);
  font-weight: 500;
  text-align: center;
  transition: all 0.2s ease;
}

input[type="number"] {
  font-family: var(--font-mono);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233, 196, 106, 0.3);
}

input.name-input { width: 110px; text-align: left; font-size: 0.85rem; font-family: var(--font-ui); }
input.full-width { width: 100%; box-sizing: border-box; text-align: left; font-size: 0.85rem; }

textarea.wide-input {
  width: 100%;
  height: auto;
  box-sizing: border-box;
  font-size: 0.85rem;
  line-height: 1.5;
  font-family: var(--font-ui);
  padding: 12px;
  overflow-y: hidden;
  resize: vertical;
  border: 1px solid var(--border-color);
  background: rgba(0,0,0,0.2);
  color: var(--text-primary);
  border-radius: 10px;
}

select {
  padding-right: 30px;
  cursor: pointer;
}

.timer-display {
  font-size: 4rem;
  font-family: var(--font-mono);
  font-weight: 700;
  text-align: center;
  margin: 10px 0;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(233, 196, 106, 0.3);
}

.phase-timer-display {
  font-size: 2rem;
  color: var(--success);
  text-shadow: 0 0 10px rgba(42, 157, 143, 0.3);
}

.timer-controls { display: flex; gap: 10px; margin-bottom: 10px; }

.timer-btn {
  flex: 2;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  font-weight: 700;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
}

.reset-btn {
  flex: 1;
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

.timer-btn.start { background: var(--success); color: #fff; }
.timer-btn.stop { background: var(--accent); color: #000; }

.timer-btn:hover { transform: translateY(-2px); }

.checklist-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1px solid transparent;
  border-left: 4px solid var(--accent);
  cursor: pointer;
  transition: all 0.3s ease;
}

.checklist-item.done {
  opacity: 0.4;
  background: transparent;
  border-left-color: var(--success);
  text-decoration: line-through;
}

.checklist-item:not(.done) {
  opacity: 1;
  border-left: 4px solid var(--accent) !important;
  background: rgba(0, 0, 0, 0.15);
}

.checklist-item:hover { background: rgba(0, 0, 0, 0.25); border-color: var(--border-color); }

.res-label { font-family: var(--font-ui); font-weight: 600; font-size: 0.9rem; }
.check-val { font-family: var(--font-mono); font-weight: 700; font-size: 1rem; color: var(--text-primary); }

.hidden { display: none !important; }

.voice-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 24px;
  background: var(--accent);
  color: black;
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 1.8rem;
  cursor: pointer;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.voice-fab:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}

.voice-fab.listening {
  background: var(--success);
  animation: pulse-mic 1.5s infinite;
}

@keyframes pulse-mic {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(42, 157, 143, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 20px rgba(42, 157, 143, 0); }
  100% { transform: scale(1); }
}

.section-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 8px 0 6px 0;
  display: block;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.library-list-scroll {
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

#libraryList {
  min-height: 0;
}

.library-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.2);
  padding: 10px 15px;
  border-radius: 10px;
  margin-bottom: 5px;
  font-size: 0.85rem;
}

.now-btn, button:not(.tag-btn):not(.tab-btn):not(.timer-btn):not(.reset-btn):not(.voice-fab) {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 10px 15px;
  touch-action: manipulation;
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  text-transform: uppercase;
}

.pie-num {
  background: var(--accent);
  color: black;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
  flex-shrink: 0;
  font-family: var(--font-mono);
}

.remove-btn {
  background: none;
  border: none;
  color: #ff4757;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 8px;
}

.sub-tab-content {
  display: none;
}

.sub-tab-content.active {
  display: block;
  animation: fadeIn 0.5s ease;
}

#breadPrefermentType {
  width: 280px;
  max-width: 100%;
  padding-right: 30px;
}

.tag-btn {
  background: rgba(233, 196, 106, 0.1) !important;
  border: 1px solid var(--accent);
  color: var(--text-primary) !important;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.tag-btn.active,
button.tag-btn.active {
  background: var(--accent) !important;
  color: #000 !important;
  border-color: var(--accent) !important;
}

.tag-btn:hover {
  background: rgba(233, 196, 106, 0.3);
}

input[type="range"] {
  -webkit-appearance: none;
  height: 8px;
  background: rgba(233, 196, 106, 0.2);
  border-radius: 5px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

#toppingNotes {
  width: 100%;
  min-height: 100px;
  height: auto;
  max-height: 400px;
  overflow-y: auto;
  resize: vertical;
  box-sizing: border-box;
  padding: 12px;
  line-height: 1.5;
  font-size: 1rem;
  font-family: var(--font-ui);
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 10px;
  text-align: left !important;
  transition: height 0.2s ease-out;
}