@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600&family=Cormorant+Garamond:ital,wght@0,400;0,500;1,400;1,600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:       #15120e;
  --surface:  #1c1812;
  --panel-bg: #221d15;
  --border:   #3d3220;
  --gold:     #caa74f;
  --gold-dim: #7e6433;
  --text:     #ebdcb9;
  --muted:    #82745b;
  --green:    #4fa676;
  --red:      #bd4a4a;
  --orange:   #bd7b3c;
  --mono:     'JetBrains Mono', monospace;
  --keyboard-width: 360px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Cormorant Garamond', Georgia, serif;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
}

#control-keyboard {
  width: var(--keyboard-width);
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 5px 0 25px rgba(0,0,0,0.5);
}

#control-keyboard.retracted {
  transform: translateX(calc(-1 * var(--keyboard-width)));
}

.kb-header {
  padding: 1.2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  text-align: center;
}
.kb-header h2 {
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  color: var(--gold);
  letter-spacing: 2px;
}
.kb-header p {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

.kb-scroller {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1rem;
}

.kb-section {
  margin-bottom: 1.5rem;
}

.kb-label {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  color: var(--gold);
  margin-bottom: 0.6rem;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(202,167,79,0.15);
  padding-bottom: 0.2rem;
}

.macro-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.macro-key {
  background: linear-gradient(135deg, #2b241b 0%, #1f1a13 100%);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 0.8rem 0.5rem;
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 52px;
}
.macro-key span.sub {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--muted);
  margin-top: 0.2rem;
  letter-spacing: 0;
}
.macro-key:hover {
  border-color: var(--gold);
  background: linear-gradient(135deg, #382e22 0%, #262017 100%);
  box-shadow: 0 4px 8px rgba(202,167,79,0.15);
}
.macro-key:active, .macro-key.active {
  background: var(--gold-dim);
  color: var(--bg);
  border-color: var(--gold);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.6);
}
.macro-key.active span.sub {
  color: rgba(21,18,14,0.7);
}

.macro-key.utility-key {
  background: linear-gradient(135deg, #23282b 0%, #15191c 100%);
  border-color: #2c353a;
}
.macro-key.utility-key:hover {
  border-color: #4f96ca;
}
.macro-key.utility-key.active {
  background: #335e7e;
  color: #fff;
}

.kb-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}
.kb-input-group label {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.kb-input-row {
  display: flex;
  gap: 0.4rem;
}
.kb-field {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  padding: 0.5rem;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8rem;
  border-radius: 3px;
  width: 100%;
}
.kb-field:focus {
  outline: none;
  border-color: var(--gold);
}

#kb-mini-log {
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.6rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  height: 110px;
  overflow-y: auto;
  white-space: pre-wrap;
}

#kb-trigger {
  position: absolute;
  top: 20px;
  right: -42px;
  width: 42px;
  height: 42px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--gold);
  font-size: 1.1rem;
  box-shadow: 4px 0 10px rgba(0,0,0,0.3);
  z-index: 101;
}
#kb-trigger:hover {
  color: var(--text);
  background: var(--surface);
}

#presentation-canvas {
  flex-grow: 1;
  margin-left: var(--keyboard-width);
  transition: margin-left 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3rem;
  position: relative;
}

#control-keyboard.retracted ~ #presentation-canvas {
  margin-left: 0;
}

.canvas-frame {
  width: 100%;
  max-width: 900px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4rem 3rem;
  box-shadow: 0 15px 50px rgba(0,0,0,0.6);
  text-align: center;
  position: relative;
  display: none;
}

.canvas-ref {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 2rem;
  letter-spacing: 2px;
  margin-bottom: 2rem;
  font-weight: 400;
}

.canvas-text {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 2rem;
  line-height: 1.8;
  font-style: italic;
  color: var(--text);
  min-height: 6rem;
  margin-bottom: 2.5rem;
}

.canvas-meta {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  align-items: center;
  border-top: 1px solid rgba(61,50,32,0.4);
  padding-top: 1.5rem;
}

.badge {
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1px;
  font-family: var(--mono);
}
.badge-active { background: rgba(202,167,79,0.15); color: var(--gold); border: 1px solid var(--gold); }
.badge-info   { background: rgba(79,166,118,0.12); color: var(--green); border: 1px solid var(--green); }
.badge-alarm  { background: rgba(189,123,60,0.15); color: var(--orange); border: 1px solid var(--orange); }

.canvas-idle {
  text-align: center;
  max-width: 600px;
  display: block;
}
.canvas-idle h1 {
  font-family: 'Cinzel', serif;
  color: var(--gold-dim);
  font-size: 3.5rem;
  letter-spacing: 6px;
  margin-bottom: 1rem;
  text-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.canvas-idle p {
  font-size: 1.3rem;
  color: var(--muted);
  font-style: italic;
}

#hud-progress-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 2rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  background: linear-gradient(to top, rgba(21,18,14,0.95) 0%, rgba(21,18,14,0) 100%);
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}
.hud-row .status-label {
  color: var(--gold);
  font-weight: 500;
}

.hud-progress-wrapper {
  height: 4px;
  background: rgba(61,50,32,0.3);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.hud-bar {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width 0.1s linear;
}
#hud-audio-bar { background: var(--gold); }
#hud-timer-bar { background: var(--gold-dim); transition: none; }

#alarm-toast {
  position: absolute;
  top: 30px;
  right: 30px;
  background: #2c1a16;
  border: 1px solid var(--red);
  padding: 1rem 1.5rem;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  display: none;
  animation: slideInRight 0.3s cubic-bezier(0.25, 1, 0.5, 1) forwards;
  z-index: 999;
}
@keyframes slideInRight { from{opacity:0;transform:translateX(30px)} to{opacity:1;transform:translateX(0)} }

.alarm-toast-content {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--text);
}
.alarm-toast-content .icon {
  font-size: 1.5rem;
  animation: flashIcon 1s steps(2, start) infinite;
}
@keyframes flashIcon { 0%, 100% { opacity: 1; color: var(--red); } 50% { opacity: 0.3; color: var(--orange); } }
.alarm-toast-content .title { font-family: 'Cinzel', serif; font-weight: 600; color: var(--red); font-size: 0.9rem; }
.alarm-toast-content .time { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }