:root {
  --bg: #000000;
  --panel: rgba(255, 255, 255, 0.03);
  --text: #f5f7fb;
  --muted: rgba(255, 255, 255, 0.72);
  --accent: #dfeaf7;
  --button-bg: rgba(255, 255, 255, 0.04);
  --button-hover: rgba(255, 255, 255, 0.1);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", sans-serif;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  overflow: hidden;
  background: #000000;
  transition: background 0.25s ease;
}

body.success {
  background: #0f7a3c !important;
}

body.warning {
  background: #d97706 !important;
}

body.danger {
  background: #b91c1c !important;
}

button {
  font: inherit;
}

.app-shell {
  width: min(980px, calc(100vw - 48px));
  min-height: min(90vh, 770px);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.38);
  transition: width 0.2s ease, min-height 0.2s ease, border-radius 0.2s ease, background 0.2s ease;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px 12px;
}

.brand {
  font-size: clamp(0.9rem, 1.3vw, 1.35rem);
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.82);
}

.top-button,
.primary-btn,
.secondary-btn,
.adjust-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.top-button:hover,
.primary-btn:hover,
.secondary-btn:hover,
.adjust-btn:hover {
  background: var(--button-hover);
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}

.top-button {
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.92rem;
}

.countdown-panel {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 26px;
  padding: 20px 28px 36px;
  overflow: hidden;
}

.config-panel {
  width: min(820px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.quick-config {
  width: min(820px, 100%);
  display: grid;
  gap: 16px;
}

.preset-block {
  display: grid;
  gap: 10px;
}

.config-heading {
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.68);
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.time-preset {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  cursor: pointer;
  transition: all 0.18s ease;
}

.time-preset:hover {
  background: rgba(255, 255, 255, 0.08);
}

.color-pickers {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: center;
}

.color-field,
.threshold-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.color-field input {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.threshold-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.threshold-field {
  display: inline-flex;
  padding: 10px 12px;
  border-radius: 14px;
}

.threshold-field input {
  width: 76px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  border-radius: 8px;
  font-size: 0.95rem;
  padding: 7px 8px;
  text-align: center;
}

body.is-running .countdown-panel {
  justify-content: center;
  gap: 0;
  padding-top: 10px;
}

body.is-running .app-shell,
body.is-fullscreen .app-shell {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  width: 100vw;
  min-height: 100vh;
  border-radius: 0;
  padding: 0;
}

body.is-running .topbar,
body.is-fullscreen .topbar,
body.is-finished .topbar {
  display: none;
}

body.is-finished .config-panel,
body.is-finished .keyboard-hint,
body.is-finished .domotikom-brand,
body.is-finished .action-row,
body.is-finished .quick-config {
  display: none;
}

body.is-finished .countdown-panel {
  justify-content: center;
  gap: 0;
}

.timer-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.timer-display {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  font-size: clamp(2.8rem, 7vw, 9rem);
  line-height: 0.9;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--text);
  user-select: none;
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.15);
  white-space: nowrap;
  overflow: hidden;
  padding-inline: 8px;
}

body.is-running .timer-display,
body.is-fullscreen .timer-display {
  font-size: clamp(6rem, 18vw, 30rem);
  letter-spacing: 0.02em;
  padding-inline: 0;
}

.controls {
  width: min(780px, 100%);
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 18px;
}

.unit-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.unit-label {
  font-size: 0.9rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.unit-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.adjust-btn {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  font-size: 2rem;
  line-height: 1;
}

.unit-value {
  min-width: 60px;
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 700;
  text-align: center;
}

.action-row {
  display: flex;
  justify-content: center;
  gap: 18px;
  width: 100%;
}

.keyboard-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
}

.keyboard-hint span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-weight: 700;
}

.domotikom-brand {
  margin-top: auto;
  padding-top: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 0.66rem;
  letter-spacing: 0.15em;
  text-transform: none;
  color: rgba(255, 255, 255, 0.5);
  opacity: 0.9;
  text-align: center;
  user-select: none;
}

.domotikom-brand a {
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
}

.domotikom-brand a:hover {
  color: rgba(255, 255, 255, 0.8);
}

body.is-running .controls,
body.is-running .action-row,
body.is-running .brand,
body.is-running .keyboard-hint,
body.is-running .domotikom-brand,
body.is-running .quick-config,
body.is-running .config-panel {
  opacity: 0;
  visibility: hidden;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  pointer-events: none;
}

body.is-fullscreen .top-button {
  display: none;
}

body.is-fullscreen .countdown-panel {
  padding: 0;
}

.primary-btn,
.secondary-btn {
  min-width: 170px;
  padding: 16px 28px;
  border-radius: 16px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.primary-btn {
  background: var(--text);
  color: #000;
  border-color: var(--text);
}

.secondary-btn {
  background: transparent;
}

@media (max-width: 700px) {
  .app-shell {
    min-height: 100vh;
    border-radius: 0;
    width: 100%;
  }

  body {
    padding: 0;
  }

  .topbar {
    padding-inline: 18px;
  }

  .controls {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .action-row {
    flex-direction: column;
    align-items: stretch;
    padding-inline: 20px;
  }

  .primary-btn,
  .secondary-btn {
    width: 100%;
    min-width: 0;
  }
}
